Command syntax, esp. optional arguments #51
Labels
C-enhancement
Category: Tickets requesting changes other than bug-fixes
E-medium
Difficulty: Medium
P-high
Importance: High
Milestone
In #50 (comment), @ctm wrote—
Sorry about this! The API for defining commands, especially around taking arguments, is one of the older and messier ones, if not the messiest, and is so poorly documented that I can't even find any generated list of items for it in the documentation. (I suppose its "documentation" consists of the examples provided by the bot modules in
src/modules
.) Now that I have users other than myself, I realize that it well may be overly restrictive that the "commands" must take YAML objects as arguments, if they take any argument.The way to have an optional argument like this with a command per se would be to make the argument a YAML mapping (what
yaml-rust
calls aHash
) and have the optional arguments be optional fields of that mapping, leading to an interface such as—However, it currently should be possible to get the interface you intended by using not commands per se but rather the similar feature currently named "triggers", which allow matching incoming messages against an arbitrary regex and running a given function for matching messages, with the regex's captures passed to the function. For your case, I imagine the regex would be
^bet(?: ([0-9]+|pot|half))?$
.These APIs deserve to be overhauled, and I imagine I might unify them into a single, more flexible API. Whether or not I do, I intend to rename triggers to something else, because, if eventually I write documentation for them, I otherwise would be talking about triggers being triggered and what triggers triggers, which could get confusing.
The text was updated successfully, but these errors were encountered: