Cardinal icon indicating copy to clipboard operation
Cardinal copied to clipboard

Add config for different command trigger

Open vwbusguy opened this issue 4 years ago • 2 comments

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.

vwbusguy avatar May 24 '21 23:05 vwbusguy

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 avatar May 25 '21 15:05 johnmaguire

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.)

johnmaguire avatar May 26 '21 22:05 johnmaguire