示例#1
0
def _send_notification(notification_type, league, text):
    if league.enable_notifications:
        for ln in league.leaguechannel_set.filter(type=notification_type,
                                                  send_messages=True):
            try:
                slackapi.send_message(ln.slack_channel, text)
            except Exception:
                logger.error(sys.exc_info())
示例#2
0
def _message_multiple_users(league, usernames, text):
    if league.enable_notifications:
        slackapi.send_message('+'.join(('@%s' % u for u in usernames)), text)
示例#3
0
def _message_user(league, username, text):
    if league.enable_notifications:
        slackapi.send_message('@%s' % username, text)
示例#4
0
def _send_notification(notification_type, league, text):
    if league.enable_notifications:
        for ln in league.leaguechannel_set.filter(type=notification_type,
                                                  send_messages=True):
            slackapi.send_message(ln.slack_channel, text)
示例#5
0
        for i in range(100):
            white_p = pairings[i]['white_player']
            black_p = pairings[i]['black_player']
            white_tz = slackapi.get_utc(pairings[i]['white_tz'])
            time.sleep(1)
            black_tz = slackapi.get_utc(pairings[i]['black_tz'])
            message = f'You have been paired in BlindFold #3 Round 1.\n'\
                      + f'<@{white_p}> (_white pieces_ , {white_tz}) vs <@{black_p}> (_black pieces_, {black_tz}) @ 15+10\n'\
                      + 'Message your opponent here as soon as possible.\n'\
                      + 'When you have agreed on a time, post it in <#CFD0VEV7G|blindfold-scheduling>.\n'
            time.sleep(1)
            slackapi.create_group_dm('%s, %s' % (white_p, black_p))
            channel_id = slackapi.create_group_dm('%s, %s' % (white_p, black_p)
            time.sleep(1)
            slackapi.send_message(message, channel_id)
            if white_p == '<Your ID>':
                slackapi.create_group_dm('%s' % (black_p))
                channel_id = slackapi.create_group_dm('%s, %s' % (white_p, black_p))
                time.sleep(1)
            elif black_p == '<Your ID>':
                slackapi.create_group_dm('%s' % (white_p))
                channel_id = slackapi.create_group_dm('%s, %s' % (white_p, black_p))
                time.sleep(1)
            else:
                slackapi.create_group_dm('%s, %s' % (white_p, black_p))
                channel_id = slackapi.create_group_dm('%s, %s' % (white_p, black_p))
                time.sleep(1)
                slackapi.close_conversation(channel_id)
    except IndexError:
        pass
示例#6
0
def slack_account_linked(lichess_username, slack_user_id, **kwargs):
    slackapi.send_message(
        slack_user_id,
        'Your Slack account has been successfully linked to the lichess account `%s`.'
        % lichess_username)