johnmaguire / Cardinal

A Python IRC bot, designed to make adding functionality quick and simple. (est. 2013)
MIT License
100 stars 38 forks source link

Add config for different command trigger #189

Open vwbusguy opened 3 years ago

vwbusguy commented 3 years ago

The current code hard codes commands to start with '.' (Ref. https://github.com/JohnMaguire/Cardinal/blob/master/cardinal/plugins.py#L30). This is a problem for joining it to a room with other historical bots that are already listening on . and may have overlapping command keys. Looking at this, we should be able to add a char config option and cast it to the regex (replace \. with %c and make "." the default config). However, it appears that the regex is currently defined outside of the context of an available config., but setting it during __init__() instead should suffice without having to update https://github.com/JohnMaguire/Cardinal/blob/master/cardinal/plugins.py#L688, too.

johnmaguire commented 3 years ago

Wondered when this request would come in. Seems like an easy enough change. If you want to put up a PR, I'd likely merge it. Otherwise, I'll look into it hopefully soon.

One thing to keep in mind is that plugins can also define regex-based commands, and so there may be some cases where this won't work perfectly.

For example the ticker plugin which uses ! instead of . because Cardinal replaced functionality of a since-removed bot in a channel that used !. I'd like to move this one back into a regular @command, but there's some additional work to support relayed bots. Currently ticker and crypto implement relayed bot support themselves, but this should probably move into the core.

I am pretty sure ticker is the only plugin today that doesn't use COMMAND_REGEX for its commands.

johnmaguire commented 3 years ago

Hm, I recall the issue with implementing this now - currently help for commands is implemented via raw text (both passed in the @help() decorator as well as common responses for invalid command syntax.)