Capability Negotiation#
Management of IRC capability negotiation.
New in version 8.0.
This module contains the Capabilities class which tracks the state of
the capability negotiation with the IRC server: it can store and update the
state of available and enabled capabilities.
Important
Plugin authors should not instantiate this class directly, as the bot
exposes an instance through its capabilities
attribute.
All state handling methods (such as Capabilities.handle_ls()) are
used by the coretasks plugin, and should not be used outside.
- class sopel.irc.capabilities.Capabilities#
Capabilities negotiated with the server.
This stores a representation of the capability negotiation state between the bot and the server: it stores the list of
availableandenabledcapabilities, and can track the state by handling variousCAPsubcommands:handle_ls()forCAP LShandle_ack()forCAP ACKhandle_nak()forCAP NAKhandle_new()forCAP NEWhandle_del()forCAP ADD
- property available: dict[str, str | None]#
Dict of available server capabilities.
Each key is the name of a capability advertised by the server, and each value is the parameters as advertised (if any) for this capability.
If a capability is not in this
dict, it means the server doesn’t advertise it, and it cannot be requested.
- property enabled: frozenset[str]#
Set of enabled server capabilities.
Each element is the name of a capability that is enabled on the server.
- get_capability_info(
- name: str,
Retrieve metadata about a capability.
The returned
CapabilityInfowill tell if the capability is advertised by the server; and if so, its parameters and whether it is enabled.If the capability is unknown, then its
availableattribute will beFalse, and itsparamsattribute will beNone.
- handle_ack(bot: SopelWrapper, trigger: Trigger) tuple[str, ...]#
Handle a
CAP ACKcommand.This method behaves as a plugin callable with its
botandtriggerarguments, with the precise goals to handleCAP ACKcommand only, registering enabled or disabled capabilities and tracking acknowledgement.Then it returns the list of acknowledged capability requests.
- handle_del(bot: SopelWrapper, trigger: Trigger) tuple[str, ...]#
Handle a
CAP DELcommand.This method behaves as a plugin callable with its
botandtriggerarguments, with the precise goals to handleCAP DELcommand only.It registers which capabilities are not available and not enabled anymore, then returns this list.
- handle_ls(bot: SopelWrapper, trigger: Trigger) bool#
Handle a
CAP LScommand.This method behaves as a plugin callable with its
botandtriggerarguments, with the precise goals to handleCAP LScommand only, registering available capabilities.Then it returns if there is no more
LScommand to handle (in case of multi-lineLS).
- handle_nak(bot: SopelWrapper, trigger: Trigger) tuple[str, ...]#
Handle a
CAP NAKcommand.This method behaves as a plugin callable with its
botandtriggerarguments, with the precise goals to handleCAP NAKcommand only.Then it returns the list of denied capability requests.
- handle_new(bot: SopelWrapper, trigger: Trigger) tuple[str, ...]#
Handle a
CAP NEWcommand.This method behaves as a plugin callable with its
botandtriggerarguments, with the precise goals to handleCAP NEWcommand only.It registers which new capabilities are available, then returns this list.
- class sopel.irc.capabilities.CapabilityInfo#
Capability metadata.
This contains the details of a capability: if
available,enabled, and itsparams(if advertised).Note
You can get a capability’s info through
Capabilities.get_capability_info().- available: bool#
Flag to tell if the server advertises this capability or not.
This is
Trueif theCAP LSsubcommand contains the capability.
- name: str#
Name of the capability.
The name of a capability is the name as it appears in the
CAP LSsubcommand, such asmulti-prefixorsasl.
- params: str | None#
Advertised parameters for this capability.
When a server supports
CAPversion 302, capabilities can have parameters. The format and the meaning of the parameters depend on the capability itself.For example, the
saslcapability can provide the list of SASL mechanisms the server supports, such asPLAIN,EXTERNAL.