Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

Command prefixes: by mention and by configuration #96

Open
khionu opened this issue May 14, 2020 · 3 comments
Open

Command prefixes: by mention and by configuration #96

khionu opened this issue May 14, 2020 · 3 comments

Comments

@khionu
Copy link

khionu commented May 14, 2020

When you don't know a bot's prefix, it should be able to respond to @mention help. While I found the way to set the prefix, it doesn't make setting it to be a mention easy.

Additionally, communities often need to change prefixes to not conflict with the prefixes of other bots.

@curz46
Copy link
Contributor

curz46 commented May 15, 2020

IIRC there is already a set_prefix function, so in theory you could achieve a configurable prefix.

edit: here

I think #97 is a good idea and should achieve this in isolation. A predefined predicate could be in place that uses the bot's id like <@id>\s+ as the prefix.

edit 2: Looking into it more, of course, set_prefix is a macro and I assume it would fail if it was executed at runtime or with some configured variable. Cogs does its job, but I have to say it might be the most evil Elixir module written with respect to metaprogramming abuse... Upon further consideration, I don't know if I support adding more features to Cogs. I can respect its value as a simple command handler, but more advanced features like predicates and mention-triggering would be better in a new command api. Perhaps, if a more versatile command api was created, Cogs could serve as a thin wrapper for backwards compatibility?

@cronokirby
Copy link
Owner

Yeah IMO the way I'd rewrite it would be to have everything be declarative, and then have an explicit function that passes the structure you've built up to the main GenServers

@khionu
Copy link
Author

khionu commented May 15, 2020

Predicates could be woven in between parsing, could even combine them. Covering all predicate and configurable parsing (qualifying custom prefixes as such) use cases would mean being able to insert checks and immediately before and after parsing a given segment of a message.

Once I'm done getting my current bot working, I might use this as an opportunity to learn Elixir metaprogramming. I've written a command parser before, should be fun to do so with Elixir's pattern matching.

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

No branches or pull requests

3 participants