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:
platypush.message.event.irc.IRCChannelJoinEvent
when a user joins a channel.platypush.message.event.irc.IRCChannelKickEvent
when a user is kicked from a channel.platypush.message.event.irc.IRCModeEvent
when a user/channel mode change event occurs.platypush.message.event.irc.IRCPartEvent
when a user parts a channel.platypush.message.event.irc.IRCQuitEvent
when a user quits.platypush.message.event.irc.IRCNickChangeEvent
when a user nick changes.platypush.message.event.irc.IRCConnectEvent
when the bot connects to a server.platypush.message.event.irc.IRCDisconnectEvent
when the bot disconnects from a server.platypush.message.event.irc.IRCPrivateMessageEvent
when a private message is received.platypush.message.event.irc.IRCPublicMessageEvent
when a public message is received.platypush.message.event.irc.IRCDCCRequestEvent
when a DCC connection request is received.platypush.message.event.irc.IRCDCCMessageEvent
when a DCC message is received.platypush.message.event.irc.IRCCTCPMessageEvent
when a CTCP message is received.platypush.message.event.irc.IRCDCCFileRequestEvent
when a DCC file request is received.platypush.message.event.irc.IRCDCCFileRecvCompletedEvent
when a DCC file download is completed.platypush.message.event.irc.IRCDCCFileRecvCancelledEvent
when a DCC file download is cancelled.platypush.message.event.irc.IRCDCCFileSendCompletedEvent
when a DCC file upload is completed.platypush.message.event.irc.IRCDCCFileSendCancelledEvent
when a DCC file upload is cancelled.
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.
- 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.
- 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.