errbot.backends.text module

class errbot.backends.text.TextBackend(config)[source]

Bases: errbot.core.ErrBot

__init__(config)[source]

Those arguments will be directly those put in BOT_IDENTITY

add_reaction(msg: errbot.backends.base.Message, reaction: str) → None[source]
build_identifier(text_representation)[source]
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 room to query for.
Returns:An instance of Room.
readline_support()[source]
remove_reaction(msg: errbot.backends.base.Message, reaction: str) → None[source]
rooms

Return a list of rooms the bot is currently in.

Returns:A list of Room 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() and disconnect_callback() themselves after connection/disconnection.

class errbot.backends.text.TextOccupant(person, room)[source]

Bases: errbot.backends.text.TextPerson, errbot.backends.base.RoomOccupant

__init__(person, room)[source]

Initialize self. See help(type(self)) for accurate signature.

room

Some backends have the full name of a user.

Returns:the fullname of this user if available.
class errbot.backends.text.TextPerson(person, client=None, nick=None, fullname=None)[source]

Bases: errbot.backends.base.Person

Simple Person implementation which represents users as simple text strings.

__init__(person, client=None, nick=None, fullname=None)[source]

Initialize self. See help(type(self)) for accurate signature.

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.
nick
Returns:a backend specific nick returning the nickname of this person if available.
person
Returns:a backend specific unique identifier representing the person you are talking to.
class errbot.backends.text.TextPlugin(bot, name=None)[source]

Bases: errbot.botplugin.BotPlugin

Internal to TextBackend.

asadmin(msg, args)[source]

This puts you in a 1-1 chat with the bot.

asuser(msg, args)[source]

This puts you in a room with the bot. You can specify a name otherwise it will default to ‘luser’.

inperson(msg, args)[source]

This puts you in a 1-1 chat with the bot.

inroom(msg, args)[source]

This puts you in a room with the bot.

class errbot.backends.text.TextRoom(name, bot)[source]

Bases: errbot.backends.base.Room

__init__(name, bot)[source]

Initialize self. See help(type(self)) for accurate signature.

create()[source]

Create the room.

Calling this on an already existing room is a no-op.

destroy()[source]

Destroy the room.

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

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 identifiers 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 occupant identities.
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.

Note

Back-ends may return an empty string rather than None when no topic has been set as a network may not differentiate between no topic and an empty topic.

Raises:

MUCNotJoinedError if the room has not yet been joined.

errbot.backends.text.borderless_ansi()[source]

This makes a converter from markdown to ansi (console) format. It can be called like this: from errbot.rendering import ansi md_converter = ansi() # you need to cache the converter

ansi_txt = md_converter.convert(md_txt)