RITlug / teleirc

Go implementation of a Telegram <=> IRC bridge for use with any IRC channel and Telegram group
https://docs.teleirc.com/
GNU General Public License v3.0
141 stars 45 forks source link

Telegram users should be able to run bot commands on IRC #330

Open Tjzabel opened 4 years ago

Tjzabel commented 4 years ago

Summary

If a bot exists on IRC that listens for generic commands (!command) from users, a Telegram user should also be able to run these commands across the bridge.

Background

Is your feature request related to a problem? Please describe:

IRC bots are unable to see commands sent from Telegram. Currently, messages are sent over the bridge like this:

<user> !foo bar

When a TG user wishes to run a command on IRC, the bridge should not send over the Telegram username, and should show:

!foo bar

Details

Parse the first character of each Telegram message for a known command flag such as !. Then, if the first character matches the known command flag, the bridge should only send over the message without the user's TG username, so any IRC bot can properly run the given command. This will allow Telegram users to participate more seamlessly with IRC.

Outcome

Telegram users are able to more seamlessly contribute to IRC by being able to use IRC bot commands specific channels may have.

xforever1313 commented 4 years ago

This is a tough one....

For some IRC Bots, the ! command is easy, it just outputs a canned message (e.g. !help).

However, some IRC Bots have smarts. It actively looks at the username of who sent the message and performs actions based on who sent it. So if using a quote bot, for example, an someone on Telegram sends !quote add something, the user that adds the quote won't be the Telegram user, but Teleirc.

There are also some bots that are even smarter; they are aware bridges are a thing and can parse messages from bridged users and figure out who sent the message. So <teleirc> <TelegramUser> !quote add something the bot would notice "teleirc" sent the message, and it is configured to be a bridge bot. It then parses the message and sees "TelegramUser" sent "!quote add something". It would add the quote as TelegramUser, not teleirc. If teleirc sent !quote add, the IRC Bot would have no idea who on the other side of the bridge sent the message and attribute the quote to teleirc.

There is no way to change who is sending a username over IRC (with good reason), PRIVMSG takes in two parameters: the target and the message.

So with all of that... there is a compromise that could be done. Not send 1 message during a command, but 2. The first one could be "TelegramUser sent command: !quote add something" and then the next message would be "!quote add something". This buys us two things:

Perhaps we can even make this configurable (e.g. have teleirc send the first message, second message, or both).

xforever1313 commented 4 years ago

We would also need a setting that specifies which message prefixes are commands. Some bots are "!", some are "#", others are "@". Heck, some are all three 🤣