errbot.backends.irc module¶
-
class
errbot.backends.irc.
IRCBackend
(config)[source]¶ Bases:
errbot.core.ErrBot
-
aclpattern
= '{nick}!{user}@{host}'¶
-
build_identifier
(txtrep: str) → Union[errbot.backends.irc.IRCRoom, errbot.backends.irc.IRCRoomOccupant, errbot.backends.irc.IRCPerson][source]¶
-
build_message
(text: str) → errbot.backends.base.Message[source]¶ You might want to override this one depending on your backend
-
build_reply
(msg: errbot.backends.base.Message, text: Optional[str] = None, private: bool = False, threaded: str = False) → errbot.backends.base.Message[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.
-
connect
() → errbot.backends.irc.IRCConnection[source]¶ Connects the bot to server or returns current connection
-
mode
¶
-
prefix_groupchat_reply
(message: errbot.backends.base.Message, identifier: errbot.backends.base.Identifier)[source]¶ Patches message with the conventional prefix to ping the specific contact For example: @gbin, you forgot the milk !
-
query_room
(room: errbot.backends.irc.IRCRoom) → errbot.backends.irc.IRCRoom[source]¶ Query a room for information.
Return type: IRCRoom
Parameters: room ( IRCRoom
) – The channel name to query for.Returns: An instance of IRCMUCRoom
.
-
rooms
() → List[errbot.backends.irc.IRCRoom][source]¶ Return a list of rooms the bot is currently in.
Returns: A list of IRCMUCRoom
instances.
-
send_message
(msg: errbot.backends.base.Message) → None[source]¶ This needs to be overridden by the backends with a super() call.
Parameters: msg ( Message
) – the message to send.Returns: None
-
send_stream_request
(identifier: errbot.backends.base.Identifier, fsource: BinaryIO, name: Optional[str] = None, size: Optional[int] = None, stream_type: Optional[str] = None) → errbot.backends.base.Stream[source]¶
-
serve_forever
() → None[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: Optional[str] = '') → None[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: irc.client.ServerConnection, event: irc.client.Event) → None[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 (
ServerConnection
) – Is an ‘irc.client.ServerConnection’ object - event (
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.
- connection (
-
on_endofnames
(connection: irc.client.ServerConnection, event: irc.client.Event) → None[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 (
ServerConnection
) – Is an ‘irc.client.ServerConnection’ object - event (
Event
) – Is an ‘irc.client.Event’ object the event.arguments[0] contains the channel name
- connection (
-
on_join
(connection: irc.client.ServerConnection, event: irc.client.Event) → None[source]¶ Handler of the join IRC message/event. Is in response of a /JOIN client message.
Parameters: - connection (
ServerConnection
) – Is an ‘irc.client.ServerConnection’ object - event (
Event
) – Is an ‘irc.client.Event’ object the event.target contains the channel name
- connection (
-
on_notopic
(connection: irc.client.ServerConnection, event: irc.client.Event) → None[source]¶ This event fires ip when there is no topic set on a room
Parameters: - connection (
ServerConnection
) – Is an ‘irc.client.ServerConnection’ object - event (
Event
) – Is an ‘irc.client.Event’ object The event.arguments[0] contains the room name
- connection (
-
on_part
(connection: irc.client.ServerConnection, event: irc.client.Event) → None[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 (
ServerConnection
) – Is an ‘irc.client.ServerConnection’ object - event (
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
- connection (
-
on_topic
(connection: irc.client.ServerConnection, event: irc.client.Event) → None[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 :type event:
Event
:type connection:ServerConnection
:param connection: Is an ‘irc.client.ServerConnection’ objectParameters: 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.
-
email
¶ Some backends have the email of a user.
Returns: the email of this user if available.
-
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: errbot.backends.base.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
-
__init__
(room: errbot.backends.base.Room, bot)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
cb_set_topic
(current_topic: str) → None[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
-
create
() → None[source]¶ Not supported on this back-end. Will join the room to ensure it exists, instead.
-
exists
¶ Boolean indicating whether this room already exists or not.
Getter: Returns True if the room exists, False otherwise.
-
invite
(*args) → None[source]¶ Invite one or more people into the room.
*argsargs: One or more nicks to invite into the room.
-
join
(username: Any = None, password: Optional[str] = None) → 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: Optional[str] = None) → 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.
-