Beispiel #1
0
def main():

    READ_WEBSOCKET_DELAY = 1
    slack_api = slack_utility.connect()
    if slack_api.rtm_connect():
        print('SLACK_BOT connected and running')
        while True:
            command, channel = slack_utility.parse_slack_response(
                slack_api.rtm_read())
            if command and channel:
                handle_command(slack_api, command, channel)
            time.sleep(READ_WEBSOCKET_DELAY)
    else:
        print('Connection failed. Invalid Slack token or bot ID?')
Beispiel #2
0
def main():
    """
    Initiate the bot and call appropriate handler functions
    """
    READ_WEBSOCKET_DELAY = 1  # 1 second delay between reading from firehose
    slack_api = slack_utility.connect()
    if slack_api.rtm_connect():
        print('SLACK_BOT connected and running')
        while True:
            command, channel = slack_utility.parse_slack_response('OK')
            if command and channel:
                handle_command(slack_api, command, channel)
            time.sleep(READ_WEBSOCKET_DELAY)
    else:
        print('Connection failed. Invalid Slack token or bot ID?')