MCPcopy Create free account
hub / github.com/bnjbvr/trinity / TrinityCommand

Interface TrinityCommand

modules/libcommand/src/lib.rs:124–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122}
123
124pub trait TrinityCommand {
125 /// Code that will be called once during initialization of the command. This is a good time to
126 /// retrieve settings from the database and cache them locally, if needs be, or run any
127 /// initialization code that shouldn't run on every message later.
128 fn init(_config: HashMap<String, String>) {}
129
130 /// Handle a message received in a room where the bot is present.
131 ///
132 /// The message isn't identified as a request for help or an admin command. Those are handled
133 /// respectively by `on_help` and `on_admin`.
134 ///
135 /// This should always be implemented, otherwise the command doesn't do anything.
136 fn on_msg(client: &mut CommandClient, content: &str);
137
138 /// Respond to a help request, for this specific command.
139 ///
140 /// If the topic is not set, then this should return a general description of the command, with
141 /// hints to the possible topics. If the topic is set, then this function should document
142 /// something related to the specific topic.
143 ///
144 /// This should always be implemented, at least to document what's the command's purpose.
145 fn on_help(_topic: Option<&str>) -> String;
146
147 /// Handle a message received by an admin, prefixed with the `!admin` subject.
148 ///
149 /// By default this does nothing, as admin commands are facultative.
150 fn on_admin(_client: &mut CommandClient, _command: &str) {}
151}

Callers

nothing calls this directly

Implementers 9

lib.rsmodules/linkify/src/lib.rs
lib.rsmodules/uuid/src/lib.rs
lib.rsmodules/silverbullet/src/lib.rs
lib.rsmodules/pun/src/lib.rs
lib.rsmodules/horsejs/src/lib.rs
lib.rsmodules/openai/src/lib.rs
lib.rsmodules/memos/src/lib.rs
lib.rsmodules/secret/src/lib.rs
lib.rsmodules/mastodon/src/lib.rs

Calls

no outgoing calls

Tested by

no test coverage detected