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()
class MMBot(Bot): 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) def _keep_active(self): while True: time.sleep(60) self._client.ping() self._client.online()
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()