Struct hexchat_api::Context
source · pub struct Context { /* private fields */ }
Expand description
Any channel in Hexchat has an associated IRC network name and channel name.
The network name and channel name are closely associated with the Hexchat
concept of contexts. Hexchat contexts can also be thought of as the
tabs, or windows, open in the UI that have the user joined to their various
“chat rooms”. To access a specific chat window in Hexchat, its context
can be acquired and used. This library’s Context
objects represent the
Hexchat contexts and can be used to interact with the specific
channels/windows/tabs that he user has open. For instance if your plugin
needs to output only to specific channels, rather than the default window
(which is the one currently open) - it can acquire the appropriate context
using Context::find("some-network", "some-channel")
, and use the object
returned to invoke a command, context.command("SAY hello!")
, or print,
context.print("Hello!")
, or perform other operations.
Implementations§
source§impl Context
impl Context
sourcepub fn find(network: &str, channel: &str) -> Option<Self>
pub fn find(network: &str, channel: &str) -> Option<Self>
This will create a new Context
object holding an internal pointer to
the requested network/channel, if it exists. The object will be
returned as a Some<Context>
if the context is found, or None
if
not.
sourcepub fn get() -> Option<Self>
pub fn get() -> Option<Self>
This will create a new Context
that represents the currently active
context (window/tab, channel/network) open on the user’s screen. An
Context
object is returned, or None
if it couldn’t be obtained.
sourcepub fn set(&self) -> Result<(), HexchatError>
pub fn set(&self) -> Result<(), HexchatError>
Sets the currently active context to the context the Context
object
points to internally.
sourcepub fn print(&self, message: &str) -> Result<(), HexchatError>
pub fn print(&self, message: &str) -> Result<(), HexchatError>
Prints the message to the Context
object’s Hexchat context. This is
how messages can be printed to Hexchat windows apart from the currently
active one.
sourcepub fn emit_print(
&self,
event_name: &str,
var_args: &[&str]
) -> Result<(), HexchatError>
pub fn emit_print( &self, event_name: &str, var_args: &[&str] ) -> Result<(), HexchatError>
Issues a print event to the context held by the Context
object.
sourcepub fn command(&self, command: &str) -> Result<(), HexchatError>
pub fn command(&self, command: &str) -> Result<(), HexchatError>
Issues a command in the context held by the Context
object.
sourcepub fn get_info(&self, list: &str) -> Result<String, HexchatError>
pub fn get_info(&self, list: &str) -> Result<String, HexchatError>
Gets information from the channel/window that the Context
object
holds an internal pointer to.
sourcepub fn list_get(&self, list: &str) -> Result<ListIterator, HexchatError>
pub fn list_get(&self, list: &str) -> Result<ListIterator, HexchatError>
Gets a ListIterator
from the context held by the Context
object.