irc
#
Description#
IRC integration.
This plugin allows you to easily create IRC bots with custom logic that reacts to IRC events and interact with IRC sessions.
Configuration#
irc:
# [Required]
# List of servers/channels that the bot will
# automatically connect/join. Format:
#
# .. code-block:: yaml
#
# servers:
# - server: irc.example.org
# port: 6697
# ssl: true
# ipv6: false
# username: foo
# password: bar
# nickname: testbot
# realname: Test Bot
#
# # List of channels that the bot will automatically join
# channels:
# - #channel1
# - #channel2
# - #channel3
servers: # type=Sequence[dict]
# [Optional]
# How often the `RunnablePlugin.loop <https://docs.platypush.tech/platypush/plugins/.html#platypush.plugins.RunnablePlugin.loop>`_ function should be
# executed (default: 15 seconds). *NOTE*: For back-compatibility
# reasons, the `poll_seconds` argument is also supported, but it's
# deprecated.
# poll_interval: 15 # type=Optional[float]
# [Optional]
# How long we should wait for any running
# threads/processes to stop before exiting (default: 5 seconds).
# stop_timeout: 5 # type=Optional[float]
# [Optional]
# If set to True then the plugin will not monitor
# for new events. This is useful if you want to run a plugin in
# stateless mode and only leverage its actions, without triggering any
# events. Defaults to False.
# disable_monitor: False # type=bool
Dependencies#
pip
pip install irc
Debian
apt install python3-irc
Fedora
yum install python-irc
Arch Linux
pacman -S python-irc
Triggered events#
Actions#
Module reference#
- class platypush.plugins.irc.IrcPlugin(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.
- __init__(servers: Sequence[dict], **kwargs)[source]#
- Parameters:
servers –
List of servers/channels that the bot will automatically connect/join. Format:
servers: - server: irc.example.org port: 6697 ssl: true ipv6: false username: foo password: bar nickname: testbot realname: Test Bot # List of channels that the bot will automatically join channels: - #channel1 - #channel2 - #channel3
- 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": false, "is_moderated": false, "is_protected": true, "is_secret": true, "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.
- 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": 62, "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.
- start()#
Start 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.
- wait_stop(timeout=None)#
Wait until a stop event is received.