joshuaskelly / twitch-observer

Turn Twitch chatter into Python events
MIT License
26 stars 6 forks source link

Add "event.reply" shortcut #69

Closed senpos closed 6 years ago

senpos commented 6 years ago

So, the point here is - since it is very common thing to send message to the channel from where the event came in, it is quite boring to use observer.send_message('my_text', event.channel) all the time.

It is convenient to have an opportunity to reply directly to the event's channel like:

@observer.on_event(ChatEventType.TWITCHCHATMESSAGE)
def message_handler(event):
    event.reply('my text')  # or event.reply_text(...)

I've seen this here.

It should be easy to implement, I think, but it requires passing Observer instance to the Event, so I am not sure about this now.

joshuaskelly commented 6 years ago

What does this solve that send_message does not?

@observer.on_event(ChatEventType.TWITCHCHATMESSAGE)
def message_handler(event):
    observer.send_message('my text', event.channel)

We should keep events as just data. I think we also should strive to keep our API as simple and concise as possible.

senpos commented 6 years ago

What does this solve that send_message does not?

It is a shortcut, that's all. Almost always you want to send message to the channel from event.

But I agree, it will make code-base a bit more complicated, so probably shouldn't be done, at least for now.