|
25 | 25 |
|
26 | 26 | PROXY = config('PROXY')
|
27 | 27 | TOKEN = config('TOKEN')
|
| 28 | +COMMUNITY_CHANNEL = config('OPCODE_COMMUNITY_ID') |
| 29 | + |
28 | 30 | PROXY = PROXY if PROXY else None
|
29 | 31 | slack_client = SlackClient(TOKEN, proxies=PROXY)
|
30 | 32 |
|
@@ -59,15 +61,20 @@ def new_member(event_dict):
|
59 | 61 | # user_id = event_dict['user']
|
60 | 62 | logging.info('team_join message')
|
61 | 63 |
|
62 |
| - custom_message = build_message(MESSAGE, |
63 |
| - real_name=user_name_from_id(user_id)) |
| 64 | + real_name = user_name_from_id(user_id) |
| 65 | + |
| 66 | + custom_message = build_message(MESSAGE, real_name=real_name) |
64 | 67 |
|
65 | 68 | new_event_logger.info('Built message: {}'.format(custom_message))
|
66 | 69 | response = slack_client.api_call('chat.postMessage',
|
67 | 70 | channel=user_id,
|
68 | 71 | text=custom_message,
|
69 | 72 | as_user=True)
|
70 | 73 |
|
| 74 | + # Notify #community |
| 75 | + # slack_client.api_call('chat.postMessage', channel=COMMUNITY_CHANNEL, |
| 76 | + # text=f"New Member -- <@{user_id}>. Automated greeting sent.") |
| 77 | + |
71 | 78 | if response['ok']:
|
72 | 79 | new_event_logger.info('New Member Slack response: {}'.format(response))
|
73 | 80 | else:
|
@@ -114,7 +121,7 @@ def run_bot(delay=1):
|
114 | 121 | time.sleep(delay)
|
115 | 122 | except Exception as e:
|
116 | 123 | logger.error(f'Some exception occured: {e}')
|
117 |
| - logger.error(f'traceback: {traceback.format_exc(e)}') |
| 124 | + logger.error(f'traceback: {traceback.print_exc()}') |
118 | 125 | slack_client.rtm_connect()
|
119 | 126 | else:
|
120 | 127 | print("Connection failed. Invalid Slack token or bot ID")
|
|
0 commit comments