errbot.backends.irc module¶
-
class
errbot.backends.irc.
IRCBackend
(config)[source]¶ Bases:
errbot.core.ErrBot
-
aclpattern
= '{nick}!{user}@{host}'¶
-
build_reply
(msg, text=None, private=False, threaded=False)[source]¶ Should be implemented by the backend
-
change_presence
(status: str = 'online', message: str = '') → None[source]¶ Signal a presence change for the bot. Should be overridden by backends with a super().send_message() call.
-
mode
¶
-
prefix_groupchat_reply
(message, identifier)[source]¶ Patches message with the conventional prefix to ping the specific contact For example: @gbin, you forgot the milk !
-
query_room
(room)[source]¶ Query a room for information.
Parameters: room – The channel name to query for. Returns: An instance of IRCMUCRoom
.
-
rooms
()[source]¶ Return a list of rooms the bot is currently in.
Returns: A list of IRCMUCRoom
instances.
-
send_message
(msg)[source]¶ This needs to be overridden by the backends with a super() call.
Parameters: msg – the message to send. Returns: None
-
serve_forever
()[source]¶ Connect the back-end to the server and serve forever.
Back-ends MAY choose to re-implement this method, in which case they are responsible for implementing reconnection logic themselves.
Back-ends SHOULD trigger
connect_callback()
anddisconnect_callback()
themselves after connection/disconnection.
-
-
class
errbot.backends.irc.
IRCConnection
(bot, nickname, server, port=6667, ssl=False, bind_address=None, ipv6=False, password=None, username=None, nickserv_password=None, private_rate=1, channel_rate=1, reconnect_on_kick=5, reconnect_on_disconnect=5)[source]¶ Bases:
irc.bot.SingleServerIRCBot
-
__init__
(bot, nickname, server, port=6667, ssl=False, bind_address=None, ipv6=False, password=None, username=None, nickserv_password=None, private_rate=1, channel_rate=1, reconnect_on_kick=5, reconnect_on_disconnect=5)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
away
(message='')[source]¶ Extend the original implementation to support AWAY. To set an away message, set message to something. To cancel an away message, leave message at empty string.
-
on_currenttopic
(connection, event)[source]¶ When you Join a room with a topic set this event fires up to with the topic information. If the room that you join don’t have a topic set, nothing happens. Here is NOT the place to fire the
callback_room_topic()
event for that case exist on_topic.Parameters: - connection – Is an ‘irc.client.ServerConnection’ object
- event – Is an ‘irc.client.Event’ object The event.arguments[0] contains the room name The event.arguments[1] contains the topic of the room.
-
on_endofnames
(connection, event)[source]¶ Handler of the enfofnames IRC message/event.
The endofnames message is sent to the client when the server finish to send the list of names of the room ocuppants. This usually happens when you join to the room. So in this case, we use this event to determine that our bot is finally joined to the room.
Parameters: - connection – Is an ‘irc.client.ServerConnection’ object
- event – Is an ‘irc.client.Event’ object the event.arguments[0] contains the channel name
-
on_join
(connection, event)[source]¶ Handler of the join IRC message/event. Is in response of a /JOIN client message.
Parameters: - connection – Is an ‘irc.client.ServerConnection’ object
- event – Is an ‘irc.client.Event’ object the event.target contains the channel name
-
on_notopic
(connection, event)[source]¶ This event fires ip when there is no topic set on a room
Parameters: - connection – Is an ‘irc.client.ServerConnection’ object
- event – Is an ‘irc.client.Event’ object The event.arguments[0] contains the room name
-
on_part
(connection, event)[source]¶ Handler of the part IRC Message/event.
The part message is sent to the client as a confirmation of a /PART command sent by someone in the room/channel. If the event.source contains the bot nickname then we need to fire the
callback_room_left()
event on the bot.Parameters: - connection – Is an ‘irc.client.ServerConnection’ object
- event – Is an ‘irc.client.Event’ object The event.source contains the nickmask of the user that leave the room The event.target contains the channel name
-
on_topic
(connection, event)[source]¶ On response to the /TOPIC command if the room have a topic. If the room don’t have a topic the event fired is on_notopic :param connection: Is an ‘irc.client.ServerConnection’ object
Parameters: event – Is an ‘irc.client.Event’ object The event.target contains the room name. The event.arguments[0] contains the topic name
-
-
class
errbot.backends.irc.
IRCPerson
(mask)[source]¶ Bases:
errbot.backends.base.Person
-
aclattr
¶ Returns: returns the unique identifier that will be used for ACL matches.
-
client
¶ Returns: a backend specific unique identifier representing the device or client the person is using to talk.
-
fullname
¶ Some backends have the full name of a user.
Returns: the fullname of this user if available.
-
host
¶
-
nick
¶ Returns: a backend specific nick returning the nickname of this person if available.
-
person
¶ Returns: a backend specific nick returning the nickname of this person if available.
-
user
¶
-
-
class
errbot.backends.irc.
IRCRoom
(room, bot)[source]¶ Bases:
errbot.backends.base.Room
Represent the specifics of a IRC Room/Channel.
- This lifecycle of this object is:
- Created in IRCConnection.on_join
- The joined status change in IRCConnection on_join/on_part
- Deleted/destroyed in IRCConnection.on_disconnect
-
cb_set_topic
(current_topic)[source]¶ Store the current topic for this room.
This method is called by the IRC backend when a currenttopic, topic or notopic IRC event is received to store the topic set for this channel.
This function is not meant to be executed by regular plugins. To get or set
-
exists
¶ Boolean indicating whether this room already exists or not.
Getter: Returns True if the room exists, False otherwise.
-
invite
(*args)[source]¶ Invite one or more people into the room.
*argsargs: One or more nicks to invite into the room.
-
join
(username=None, password=None)[source]¶ Join the room.
If the room does not exist yet, this will automatically call
create()
on it first.
-
joined
¶ Boolean indicating whether this room has already been joined.
Getter: Returns True if the room has been joined, False otherwise.
-
leave
(reason=None)[source]¶ Leave the room.
Parameters: reason – An optional string explaining the reason for leaving the room
-
occupants
¶ The room’s occupants.
Getter: Returns a list of occupants. :raises: MUCNotJoinedError
if the room has not yet been joined.
-
topic
¶ The room topic.
Getter: Returns the topic (a string) if one is set, None if no topic has been set at all.
-
class
errbot.backends.irc.
IRCRoomOccupant
(mask, room)[source]¶ Bases:
errbot.backends.irc.IRCPerson
,errbot.backends.base.RoomOccupant
-
room
¶ Some backends have the full name of a user.
Returns: the fullname of this user if available.
-