pub struct ValidContext<'a, 'ph: 'a> { /* private fields */ }
Expand description

A PluginHandle operating on a valid context.

This mechanism attempts to reduce the likelihood of segfaults in hexchat code.

See also PluginHandle::ensure_valid_context.

Implementations

Finds an open context for the given servname and channel.

Compares two nicks based on the server’s case mapping.

Executes a command.

Examples
use hexchat_unsafe_plugin::{ValidContext};

fn join(context: ValidContext<'_, '_>, channel: &str) {
    context.command(&format!("join {}", channel));
}

Prints an event message, and returns a success status (whether or not the event exists).

Examples
use hexchat_unsafe_plugin::{ValidContext};

fn emit_channel_message(context: ValidContext<'_, '_>, nick: &str, msg: &str) {
    context.emit_print("Channel Message", [nick, msg]);
}

Prints an event message, and returns a success status (whether or not the event exists).

Also allows setting event attributes.

Examples
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]);
}

Returns the current context.

See PluginHandle::get_context.

Sets the current context.

Returns true if the context is valid, false otherwise.

See PluginHandle::set_context.

Prints to the hexchat buffer.

See PluginHandle::print.

Prints to the hexchat buffer.

Glue for usage of the write! macro with hexchat.

See PluginHandle::write_fmt.

Panics

This panics if any broken formatting trait implementations are used in the format arguments. See also format!.

Sets a command hook.

See PluginHandle::hook_command.

Sets a server hook.

See PluginHandle::hook_server.

Sets a server hook with attributes.

See PluginHandle::hook_server_attrs.

Sets a print hook.

See PluginHandle::hook_print.

Sets a print hook with attributes.

See PluginHandle::hook_print_attrs.

Sets a timer hook.

See PluginHandle::hook_timer.

Returns context and client information.

See PluginHandle::get_info.

Returns the plugin directory.

See PluginHandle::get_libdirfs.

Strips attributes from text.

See PluginHandle::strip.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.