GinjaNinja32 / DisGoIRC

Discord<->IRC bridge bot, written in Go
GNU Affero General Public License v3.0
9 stars 3 forks source link

Add bot command handling #16

Closed Karunamon closed 5 years ago

Karunamon commented 5 years ago

Greetings, and thanks for your effort on this bot <3

This pull request adds command handling to the link bot.

In short, most IRC/Discord bots require that their trigger command (a string prefixed with ? or ! or something) is the first word of a message. Since the linkbot prefixes all messages with the name of the sender, I taught it to recognize command prefixes (with a list in the config file), and send any of those messages out without a username attached. For identity, it will say "Command send by (name)" before the non-username-prefixed message is transmitted on its own.

GinjaNinja32 commented 5 years ago

Thanks for the PR!

I've pushed another commit which slightly changes the behaviour; since you're unlikely to want a given prefix to forward as a command in both directions, the characters are specified separately now; for example, to forward commands starting with either ! or ? from Discord to IRC, and commands starting with = from IRC to Discord, you'd use:

{
    "irc": {
        ...
        "command_chars": "="
    },
    "discord": {
        ...
        "command_chars": "!?"
    },
    ...
}

Of course, if you do want a given prefix to forward both ways, simply add it to both lists :)