Skip to content
This repository was archived by the owner on Jun 19, 2019. It is now read-only.

Commit 6009711

Browse files
committed
added notification in #community for new members. Currently disabled
1 parent 9d308bf commit 6009711

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/app.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
PROXY = config('PROXY')
2727
TOKEN = config('TOKEN')
28+
COMMUNITY_CHANNEL = config('OPCODE_COMMUNITY_ID')
29+
2830
PROXY = PROXY if PROXY else None
2931
slack_client = SlackClient(TOKEN, proxies=PROXY)
3032

@@ -59,15 +61,20 @@ def new_member(event_dict):
5961
# user_id = event_dict['user']
6062
logging.info('team_join message')
6163

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)
6467

6568
new_event_logger.info('Built message: {}'.format(custom_message))
6669
response = slack_client.api_call('chat.postMessage',
6770
channel=user_id,
6871
text=custom_message,
6972
as_user=True)
7073

74+
# Notify #community
75+
# slack_client.api_call('chat.postMessage', channel=COMMUNITY_CHANNEL,
76+
# text=f"New Member -- <@{user_id}>. Automated greeting sent.")
77+
7178
if response['ok']:
7279
new_event_logger.info('New Member Slack response: {}'.format(response))
7380
else:
@@ -114,7 +121,7 @@ def run_bot(delay=1):
114121
time.sleep(delay)
115122
except Exception as e:
116123
logger.error(f'Some exception occured: {e}')
117-
logger.error(f'traceback: {traceback.format_exc(e)}')
124+
logger.error(f'traceback: {traceback.print_exc()}')
118125
slack_client.rtm_connect()
119126
else:
120127
print("Connection failed. Invalid Slack token or bot ID")

0 commit comments

Comments
 (0)