Exemplo n.º 1
0
    return None, None, None, None


if __name__ == "__main__":
    text_parser = EmojiParser(slack_client)

    command_handler = CommandHandler(slack_client)
    READ_WEBSOCKET_DELAY = 0.5  # 1 second delay between reading from data stream
    if slack_client.rtm_connect():
        print("ReactionAdder connected and running!")
        while True:
            output_list = slack_client.rtm_read()
            msg_type = determine_message_type(output_list)
            if msg_type == 'command':
                __message, channel = command_handler.get_command_info(
                    output_list)
                command_handler.parse_command(__message.split(), channel)
            elif msg_type == 'nlp':
                print("in nlp branch")
                emoji_list, channel, timestamp, user = text_parser.parse_message(
                    output_list)
                print emoji_list
                for emoji_text in emoji_list:
                    if emoji_text is not None:
                        slack_client.api_call("reactions.add",
                                              channel=channel,
                                              name=emoji_text,
                                              timestamp=timestamp,
                                              as_user=True)
            time.sleep(READ_WEBSOCKET_DELAY)
    else: