Macro catinator_macros::catinator [−][src]
catinator!() { /* proc-macro */ }
Expand description
Main entrypoint to the bot
#[tokio::main]
async fn main() {
catinator!(
hook("name", "A short description", PRIVMSG, function)
command("name", "A short description", function)
matcher("name", "A short description", r"^\[.*?\]$", function)
);
}
Functions
All the functions share a similar pattern, The first two arguments are the name and description respectively, the last argument is the function that gets executed.
The function must of of the following type:
fn hook(bot: &catinator::Bot, msg: irc::client::prelude::Message) -> anyhow::Result<()> {
Ok(())
}
async
You can run async functions natively by prepending your function hooks etc. with the async keyword.
async hook("name", "description", COMMAND, function)
hook
Hooks execute a function when a specific IRC Command is received, this allows for great flexibility in hooking into IRC for Authentication and the likes.
hook("name", "description", COMMAND, function)
PRIVMSG is an IRC Command like PRIVMSG or AUTHENTICATE Any of the enum variants of the irc crate should work.
command
A Command is command that can be executed in any PRIVMSG and is prefixed with the prefix configured in the config.toml file
command("name", "description", function)
Would be “:name
matcher
A matcher matches on a PRIVMSG using regex.
matcher("name", "description", r"regex", function)
The regex crate is used for matching, see it’s documentation for details.