pyslackers/sirbot-slack

Boilerplate configuration gets error.

alairock opened this issue · 4 comments

K, Not sure this is a bug, or just bad config on my part. Here is my config:
https://gist.github.com/alairock/13f50bc8987ae0d8132df2bd44d927fc

Created a new folder with just those two files. I created a virtualenv and pip install -r requirements.txt then ran sirbot -c sirbot.yaml

That's it. I added the slack env variables, and I got this error:

2017-06-04 19:46:19,899 - sirbot.core.core - INFO - Initializing Sir-bot-a-lot
2017-06-04 19:46:19,899 - sirbot.core.core - DEBUG - Importing plugins
2017-06-04 19:46:19,910 - sirbot.core.core - DEBUG - Initializing plugins
2017-06-04 19:46:19,910 - sirbot.slack.core - DEBUG - Initializing slack plugin
2017-06-04 19:46:19,911 - sirbot.core.core - INFO - Sir-bot-a-lot Initialized
2017-06-04 19:46:19,911 - sirbot.core.core - DEBUG - Configuring plugins
2017-06-04 19:46:19,913 - sirbot.slack.core - DEBUG - Configuring slack plugin
2017-06-04 19:46:19,915 - sirbot.slack.core - DEBUG - Initializing plugins of slack plugin
2017-06-04 19:46:19,916 - sirbot.slack.core - DEBUG - Adding actions endpoint: /buttons
2017-06-04 19:46:19,916 - sirbot.slack.core - DEBUG - Adding commands endpoint: /commands
2017-06-04 19:46:19,916 - sirbot.core.core - DEBUG - Plugins configured
2017-06-04 19:46:19,917 - sirbot.core.core - INFO - Starting Sir-bot-a-lot ...
2017-06-04 19:46:19,917 - sirbot.core.core - DEBUG - Starting plugins
2017-06-04 19:46:19,917 - sirbot.core.core - DEBUG - Starting plugins sqlite
2017-06-04 19:46:20,119 - sirbot.core.core - DEBUG - Plugins sqlite started
2017-06-04 19:46:20,119 - sirbot.core.core - DEBUG - Starting plugins slack
2017-06-04 19:46:20,120 - sirbot.slack.core - DEBUG - Starting slack plugin
Traceback (most recent call last):
  File "/Users/alairock/dev/patpbot/venv/bin/sirbot", line 11, in <module>
    load_entry_point('sirbot==0.0.1', 'console_scripts', 'sirbot')()
  File "/Users/alairock/dev/patpbot/venv/lib/python3.6/site-packages/sirbot/core/cli.py", line 70, in main
    start(config, port=port)
  File "/Users/alairock/dev/patpbot/venv/lib/python3.6/site-packages/sirbot/core/cli.py", line 79, in start
    bot.run(port=int(port))
  File "/Users/alairock/dev/patpbot/venv/lib/python3.6/site-packages/sirbot/core/core.py", line 217, in run
    web.run_app(self._app, host=host, port=port)  # pragma: no cover
  File "/Users/alairock/dev/patpbot/venv/lib/python3.6/site-packages/aiohttp/web.py", line 321, in run_app
    loop.run_until_complete(app.startup())
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/base_events.py", line 466, in run_until_complete
    return future.result()
  File "/Users/alairock/dev/patpbot/venv/lib/python3.6/site-packages/aiohttp/web.py", line 242, in startup
    yield from self.on_startup.send(self)
  File "/Users/alairock/dev/patpbot/venv/lib/python3.6/site-packages/aiohttp/signals.py", line 50, in send
    yield from self._send(*args, **kwargs)
  File "/Users/alairock/dev/patpbot/venv/lib/python3.6/site-packages/aiohttp/signals.py", line 16, in _send
    yield from res
  File "/Users/alairock/dev/patpbot/venv/lib/python3.6/site-packages/sirbot/core/core.py", line 78, in _start
    await self._start_plugins()
  File "/Users/alairock/dev/patpbot/venv/lib/python3.6/site-packages/sirbot/core/core.py", line 164, in _start_plugins
    task.result()
  File "/Users/alairock/dev/patpbot/venv/lib/python3.6/site-packages/sirbot/slack/core.py", line 256, in start
    self._dispatcher['message'].bot = self.bot
KeyError: 'message'
Exception ignored in: <bound method SQLiteFacade.__del__ of <sirbot.plugins.sqlite.SQLiteFacade object at 0x103597358>>
Traceback (most recent call last):
  File "/Users/alairock/dev/patpbot/venv/lib/python3.6/site-packages/sirbot/plugins/sqlite.py", line 148, in __del__
sqlite3.ProgrammingError: Cannot operate on a closed database.

@ovv I think we should provide a sensible default here, meaning that a user could fire up sirbot without doing anything. Thoughts?

Fixed it on my end. Looks like this error is happening because some environment variables were not set. Probably could just update this section to have better messaging / error handling.

ovv commented

I think I figured out what happened.

It depends if you use the rtm api (websocket) or the webhook api.

You can also use the webhook APi and for that you need to activate the events subscription for your slack app and add an endpoint for events

Or use the rtm where you need to have the SIRBOT_SLACK_BOT_TOKEN environment variable to be your bot token (the one starting by xoxb for that you need to add a bot to the slack app) and add rtm: true in the slack part of your config file (just added that today it was just looking for the env var before)

ovv commented

Feel free to reopen if you still have errors :)