Lullabot / lubot

1 stars 0 forks source link

Refactor code so connections to IRC/Slack operate as plugins #59

Closed eojthebrave closed 1 year ago

eojthebrave commented 8 years ago

Right now the slackbot branch adds integration with Slack. But it's a total hack. There's no way to disable IRC, or Slack for that matter. So the bot will always connect to both. And, all the scripts that have been converted contain piles of duplicate code in order to work with both IRC and Slack.

Factoids for example has bot.ws.on() and bot.irc.addListener() which are almost identical. The only real differences are in the initial addition of an event listener, and the code used to broadcast a message. bot.irc.say() vs. bot.slack.api('chat.postMessage').

At this point it seems like it would be a good idea to either, remove IRC support completely. Or, refactor the codebase so that it uses plugins for different connection types, and proxies like bot.say(), and bot.subscribe() that will delegate to the plugins appropriately. And then write plugins for both IRC and Slack.

At the moment I'm kind of inclined to just remove IRC support. But, I'm open to being convinced otherwise.

Discuss.

willwh commented 8 years ago

This has come up before. I'm inclined to say, IRC is dead, long live IRC....

With tools like Twitter, Slack & Gitter - I don't see the point in continuing to support IRC.

I think https://gitter.im is great and has a good chance of supplanting IRC as a FOSS real time chatter medium. I guess we'll see :)

willwh commented 8 years ago

I guess I'm saying, I'd rather write Slack and Gitter plugins, and if anyone is about to loose it, IRC too :)

q0rban commented 8 years ago

Since this is @justafish's creation, and since she doesn't use Slack, I'm guessing she is not going to want to lose IRC support.

q0rban commented 8 years ago

Another crazy idea. How hard would it be to use Botkit to do what we need, instead of trying to make lubot both slack and IRC compatible? Not sure that's quicker, but maybe trivial, depending on how Botkit is written.

eojthebrave commented 8 years ago

It looks like Botkit currently only supports Slack. So I don't think it would provide any real benefit in our attempt to support both Slack and IRC. However, if we decided we don't want to support IRC any longer I would be 100% in favor of using Botkit as the base for our bot. It's far more advanced than our current implementation of the Slack API.

From the looks of it we could use Botkit, and rewrite our custom bot commands pretty easily. Botkit supports permanent storage, though only via JSON formatted files and not via a DB directly. (ours uses mongo for things like factoids currently). It looks like these are pluggable, and as such we could either write a mongo plugin, or better yet, probably find one that someone else is already using.

Additionally, even if we want to support both Slack and IRC we might want to consider using Botkit as the Slack API implementation, and then still write our own wrapper/plugin system.

willwh commented 8 years ago

I don't know that we need to continue supporting IRC?

Slack supports an IRC interface for people that want to connect via that protocol, and the bot can still do everything it needs to....

@justafish what say you?

q0rban commented 8 years ago

What I was thinking is that we use Botkit to create a Slack bot, and use lubot for when we need an IRC bot.