[][src]Struct hexchat::Context

pub struct Context { /* fields omitted */ }

The main object for working with HexChat. Passed to you via callbacks.

Methods

impl Context[src]

pub fn get_away_reason(&self) -> Option<String>[src]

Gets the client's currently set away reason, or None if the client is not away.

pub fn is_away(&self) -> bool[src]

Gets whether or not the client is currently away.

pub fn get_channel_name(&self) -> String[src]

Gets the name of the current channel.

pub fn get_charset(&self) -> Charset[src]

Gets the current charset in use.

pub fn get_config_dir(&self) -> PathBuf[src]

Gets HexChat's configuration directory.

pub fn get_event_format_string(&self, event: PrintEvent) -> String[src]

Gets the format string that gets printed to the window when the specified PrintEvent is fired.

pub fn get_hostname(&self) -> String[src]

Gets the client's current hostname.

pub fn get_inputbox_contents(&self) -> String[src]

Gets the current contents of the input box.

pub fn get_hexchat_library_dir(&self) -> PathBuf[src]

Gets HexChat's library directory, also known as the plugin directory.

pub fn get_channel_mode_string(&self) -> Option<String>[src]

Gets the channel mode string for the current channel, or None if unknown.

pub fn get_network_name(&self) -> Option<String>[src]

Gets the name of the current server network, or None if unknown.

pub fn get_nickname(&self) -> String[src]

Gets the nickname in use on the current server.

pub fn get_nickserv_password(&self) -> Option<String>[src]

Gets the NickServ password for the current server, or None if none is set.

pub fn get_server_name(&self) -> Option<String>[src]

Gets the name of the current server, or None if unknown.

pub fn get_channel_topic(&self) -> String[src]

Gets the topic of the current channel.

pub fn get_hexchat_version(&self) -> String[src]

Gets the version string of the build of Hexchat you're running on.

impl Context[src]

pub fn get_all_channels(
    &self
) -> impl Iterator<Item = ChannelInfo>
[src]

Gets all channels currently open.

pub fn get_current_dcc_transfers(
    &self
) -> impl Iterator<Item = DccTransferInfo>
[src]

Gets all DCC transfers currently active.

pub fn get_ignore_entries(
    &self
) -> impl Iterator<Item = IgnoreEntry>
[src]

Gets all entries in the ignore list.

pub fn get_notify_users(
    &self
) -> impl Iterator<Item = NotifyEntry>
[src]

Gets all entries in the notify list.

pub fn get_users_in_current_channel(
    &self
) -> impl Iterator<Item = UserInfo>
[src]

Gets all the users in the current channel.

pub fn get_users_in_channel(
    &self,
    channel: &ChannelRef
) -> Option<impl Iterator<Item = UserInfo>>
[src]

Gets all the users in a specific channel, or None if the channel is invalid.

impl Context[src]

pub fn register_command(
    &self,
    name: &str,
    help_text: &str,
    priority: Priority,
    function: impl Fn(&Self, &[String]) -> EatMode + 'static
) -> Command
[src]

Registers a new command accessible to the user via /<COMMAND> [args]. Returns a corresponding object that can be passed to deregister_command.

Callback

The callback's signature corresponds to this context, followed by a slice of all the command arguments. If you intend to get command arguments, you should probably start at 1; argument 0 is the name of the command. The callback should return who the command event should be hidden from.

pub fn deregister_command(&self, command: Command)[src]

Deregisters a command registered by register_command.

pub fn add_print_event_listener(
    &self,
    event: PrintEvent,
    priority: Priority,
    function: impl Fn(&Self, &[String], DateTime<Utc>) -> EatMode + 'static
) -> PrintEventListener
[src]

Adds a listener for a particular PrintEvent; see PrintEvent's documentation for more details. Returns a corresponding object that can be passed to remove_print_event_listener.

Callback

The callback's signature is this context, followed by a slice of all the print event's arguments, followed by the time this message was printed. Note that the argument $1 corresponds to args[0] and so forth. The callback should return who the event should be hidden from.

pub fn remove_print_event_listener(&self, listener: PrintEventListener)[src]

Removes a listener added by add_print_event_listener.

pub fn add_window_event_listener(
    &self,
    event: WindowEvent,
    priority: Priority,
    function: impl Fn(&Self, ChannelRef) -> EatMode + 'static
) -> WindowEventListener
[src]

Adds a listener for a particular WindowEvent. See WindowEvent's docs for more details. Returns a corresponding object that can be passed to remove_window_event_listener.

Callback

The callback's signature is this context, followed by a ChannelRef corresponding to the channel this event is regarding or the current channel if none applies. The callback should return who the event should be hidden from.

pub fn remove_window_event_listener(&self, listener: WindowEventListener)[src]

Removes a listener added by add_window_event_listener.

pub fn add_raw_server_event_listener(
    &self,
    event: &str,
    priority: Priority,
    function: impl Fn(&Self, &[String], DateTime<Utc>) -> EatMode + 'static
) -> RawServerEventListener
[src]

Adds a listener for raw server events, i.e. commands coming straight from the server. Will be superseded by a fuller event API soon. Returns a corresponding object suitable for passing to remove_raw_server_event_listener.

Callback

The callback's signature is this context, followed by a slice of all the event's arguments, followed by the time this event was sent. If you intend to get event arguments, you probably should start at 1, since argument 0 is the event name. The callback should return who the event should be hidden from.

pub fn remove_raw_server_event_listener(&self, listener: RawServerEventListener)[src]

Removes a listener added by add_raw_server_event_listener.

pub fn add_timer_task(
    &self,
    interval: Duration,
    task: impl Fn(&Self) + 'static
) -> TimerTask
[src]

Registers a task to be run repeatedly with a specified interval. Returns a corresponding object suitable for passing to remove_timer_task.

Note

Right now the interval cannot be more than i32::max_value() milliseconds. If it is more than i32::max_value() milliseconds, it will be truncated to i32::max_value() milliseconds. This restriction will be lifted in the future.

pub fn remove_timer_task(&self, task: TimerTask)[src]

Removes a timer task added by add_timer_task.

impl Context[src]

pub fn print_plain(&self, text: &str)[src]

Prints plain text to the current tab.

pub fn print_event(
    &self,
    event: PrintEvent,
    arguments: &[impl AsRef<str>]
) -> bool
[src]

Prints a specific print event to the current tab. Returns whether or not it succeeded.

pub fn print_event_at(
    &self,
    event: PrintEvent,
    timestamp: &DateTime<impl TimeZone>,
    arguments: &[impl AsRef<str>]
) -> bool
[src]

Prints a specific print event to the current tab with a specified timestamp. Returns whether or not it succeeded.

pub fn print_event_to_channel(
    &self,
    channel: &ChannelRef,
    event: PrintEvent,
    args: &[impl AsRef<str>]
) -> bool
[src]

Prints a specific print event to a particular ChannelRef. Returns whether or not it succeeded.

pub fn print_event_to_channel_at(
    &self,
    channel: &ChannelRef,
    event: PrintEvent,
    timestamp: &DateTime<impl TimeZone>,
    args: &[impl AsRef<str>]
) -> bool
[src]

Prints a specific print event to a particular channel with a specified timestamp. Returns whether or not it succeeded.

pub fn add_modes(
    &self,
    targets: &[impl AsRef<str>],
    mode: char
) -> bool
[src]

Adds a user mode char to one or more users in the current channel. Returns whether or not it succeeded.

pub fn remove_modes(
    &self,
    targets: &[impl AsRef<str>],
    mode: char
) -> bool
[src]

Removes a user mode char from one or more users in the current channel. Returns whether or not it succeeded.

pub fn add_modes_in_channel(
    &self,
    targets: &[impl AsRef<str>],
    mode: char,
    channel: &ChannelRef
) -> bool
[src]

Adds a user mode char to one or more users in the specified channel. Returns whether or not it succeeded.

pub fn remove_modes_in_channel(
    &self,
    targets: &[impl AsRef<str>],
    mode: char,
    channel: &ChannelRef
) -> bool
[src]

Removes a user mode char from one or more users in the specified channel. Returns whether or not it succeeded.

pub fn name_cmp(&self, nick1: &str, nick2: &str) -> Ordering[src]

Compares two names (nicks, channel names, etc.) according to IRC comparison rules.

pub fn strip_colors(&self, string: &str) -> Result<String, ()>[src]

Strips color characters from a string. Returns the stripped string, or Err if the color characters are malformed.

pub fn strip_attributes(&self, string: &str) -> Result<String, ()>[src]

Strips non-color formatting characters from a string. Returns the stripped string, or Err if the formatting characters are malformed.

pub fn strip_formatting(&self, string: &str) -> Result<String, ()>[src]

Strips all formatting characters from a string. Returns the stripped string, or Err if the formatting characters are malformed.

pub fn strip_colors_in_place(&self, string: &mut String) -> Result<(), ()>[src]

Strips color characters from a string and puts the result back into the string. Returns Ok if it succeeded or Err if the color characters are malformed.

pub fn strip_attributes_in_place(&self, string: &mut String) -> Result<(), ()>[src]

Strips non-color formatting characters from a string and puts the result back into the string. Returns Ok if it succeeded or Err if the formatting characters are malformed.

pub fn strip_formatting_in_place(&self, string: &mut String) -> Result<(), ()>[src]

Strips all formatting characters from a string and puts the result back into the string. Returns Ok if it succeeded or Err if the formatting characters are malformed

impl Context[src]

pub fn get_global_pref(&self, name: &str) -> Option<GlobalPreferenceValue>[src]

Gets a HexChat user preference by name. Returns the preference if found, or None if no preference by that name exists.

pub fn get_cursor_pos(&self) -> Option<usize>[src]

Gets the current cursor position in the text box, or None if it's deselected.

pub fn get_server_id(&self) -> Option<i32>[src]

Gets the unique ID of the current server, or None if unknown.

pub fn set_pref_string(&self, name: &str, value: &str) -> Result<(), ()>[src]

Saves a plugin preference string to file. Returns Ok if it succeeded, or Err if there was an IO error.

pub fn set_pref_int(&self, name: &str, value: u32) -> Result<(), ()>[src]

Saves a plugin preference integer to file. Returns Ok if it succeeeded, or Err if there was an IO error.

pub fn get_pref_string(&self, name: &str) -> Option<String>[src]

Gets a plugin preference string from file. Returns the result, or None if no such preference exists or there was an IO error.

pub fn get_pref_int(&self, name: &str) -> Option<u32>[src]

Gets a plugin preference integer from file. Returns the result, or None if no such preference exists or there was an IO error.

pub fn delete_pref(&self, name: &str) -> Result<(), ()>[src]

Deletes a plugin preference from the preferences file. Returns Ok if it succeeded or Err if no such preference exists or there was an IO error.

pub fn get_prefs(&self) -> Vec<String>[src]

Gets every plugin preference name that has been saved.

impl Context[src]

pub fn get_current_channel(&self) -> ChannelRef[src]

Gets the current channel context.

pub fn get_focused_channel(&self) -> Option<ChannelRef>[src]

Gets the channel that's currently focused in the HexChat window. Returns the ChannelRef if found, or None if none exists.

pub fn get_focused_channel_in_server(
    &self,
    server_name: &str
) -> Option<ChannelRef>
[src]

Gets the frontmost channel in a particular server. Returns the ChannelRef if found, or None if none exists.

pub fn get_first_channel(&self, channel_name: &str) -> Option<ChannelRef>[src]

Gets the first channel with the specified name in any server. Returns the ChannelRef if found, or None if none exists.

pub fn get_channel(
    &self,
    server_name: &str,
    channel_name: &str
) -> Option<ChannelRef>
[src]

Gets the first channel with the specified name in the specified server. Returns the ChannelRef if found, or None if none exists.

impl Context[src]

pub fn add_fake_plugin(
    &self,
    path: impl AsRef<Path>,
    name: &str,
    description: &str,
    version: &str
) -> FakePlugin
[src]

Adds a fake plugin to the plugin list. Useful for scripting enablement plugins, like the Lua plugin. You don't need to use this to add your crate-registered plugin, and please don't. Returns a corresponding object suitable for passing to remove_fake_plugin.

pub fn remove_fake_plugin(&self, plugin: FakePlugin)[src]

Removes a fake plugin entry from the plugin list added by add_fake_plugin. In case you missed it the first time around, please do not add your crate-registered plugin to this list.

impl Context[src]

pub fn send_command(&self, command: &str)[src]

Executes a command as though it were typed in HexChat's input box.

Auto Trait Implementations

impl !Send for Context

impl !Sync for Context

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.