Skip to content

Commit

Permalink
refactor: Set default backend to Text (#1522)
Browse files Browse the repository at this point in the history
* refactor: change default backend to Text

* fix: setting default list of room occupants

This should address issue #1285

* docs: Add backend change to CHANGES
  • Loading branch information
sijis authored Jul 16, 2021
1 parent 574f66d commit b846d1a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
v6.1.9 (unreleased)
-------------------

features:
- core: set default backend to Text (#1522)

fixes:

- core: success handling for update_repos (#1520)
Expand Down
11 changes: 9 additions & 2 deletions errbot/backends/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,19 @@ def __init__(self, name, bot):
self.name = name
self._bot = bot

# get the bot username
bot_config = self._bot.bot_config
default_bot_name = "@errbot"
if hasattr(bot_config, "BOT_IDENTITY"):
bot_name = bot_config.BOT_IDENTITY.get("username", default_bot_name)
else:
bot_name = default_bot_name

# fill up the room with a coherent set of identities.
self._occupants = [
TextOccupant("somebody", self),
TextOccupant(TextPerson(bot.bot_config.BOT_ADMINS[0]), self),
TextOccupant(bot.bot_identifier, self),
TextOccupant(bot_name, self),
]

def join(self, username=None, password=None):
Expand Down Expand Up @@ -426,7 +434,6 @@ def query_room(self, room):
self._rooms.insert(0, self._rooms.pop(self._rooms.index(text_room)))
return text_room

@property
def rooms(self):
return self._rooms

Expand Down
10 changes: 6 additions & 4 deletions errbot/config-template.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
# 'Telegram' - cloud-based mobile and desktop messaging app with a focus
# on security and speed. (https://telegram.org/)

# BACKEND = 'XMPP' # defaults to XMPP
# BACKEND = 'Text' # defaults to Text

# STORAGE selection.
# This configures the type of persistence you wish to use Errbot with.
Expand Down Expand Up @@ -154,9 +154,11 @@

# The identity, or credentials, used to connect to a server
BOT_IDENTITY = {
# XMPP (Jabber) mode
"username": "err@localhost", # The JID of the user you have created for the bot
"password": "changeme", # The corresponding password for this user
## Text mode
"username": "@errbot", # The name for the bot
## XMPP (Jabber) mode
# "username": "err@localhost", # The JID of the user you have created for the bot
# "password": "changeme", # The corresponding password for this user
# 'server': ('host.domain.tld',5222), # server override
## HipChat mode (Comment the above if using this mode)
# 'username': '[email protected]',
Expand Down

0 comments on commit b846d1a

Please sign in to comment.