diff --git a/CHANGELOG.md b/CHANGELOG.md index e5b93a1..5ee8366 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # xbotlib x.x.x (UNRELEASED) +# xbotlib 0.11.0 (2021-01-16) + +- Allow to configure avatar from configuration file and environment + # xbotlib 0.10.0 (2021-01-16) - Implement Redis based storage ([#21](https://git.autonomic.zone/decentral1se/xbotlib/issues/21)) diff --git a/README.md b/README.md index e83babd..a2453a9 100644 --- a/README.md +++ b/README.md @@ -156,6 +156,7 @@ deployments. - **XBOT_ACCOUNT**: The bot account - **XBOT_PASSWORD**: The bot password - **XBOT_NICK**: The bot nickname +- **XBOT_AVATAR**: The bot avatar icon ## Deploy your bots diff --git a/xbotlib.py b/xbotlib.py index 129e897..d636fa6 100644 --- a/xbotlib.py +++ b/xbotlib.py @@ -200,6 +200,7 @@ class Bot(ClientXMPP): account = input("Account: ") password = getpass("Password: ") nick = input("Nickname: ") + avatar = input("Avatar: ") config = ConfigParser() config[self.name] = {"account": account, "password": password} @@ -207,6 +208,9 @@ class Bot(ClientXMPP): if nick: config[self.name]["nick"] = nick + if avatar: + config[self.name]["avatar"] = avatar + with open(self.CONFIG_FILE, "w") as file_handle: config.write(file_handle) @@ -225,6 +229,11 @@ class Bot(ClientXMPP): nick = ( self.args.nick or self.config.nick or environ.get("XBOT_NICK", None) ) + avatar = ( + self.args.avatar + or self.config.avatar + or environ.get("XBOT_AVATAR", None) + ) if not account: self.log.error("Unable to discover account") @@ -241,8 +250,7 @@ class Bot(ClientXMPP): self.account = account self.password = password self.nick = nick - - self.avatar = self.args.avatar + self.avatar = avatar def register_xmpp_event_handlers(self): """Register functions against specific XMPP event handlers."""