def edubot_channel_post(sc, team_bot, message, employee):
from slackclient import SlackClient
channels_list = sc.api_call('channels.list', exclude_archived=1)
channel_names = [channel['name'] for channel in channels_list['channels']]
if 'question' in channel_names:
channel_id = '#question'
post_on_question_channel(sc, channel_id, message)
else:
owner_sc = SlackClient(team_bot.owner.slack_access_token)
msg_res = owner_sc.api_call('channels.create', name='question')
channel_id = msg_res['channel']['id']
mentioned_employees = extract_mentions("<!everyone>", team_bot.slack_team_id, team_bot.owner)
if mentioned_employees:
for employee in mentioned_employees:
owner_sc.api_call('channels.invite', channel=channel_id, user=employee.user.username)
post_on_question_channel(sc, channel_id, message)
评论列表
文章目录