Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Provide a way to change command prefix #42

Open
pasali opened this issue Feb 17, 2017 · 10 comments
Open

Provide a way to change command prefix #42

pasali opened this issue Feb 17, 2017 · 10 comments

Comments

@pasali
Copy link
Contributor

pasali commented Feb 17, 2017

It will be useful to give ability to override bots command prefix. I want to use prefixs other than "!" character or maybe bots name while i am typing commands.

@doenietzomoeilijk
Copy link
Contributor

Actually that would slightly overlap with #6, depending on what you had in mind.

I was considering adding an option for the bot to respond to its name (possibly creating another command type for that, next to the regular, passive and periodic ones), so that'd solve that part, and #6 speaks of using a slash rather than an exclamation mark, so a generic way of enabling changing the prefix would cover both your use cases.

@pasali
Copy link
Contributor Author

pasali commented Feb 22, 2017

Hi, thanks for reply. I was wondering how could i make bot to respond to its name like you said above, then i came up with the idea of making bot's name command prefix. İf you mention someone on Slack, user's name will look like <@XXXXXXX> so i thought i could use it for command prefix to achieve my goal. If this isn't going to work, totally +1 for the new command type :)

@doenietzomoeilijk
Copy link
Contributor

Having it respond to its own name like that should be possible using a passive command; just have it match on "(?i)^@yourbotname\\b".

@pasali
Copy link
Contributor Author

pasali commented Feb 28, 2017

@doenietzomoeilijk i tried what you proposed. But passive commands doesnt have arguments like regular commands. I do not want to lose cmd args. Basicly what i want is that a regular command which i can trigger by bots name.

@doenietzomoeilijk
Copy link
Contributor

In that case it'd either have to be a separate command type, or a way to really change the prefix. I'd lean towards the former, since matching on bot name could be a bit more generic (both with and without leading @, both with and without a tailing : or ,), so more like a job for a regex, while I'd view the command prefix as a single character thing.

@fabioxgn what's your thoughts on this?

@fabioxgn
Copy link
Member

@doenietzomoeilijk I think that the best way is to handle the prefix on the bot itself instead of creating a separate command type.

When I first wrote the bot I had that in mind, that's why the prefix is a constant:

bot/bot.go

Line 15 in e614e12

CmdPrefix = "!"

I think that changing this constant to a function which returns the bot's actual nick would be enough to make it work, than each protocol just have to implement this function.

@doenietzomoeilijk
Copy link
Contributor

@fabioxgn Fair enough, but does that leave us with a way of setting the prefix per protocol? I want a / on Telegram, but not on IRC where I can't use it, for example. And on Slack the bot name should probably be prefixed with a @, but not on other protocols. And so on. So maybe not a function that you'd have to implement per protocol (that'd be duplicate code indeed), but at least something that can tell protocols apart.

@fabioxgn
Copy link
Member

fabioxgn commented Mar 1, 2017

@doenietzomoeilijk each protocol by default could respond by name and then allow a custom prefix (as we already do), now the prefix is ! by default, so if you are using the help command you need to type !help.

Maybe on slack, by default the bot could respond to: @bot help and also !help, on IRC it could respond to bot help and on Telegram @bot help just the same as slack.

@pasali
Copy link
Contributor Author

pasali commented Mar 1, 2017

+1 for @fabioxgn's suggestion. In spite of being a newbie go programmer, i would like to help you out with this. So let me know if you dont have enough time to implement this feature.

@toolateforteddy
Copy link
Contributor

The easy way to make this configurable would be to change the const to var then you could set the prefix from the outside for configuration.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants