diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs index a2b43b3..3211786 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1256,6 +1256,16 @@ impl<'a, 'ph: 'a> ValidContext<'a, 'ph> { } /// Executes a command. + /// + /// # Examples + /// + /// ```no_run + /// use hexchat_unsafe_plugin::{ValidContext}; + /// + /// fn join(context: ValidContext<'_, '_>, channel: &str) { + /// context.command(&format!("join {}", channel)); + /// } + /// ``` pub fn command(self, cmd: &str) { let ph = self.ph; // need to put this in a more permanent position than temporaries @@ -1265,6 +1275,18 @@ impl<'a, 'ph: 'a> ValidContext<'a, 'ph> { } } + /// Prints an event message, and returns a success status (whether or not + /// the event exists). + /// + /// # Examples + /// + /// ```no_run + /// use hexchat_unsafe_plugin::{ValidContext}; + /// + /// fn emit_channel_message(context: ValidContext<'_, '_>, nick: &str, msg: &str) { + /// context.emit_print("Channel Message", [nick, msg]); + /// } + /// ``` pub fn emit_print<'b, I: IntoIterator<Item=&'b str>>(self, event: &str, args: I) -> bool { let ph = self.ph; let event = CString::new(event).unwrap(); @@ -1291,6 +1313,23 @@ impl<'a, 'ph: 'a> ValidContext<'a, 'ph> { } } + /// Prints an event message, and returns a success status (whether or not + /// the event exists). + /// + /// Also allows setting event attributes. + /// + /// # Examples + /// + /// ```no_run + /// use std::time::SystemTime; + /// use hexchat_unsafe_plugin::{EventAttrs, ValidContext}; + /// + /// fn emit_channel_message_at(context: ValidContext<'_, '_>, time: Option<SystemTime>, nick: &str, msg: &str) { + /// let mut attrs = EventAttrs::new(); + /// attrs.server_time = time; + /// context.emit_print_attrs(attrs, "Channel Message", [nick, msg]); + /// } + /// ``` pub fn emit_print_attrs<'b, I: IntoIterator<Item=&'b str>>(self, attrs: EventAttrs, event: &str, args: I) -> bool { let ph = self.ph; let event = CString::new(event).unwrap(); |