Esempio n. 1
0
 def __init__(self):
     self._client = SlackClient(settings.API_TOKEN,
                                bot_icon=settings.BOT_ICON if hasattr(
                                    settings, 'BOT_ICON') else None,
                                bot_emoji=settings.BOT_EMOJI if hasattr(
                                    settings, 'BOT_EMOJI') else None)
     self._plugins = PluginsManager()
     self._dispatcher = MessageDispatcher(self._client, self._plugins)
Esempio n. 2
0
 def __init__(self, api_token=None):
     if api_token is None:
         api_token = settings.API_TOKEN
     self._client = SlackClient(api_token,
                                bot_icon=settings.BOT_ICON if hasattr(
                                    settings, 'BOT_ICON') else None,
                                bot_emoji=settings.BOT_EMOJI if hasattr(
                                    settings, 'BOT_EMOJI') else None)
     self._plugins = PluginsManager()
     self._dispatcher = MessageDispatcher(self._client, self._plugins)
     self._stop = threading.Event()
Esempio n. 3
0
 def __init__(self):
     self._client = SlackClient(
         CONFIG.slack_api_token,
         timeout=settings.TIMEOUT if hasattr(settings, 'TIMEOUT') else None,
         bot_icon=settings.BOT_ICON
         if hasattr(settings, 'BOT_ICON') else None,
         bot_emoji=settings.BOT_EMOJI
         if hasattr(settings, 'BOT_EMOJI') else None)
     self._plugins = PluginsManager()
     self._dispatcher = MessageDispatcher(self._client, self._plugins,
                                          settings.ERRORS_TO)
Esempio n. 4
0
def handle_message(text, expect_reaction=True):
    client = SlackClient("api_token", connect=False)
    plugins = PluginsManager()
    dispatcher = MessageDispatcher(client, plugins, None)
    msg = [
        "respond_to",
        {"text": text, "channel": "channel", "ts": str(time.mktime(T0.timetuple()))},
    ]

    if expect_reaction:
        with assert_slack_client_reacts_to_message():
            dispatcher.dispatch_msg(msg)
    else:
        with assert_slack_client_doesnt_react_to_message():
            dispatcher.dispatch_msg(msg)
Esempio n. 5
0
def handle_message(text, *, category="respond_to", expect_reaction=True):
    client = SlackClient("api_token", connect=False)
    plugins = PluginsManager()
    plugins.init_plugins()
    dispatcher = MessageDispatcher(client, plugins, None)
    msg = [
        category,
        {
            "text": text,
            "channel": "channel",
            "ts": TS
        },
    ]

    if expect_reaction:
        with assert_slack_client_reacts_to_message():
            dispatcher.dispatch_msg(msg)
    else:
        with assert_slack_client_doesnt_react_to_message():
            dispatcher.dispatch_msg(msg)
Esempio n. 6
0
 def __init__(self):
     self._client = SlackClient(settings.API_TOKEN)
     self._plugins = PluginsManager()
     self._dispatcher = MessageDispatcher(self._client, self._plugins)