butterfield icon indicating copy to clipboard operation
butterfield copied to clipboard

Posts can't be done outside of a handler?

Open ZacSweers opened this issue 9 years ago • 3 comments

Nothing happens with the following code snippet:

from butterfield import Bot

bot = Bot('not-a-real-key')
bot.post("some-channel-id", 'Hi, channel!')

And if I try to "run" the bot first, it blocks on the run call:

import butterfield
from butterfield import Bot

bot = Bot('not-a-real-key')
butterfield.run(bot) # Never gets past here
bot.post("some-channel-id", 'Hi, channel!')

Posts only work from a handler, but that seems rather limiting. Am I missing something?

ZacSweers avatar Jun 08 '15 03:06 ZacSweers

I suppose a hacky way around it would be to just call bot.slack.**, but I feel like there should be a more API for exposing this if so

ZacSweers avatar Jun 08 '15 03:06 ZacSweers

@hzsweers I'm going to have to take a closer look at this tomorrow. Butterfield is still very much under development so the README may not completely reflect the current state of things. We have a branch that is about to be merged that changes a lot of core stuff and removes bot.slack, so that's probably not a viable workaround.

We use bot.post with the Sunlight bot, but only within handlers. I'll have to make sure it's still possible to use that method elsewhere.

jcarbaugh avatar Jun 08 '15 03:06 jcarbaugh

Good to know, thanks for looking into it! I probably misinterpreted the README, and was under the impression it was implying you could call post without run

ZacSweers avatar Jun 08 '15 03:06 ZacSweers