archangelic / pinhook

the pluggable python framework for IRC bots and Twitch bots
https://archangelic.github.io/pinhook/
MIT License
31 stars 4 forks source link

Abstraction for multiple backends #31

Open Lucidiot opened 6 years ago

Lucidiot commented 6 years ago

Instead of having IRCBot and TwitchBot classes, have a single Bot class that takes a backend as a parameter. That could allow to split pinhook into multiple packages, like pinhook-irc, pinhook-twitch, etc.

The backend could be a class or a string pointing to a class (to help with import troubles). A backend would be initialized with the Bot instance as a parameter, and started as soon as the bot is ready to accept events; then, the backend deals with everything and fires on_* events on the bot.

It could be possible to use Abstract Base Classes to enforce implementing specific methods if needed.

Messages would probably need to become even more abstract (or have more possibilities than just action and message) to provide support for backends from different paradigms (like toots or facebook privacy settings).

archangelic commented 6 years ago

Definitely gonna brainstorm about this. This is really good.

ixxie commented 5 years ago

This is a great idea but I wonder if splitting the package afterwards is wise; there are interesting use-cases for the same bot simultaneously plugging into multiple back-ends, and this may be trickier to achieve when the packaging is split.

ixxie commented 5 years ago

This would also solve the problem of not being able to connect to multiple networks at once.

archangelic commented 5 years ago

@ixxie Opened #64 to discuss this further.