示例#1
0
class Bot(object):
    def __init__(self):
        if settings.MATTERMOST_API_VERSION == 4:
            self._client = MattermostClientv4(settings.BOT_URL,
                                              settings.BOT_TEAM,
                                              settings.BOT_LOGIN,
                                              settings.BOT_PASSWORD,
                                              settings.SSL_VERIFY)
        else:
            self._client = MattermostClient(settings.BOT_URL,
                                            settings.BOT_TEAM,
                                            settings.BOT_LOGIN,
                                            settings.BOT_PASSWORD,
                                            settings.SSL_VERIFY)
        logger.info('connected to mattermost')
        self._plugins = PluginsManager()
        self._dispatcher = MessageDispatcher(self._client, self._plugins)

    def run(self):
        self._plugins.init_plugins()
        self._dispatcher.start()
        _thread.start_new_thread(self._keep_active, tuple())
        self._dispatcher.loop()

    def _keep_active(self):
        logger.info('keep active thread started')
        while True:
            time.sleep(60)
            self._client.ping()
示例#2
0
 def __init__(self):
     self._client = MattermostClient(settings.BOT_URL, settings.BOT_TEAM,
                                     settings.BOT_LOGIN,
                                     settings.BOT_PASSWORD,
                                     settings.SSL_VERIFY)
     logger.info('connected to mattermost')
     self._plugins = PluginsManager()
     self._dispatcher = MessageDispatcher(self._client, self._plugins)
示例#3
0
 def __init__(self):
     self._client = MattermostClient(
         settings.BOT_URL, settings.BOT_TEAM,
         settings.BOT_LOGIN, settings.BOT_PASSWORD,
     )
     logger.info('connected to mattermost')
     self._plugins = PluginsManager()
     self._dispatcher = MessageDispatcher(self._client, self._plugins)
示例#4
0
 def __init__(self):
     self._client = MattermostClient(local_settings.BOT_URL,
                                     local_settings.BOT_TEAM,
                                     local_settings.BOT_LOGIN,
                                     local_settings.BOT_PASSWORD,
                                     local_settings.SSL_VERIFY)
     self._plugins = PluginsManager(local_settings.PLUGINS)
     self._dispatcher = MessageDispatcher(self._client, self._plugins)
示例#5
0
 def __init__(self):
     self._client = MattermostClientv4(bot_settings.BOT_URL,
                                       bot_settings.BOT_TEAM,
                                       bot_settings.BOT_LOGIN,
                                       bot_settings.BOT_PASSWORD,
                                       bot_settings.SSL_VERIFY)
     self._plugins = PluginsManager()
     self._plugins.init_plugins()
     self._dispatcher = MessageDispatcher(self._client, self._plugins)
示例#6
0
class Bot(object):
    def __init__(self):
        self._client = MattermostClient(
            settings.BOT_URL, settings.BOT_TEAM,
            settings.BOT_LOGIN, settings.BOT_PASSWORD,
        )
        logger.info('connected to mattermost')
        self._plugins = PluginsManager()
        self._dispatcher = MessageDispatcher(self._client, self._plugins)

    def run(self):
        self._plugins.init_plugins()
        self._dispatcher.start()
        _thread.start_new_thread(self._keep_active, tuple())
        self._dispatcher.loop()

    def _keep_active(self):
        logger.info('keep active thread started')
        while True:
            time.sleep(60)
            self._client.ping()