plug.irc

exception immp.plug.irc.IRCError

Bases: immp.core.error.PlugError

Generic error from the IRC server.

exception immp.plug.irc.IRCTryAgain

Bases: immp.plug.irc.IRCError

Rate-limited response to an IRC command (RPL_TRYAGAIN, 263).

class immp.plug.irc.Line(command, *args, source=None, tags=None)

Bases: object

Low-level representation of an IRC message, either sent or received. Calling str() on a line will encode it suitable for transmission.

command

str – IRC verb or numeric.

args

str list – Additional arguments for this message.

source

str list – Optional source of this message.

tags

(str, str) dict – Any tags attached to the message.

classmethod parse(line)

Take a raw IRC line and decode it into a Line.

Parameters
line (str) – Raw IRC message.
Returns
Parsed line.
Return type
Line
class immp.plug.irc.IRCSegment(text, *, bold=False, italic=False, underline=False, strike=False, code=False, pre=False, link=None, mention=None)

Bases: immp.core.message.Segment

Plug-friendly representation of IRC message formatting.

classmethod to_formatted(segment)

Convert a Segment into text formatted using IRC ASCII escape sequences.

Parameters
segment (Segment) – Message segment created by another plug.
Returns
Code-formatted string.
Return type
str
class immp.plug.irc.IRCRichText(segments=None)

Bases: immp.core.message.RichText

Wrapper for IRC-specific encoding of formatting.

classmethod to_formatted(rich)

Convert a RichText into text formatted using IRC ASCII escape sequences.

Parameters
rich (RichText) – Parsed rich text container.
Returns
Code-formatted string.
Return type
str
class immp.plug.irc.IRCMessage(*, text=None, user=None, edited=False, action=False, reply_to=None, joined=None, left=None, title=None, attachments=None, raw=None)

Bases: immp.core.message.Message

Message originating from IRC.

classmethod from_line(irc, line)

Convert a Line into a Message.

Parameters
  • irc (IRCPlug) – Related plug instance that provides the line.
  • line (Line) – Raw message line from the server.
Returns

Parsed message object.

Return type

IRCMessage

class immp.plug.irc.Wait(lines, success, fail, collect)

Bases: object

Request-like object for sending a Line and waiting on a response.

After sending, await an instance of this class to retrieve all collected lines after a success line is received. On failure, a ValueError is raised.

class immp.plug.irc.IRCPlug(name, config, host)

Bases: immp.core.plug.Plug

Plug for an IRC server.