errbot.backends.xmpp module

class errbot.backends.xmpp.XMPPBackend(config)[source]

Bases: ErrBot

__init__(config)[source]

Those arguments will be directly those put in BOT_IDENTITY

build_identifier(txtrep: str) XMPPRoomOccupant | XMPPRoom | XMPPPerson[source]
build_reply(msg: Message, text: str = None, private: bool = False, threaded: bool = False) 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.

chat_topic(event) None[source]
connected(data) None[source]

Callback for connection events

contact_offline(event) None[source]
contact_online(event) None[source]
create_connection() XMPPConnection[source]
disconnected(data) None[source]

Callback for disconnection events

incoming_message(xmppmsg: dict) None[source]

Callback for message events

property mode
prefix_groupchat_reply(message: Message, identifier: Identifier)[source]

Patches message with the conventional prefix to ping the specific contact For example: @gbin, you forgot the milk !

query_room(room) XMPPRoom[source]

Query a room for information.

Parameters:

room – The JID/identifier of the room to query for.

Returns:

An instance of XMPPMUCRoom.

room_factory

alias of XMPPRoom

roomoccupant_factory

alias of XMPPRoomOccupant

rooms() List[XMPPRoom][source]

Return a list of rooms the bot is currently in.

Returns:

A list of XMPPMUCRoom instances.

send_message(msg: Message) None[source]

This needs to be overridden by the backends with a super() call.

Parameters:

msg – the message to send.

Returns:

None

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() and disconnect_callback() themselves after connection/disconnection.

user_changed_status(event) None[source]
user_joined_chat(event) None[source]
user_left_chat(event) None[source]
class errbot.backends.xmpp.XMPPConnection(jid, password, feature=None, keepalive=None, ca_cert=None, server=None, use_ipv6=None, bot=None, ssl_version=None)[source]

Bases: object

__init__(jid, password, feature=None, keepalive=None, ca_cert=None, server=None, use_ipv6=None, bot=None, ssl_version=None)[source]
add_event_handler(name: str, cb: Callable) None[source]
connect() XMPPConnection[source]
del_event_handler(name: str, cb: Callable) None[source]
disconnect() None[source]
serve_forever() None[source]
session_start(_)[source]
class errbot.backends.xmpp.XMPPIdentifier(node, domain, resource)[source]

Bases: Identifier

This class is the parent and the basic contract of all the ways the backends are identifying a person on their system.

__init__(node, domain, resource)[source]
property client
property domain: str
property email
property fullname: None
property nick: str
property node: str
property person: str
property resource: str
class errbot.backends.xmpp.XMPPPerson(node, domain, resource)[source]

Bases: XMPPIdentifier, Person

property aclattr: str
Returns:

returns the unique identifier that will be used for ACL matches.

class errbot.backends.xmpp.XMPPRoom(room_jid, bot: ErrBot)[source]

Bases: XMPPIdentifier, Room

__init__(room_jid, bot: ErrBot)[source]
configure() None[source]

Configure the room.

Currently this simply sets the default room configuration as received by the server. May be extended in the future to set a custom room configuration instead.

create() None[source]

Not supported on this back-end (Slixmpp doesn’t support it). Will join the room to ensure it exists, instead.

destroy() None[source]

Destroy the room.

Calling this on a non-existing room is a no-op.

property exists: bool

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 JID’s to invite into the room.

join(username: str | None = None, password: str | None = None) None[source]

Join the room.

If the room does not exist yet, this will automatically call create() on it first.

property joined: bool

Boolean indicating whether this room has already been joined.

Getter:

Returns True if the room has been joined, False otherwise.

leave(reason: str | None = None) None[source]

Leave the room.

Parameters:

reason – An optional string explaining the reason for leaving the room

property occupants: List[XMPPRoomOccupant]

The room’s occupants.

Getter:

Returns a list of MUCOccupant instances.

Raises:

MUCNotJoinedError if the room has not yet been joined.

property topic: str | None

The room topic.

Getter:

Returns the topic (a string) if one is set, None if no topic has been set at all.

Raises:

RoomNotJoinedError if the room has not yet been joined.

class errbot.backends.xmpp.XMPPRoomOccupant(node, domain, resource, room)[source]

Bases: XMPPPerson, RoomOccupant

__init__(node, domain, resource, room)[source]
property nick: str
Returns:

a backend specific nick returning the nickname of this person if available.

property person
Returns:

a backend specific unique identifier representing the person you are talking to.

property real_jid: str

The JID of the room occupant, they used to login. Will only work if the errbot is moderator in the MUC or it is not anonymous.

property room: XMPPRoom

Some backends have the full name of a user.

Returns:

the fullname of this user if available.

errbot.backends.xmpp.split_identifier(txtrep: str) Tuple[str, str, str][source]