meleca / plugins

Plugins for go-chat-bot
MIT License
0 stars 0 forks source link

URL shortener as passive command #1

Open bmeneg opened 7 years ago

bmeneg commented 7 years ago

Would be a great feature a "URL shortener" passive command:

IF url_sent_to_channel:
    url = url_sent
    IF len(url) > ??:
        url = some_url_shortner(url)

What I meant by "great feature" is for those who uses a non-X IRC clients, and usually the terminal breaks the URL in two+ different lines, forcing the user copy-paste each line.

julianolf commented 7 years ago

Ok, here we go.

I think that the plugin should work this way:

  1. The original url should be sent directly to the bot as a private message and then the short version would be sent to the desired channels.
  2. Every time the bot recognises a url pattern in the channel it would mention the sender of that url in a message telling about the command for shrink urls.
  3. All urls recognized by the bot should be recorded with the following information: channel, date and time, sender, short version of the url and page title.
  4. A command, that accept a few parameters for filtering, should return those saved urls. Filters like channel, sender, date and title keywords must be enough.

That said, I think it would be better to split these functionalities into two plugins, one for shrink urls and another to persist the history of urls, but both should be enable to run independently of each other.

PS.: Take care about support for all protocols.

bmeneg commented 7 years ago

@julianolf yeah, crystal clear. As we previously talked about I'll make the changes following the steps you mentioned. But about other protocols, I didn't dive in their internals to understand how they work, but would this feature make sense on Slack and Telegram? For Telegram I know there are those who access it through IRC, but send the URL to the bot and then it send to the "group" .. I don't know.. I'm just thinking out loud here. What do you guys think?

Btw, for now I'll dev the plugin using sqlite. And I think till this weekend I'll have something ready. Thanks!

bviecelli commented 7 years ago

@bmeneguele Is there a way to configure what plugins will run for different types of services, right? This can be enabled by default only for IRC instances.

bmeneg commented 7 years ago

@bviecelli well,I didn't know exactly, but I took a look and it seems there isn't, any new plugin is available to all protocols. I'll see what I can do to support this "private messages"-only commands on all protocols, regardless their usefulness on that platform. Once done we can think in create a white/blacklist mechanism of commands vs protocols, if really necessary.

julianolf commented 7 years ago

It's not possible to filter protocols indeed. The point is, the bot should abstract that, so the same instance can run over all three protocols.

I know that it would be kind of weird to receive messages from the bot every time you share a url on Telegram from your cellphone, so to avoid this we could just ommit the message that tells about the command.

What do you think?

By doing that we would still be able to use the shrink command even on Telegram, I think it is useful and there are these kind of actions in private conversations with bots even on Telegram.

Finally, have access to a history of urls is definatly a good feature.

bmeneg commented 7 years ago

@julianolf yeah, sounds good to me.