chat.irc

class platypush.plugins.chat.irc.ChatIrcPlugin(servers: Sequence[dict], **kwargs)[source]

IRC integration.

This plugin allows you to easily create IRC bots with custom logic that reacts to IRC events and interact with IRC sessions.

Triggers:

Requires:

  • irc (pip install irc)

__init__(servers: Sequence[dict], **kwargs)[source]
Parameters

servers – List of servers/channels that the bot will automatically connect/join.

channel(server: Union[str, Tuple[str, int]], channel: str) dict[source]

Get information about a connected channel.

Parameters
  • server – IRC server, identified either by alias or (server, port) tuple.

  • channel

Returns

{
  "is_invite_only": false,
  "is_moderated": true,
  "is_protected": false,
  "is_secret": false,
  "modes": [
    "string"
  ],
  "name": "string",
  "opers": [
    "string"
  ],
  "owners": [
    "string"
  ],
  "users": [
    "string"
  ],
  "voiced": [
    "string"
  ]
}

disconnect(server: Union[str, Tuple[str, int]], message: Optional[str] = None)[source]

Disconnect from a server.

Parameters
  • server – IRC server, identified either by alias or (server, port) tuple.

  • message – Disconnect message (default: configured stop_message.

invite(nick: str, channel: str, server: Union[str, Tuple[str, int]])[source]

Invite a nick to a channel.

Parameters
  • nick – Target IRC nick.

  • channel – Target IRC channel.

  • server – IRC server, identified either by alias or (server, port) tuple.

join(channel: str, server: Union[str, Tuple[str, int]])[source]

Join a channel.

Parameters
  • channel – Target IRC channel.

  • server – IRC server, identified either by alias or (server, port) tuple.

kick(nick: str, channel: str, server: Union[str, Tuple[str, int]], reason: Optional[str] = None)[source]

Kick a nick from a channel.

Parameters
  • nick – Target IRC nick.

  • channel – Target IRC channel.

  • server – IRC server, identified either by alias or (server, port) tuple.

  • reason – Kick reason.

mode(target: str, command: str, server: Union[str, Tuple[str, int]])[source]

Send a MODE command on the selected target.

Parameters
  • target – IRC target.

  • command – Mode command.

  • server – IRC server, identified either by alias or (server, port) tuple.

oper(nick: str, password: str, server: Union[str, Tuple[str, int]])[source]

Send an OPER command.

Parameters
  • nick – IRC nick.

  • password – Nick password.

  • server – IRC server, identified either by alias or (server, port) tuple.

part(channel: Union[str, Sequence[str]], server: Union[str, Tuple[str, int]], message: Optional[str] = None)[source]

Parts/exits a channel.

Parameters
  • channel – IRC channel (or list of channels).

  • server – IRC server, identified either by alias or (server, port) tuple.

  • message – Optional part message (default: same as the bot’s stop_message).

quit(server: Union[str, Tuple[str, int]], message: Optional[str] = None)[source]

Send a QUIT command.

Parameters
  • server – IRC server, identified either by alias or (server, port) tuple.

  • message – Optional quit message (default: same as the bot’s stop_message).

send_ctcp_message(ctcp_type: str, body: str, server: Union[str, Tuple[str, int]], target: str)[source]

Send a CTCP message to a target.

Parameters
  • ctcp_type – CTCP message type.

  • body – Message content.

  • server – IRC server, identified either by alias or (server, port) tuple.

  • target – Message target.

send_ctcp_reply(body: str, server: Union[str, Tuple[str, int]], target: str)[source]

Send a CTCP REPLY command.

Parameters
  • body – Message content.

  • server – IRC server, identified either by alias or (server, port) tuple.

  • target – Message target.

send_file(file: str, server: Union[str, Tuple[str, int]], nick: str, bind_address: Optional[str] = None)[source]

Send a file to an IRC user over DCC connection. Note that passive connections are currently not supported.

Parameters
  • file – Path of the file that should be transferred.

  • server – IRC server, identified either by alias or (server, port) tuple.

  • nick – Target IRC nick.

  • bind_address – DCC listen bind address (default: any).

send_message(text: str, server: Union[str, Tuple[str, int]], target: Union[str, Sequence[str]])[source]

Send a message to a channel or a nick.

Parameters
  • text – Message content.

  • server – IRC server, identified either by alias or (server, port) tuple.

  • target – Message target (nick or channel). If it’s a list then the message will be sent to multiple targets.

send_notice(text: str, server: Union[str, Tuple[str, int]], target: str)[source]

Send a notice to a channel or a nick.

Parameters
  • text – Message content.

  • server – IRC server, identified either by alias or (server, port) tuple.

  • target – Message target (nick or channel).

send_raw(message: str, server: Union[str, Tuple[str, int]])[source]

Send a raw IRC message to a connected server.

Parameters
  • message – IRC message.

  • server – IRC server, identified either by alias or (server, port) tuple.

servers() Sequence[dict][source]

Get information about the connected servers.

Returns

[
  {
    "alias": "strippedstring",
    "connected_channels": [
      "string"
    ],
    "is_connected": false,
    "nickname": "string",
    "port": 99,
    "real_name": "string",
    "server": "strippedstring"
  }
]

set_nick(nick: str, server: Union[str, Tuple[str, int]])[source]

Set the IRC nick.

Parameters
  • nick – New IRC nick.

  • server – IRC server, identified either by alias or (server, port) tuple.

topic(channel: str, server: Union[str, Tuple[str, int]], topic: Optional[str] = None) str[source]

Get/set the topic of an IRC channel.

Parameters
  • channel – IRC channel.

  • server – IRC server, identified either by alias or (server, port) tuple.

  • topic – If specified, then set the new topic as channel topic. Otherwise, just return the current channel topic.

whois(target: str, server: Union[str, Tuple[str, int]])[source]

Send a WHOIS command for a target.

Parameters
  • target – IRC target.

  • server – IRC server, identified either by alias or (server, port) tuple.