errbot.backends.text module¶
-
class
errbot.backends.text.
TextBackend
(config)[source]¶ Bases:
errbot.core.ErrBot
-
build_identifier
(text_representation: str) → Union[errbot.backends.text.TextOccupant, errbot.backends.text.TextRoom, errbot.backends.text.TextPerson][source]¶
-
build_reply
(msg: errbot.backends.base.Message, text: str = None, private: bool = False, threaded: bool = 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.
-
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: str) → errbot.backends.text.TextRoom[source]¶ Query a room for information.
Return type: TextRoom
Parameters: room ( str
) – The room to query for.Returns: An instance of Room
.
-
rooms
() → List[errbot.backends.text.TextRoom][source]¶ Return a list of rooms the bot is currently in.
Returns: A list of Room
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
(user: errbot.backends.base.Identifier, fsource: BinaryIO, name: str = None, size: int = None, stream_type: str = None) → errbot.backends.base.Stream[source]¶ Starts a file transfer. For Slack, the size and stream_type are unsupported
Return type: Parameters: - user (
Identifier
) – is the identifier of the person you want to send it to. - fsource (
BinaryIO
) – is a file object you want to send. - name (
str
) – is an optional filename for it. - size (
int
) – not supported in Slack backend - stream_type (
str
) – not supported in Slack backend
Return Stream: object on which you can monitor the progress of it.
- user (
-
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.text.
TextOccupant
(person, room)[source]¶ Bases:
errbot.backends.text.TextPerson
,errbot.backends.base.RoomOccupant
-
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.
-
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.
-
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.
TextRoom
(name: str, bot: errbot.core.ErrBot)[source]¶ Bases:
errbot.backends.base.Room
-
__init__
(name: str, bot: errbot.core.ErrBot)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
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: Optional[str] = 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 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.
-