chat.irc#

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

Bases: RunnablePlugin, ChatPlugin

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: 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": true,
  "is_moderated": false,
  "is_protected": false,
  "is_secret": false,
  "modes": [
    "string"
  ],
  "name": "string",
  "opers": [
    "string"
  ],
  "owners": [
    "string"
  ],
  "users": [
    "string"
  ],
  "voiced": [
    "string"
  ]
}

disconnect(server: str | Tuple[str, int], message: str | None = 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: 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: 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: str | Tuple[str, int], reason: str | None = 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.

main()[source]#

Implementation of the main loop of the plugin.

mode(target: str, command: str, server: 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: 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: str | Sequence[str], server: str | Tuple[str, int], message: str | None = 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: str | Tuple[str, int], message: str | None = 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: 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: 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: str | Tuple[str, int], nick: str, bind_address: str | None = 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: str | Tuple[str, int], target: 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: 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: 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": 92,
    "real_name": "string",
    "server": "strippedstring"
  }
]

set_nick(nick: str, server: 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.

stop()[source]#

Stop the plugin.

topic(channel: str, server: str | Tuple[str, int], topic: str | None = 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: 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.