19
19
# COMMUNITY_CHANNEL = config('PERSONAL_PRIVATE_CHANNEL')
20
20
21
21
TOKEN = config ('OPCODE_APP_TOKEN' )
22
- # TOKEN = config('TOKEN')
23
- # COMMUNITY_CHANNEL = config('OPCODE_COMMUNITY_ID')
24
22
COMMUNITY_CHANNEL = config ('OPCODE_REWRITE_CHANNEL' )
25
23
PROJECTS_CHANNEL = config ('OPCODE_OC_PROJECTS_CHANNEL' )
24
+ # COMMUNITY_CHANNEL = config('OPCODE_COMMUNITY_ID')
26
25
27
26
PROXY = PROXY if PROXY else None
28
27
slack_client = SlackClient (TOKEN , proxies = PROXY )
@@ -40,9 +39,9 @@ def event_handler(event_dict: dict) -> None:
40
39
:param event_dict:
41
40
"""
42
41
# all_event_logger.info(event_dict)
43
- # if event_dict['type'] == 'team_join':
44
- # new_event_logger.info('New member event recieved')
45
- # new_member(event_dict)
42
+ if event_dict ['type' ] == 'team_join' :
43
+ new_event_logger .info ('New member event recieved' )
44
+ new_member (event_dict )
46
45
47
46
""" Trigger for testing team_join event """
48
47
if event_dict ['type' ] == 'message' and 'user' in event_dict .keys () and event_dict ['text' ] == 'testgreet' :
@@ -106,7 +105,7 @@ def new_member(event_dict: dict) -> None:
106
105
response = slack_client .api_call ('chat.postMessage' ,
107
106
channel = user_id ,
108
107
# channel=COMMUNITY_CHANNEL, # testing option
109
- # as_user=True,
108
+ # as_user=True, # Currently not working. DM comes from my account
110
109
text = custom_message )
111
110
112
111
r2 = slack_client .api_call ('chat.postMessage' ,
@@ -116,9 +115,9 @@ def new_member(event_dict: dict) -> None:
116
115
** HELP_MENU )
117
116
118
117
# Notify #community
119
- # text = f":tada: <@{user_id}> has joined the Slack team :tada:"
120
- # slack_client.api_call('chat.postMessage', channel=COMMUNITY_CHANNEL,
121
- # text=text, attachments=needs_greet_button())
118
+ text = f":tada: <@{ user_id } > has joined the Slack team :tada:"
119
+ slack_client .api_call ('chat.postMessage' , channel = COMMUNITY_CHANNEL ,
120
+ text = text , attachments = needs_greet_button ())
122
121
123
122
if response ['ok' ]:
124
123
new_event_logger .info ('New Member Slack response: Response 1: {} \n Response2: {}' .format (response , r2 ))
@@ -161,12 +160,11 @@ def join_channels():
161
160
162
161
163
162
# set the defalt to a 1 second delay
164
- def run_bot (delay : int = 1 ):
163
+ def run_bot (delay : int = 1 ) -> None :
165
164
"""
166
165
Runs the bot using the Slack Real Time Messaging API.
167
166
**Doesn't provide events or interactive functionality
168
167
:param delay:
169
- :return:
170
168
"""
171
169
setup_logging ()
172
170
if slack_client .rtm_connect ():
0 commit comments