Skip to content

Conversation

@seLain
Copy link

@seLain seLain commented Sep 15, 2017

Local settings can be specified when creating a new bot class.

Usage example (appended to README,md as well) :

Add Local Settings and Plugins

If you would like to do settings and import local plugins without alter mattermost_bot.settings in Python site-packages, you can simply create a local_settings.py in your developement dir, and a plugins directory.

The local_settings.py looks like this :

PLUGINS = [
    'plugins'
]

BOT_URL = 'http://mm.example.com/api/v3'
BOT_LOGIN = 'bot@example.com'
BOT_PASSWORD = None
BOT_TEAM = 'devops'
SSL_VERIFY = True

Then you can create your own Bot class and overwrite __init__() constructor :

from mattermost_bot.bot import Bot, PluginsManager
from mattermost_bot.mattermost import MattermostClient
from mattermost_bot.dispatcher import MessageDispatcher
import local_settings

class LocalBot(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)

if __name__ == "__main__":
    LocalBot().run()

local settings can be specified when creating a new bot class.
@seLain seLain closed this Jan 15, 2018
@seLain seLain deleted the enable_local_settings branch February 20, 2018 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant