Support conf/env avatar loading
This commit is contained in:
parent
47ba30fe28
commit
128d42c080
@ -1,5 +1,9 @@
|
|||||||
# xbotlib x.x.x (UNRELEASED)
|
# 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)
|
# xbotlib 0.10.0 (2021-01-16)
|
||||||
|
|
||||||
- Implement Redis based storage ([#21](https://git.autonomic.zone/decentral1se/xbotlib/issues/21))
|
- Implement Redis based storage ([#21](https://git.autonomic.zone/decentral1se/xbotlib/issues/21))
|
||||||
|
@ -156,6 +156,7 @@ deployments.
|
|||||||
- **XBOT_ACCOUNT**: The bot account
|
- **XBOT_ACCOUNT**: The bot account
|
||||||
- **XBOT_PASSWORD**: The bot password
|
- **XBOT_PASSWORD**: The bot password
|
||||||
- **XBOT_NICK**: The bot nickname
|
- **XBOT_NICK**: The bot nickname
|
||||||
|
- **XBOT_AVATAR**: The bot avatar icon
|
||||||
|
|
||||||
## Deploy your bots
|
## Deploy your bots
|
||||||
|
|
||||||
|
12
xbotlib.py
12
xbotlib.py
@ -200,6 +200,7 @@ class Bot(ClientXMPP):
|
|||||||
account = input("Account: ")
|
account = input("Account: ")
|
||||||
password = getpass("Password: ")
|
password = getpass("Password: ")
|
||||||
nick = input("Nickname: ")
|
nick = input("Nickname: ")
|
||||||
|
avatar = input("Avatar: ")
|
||||||
|
|
||||||
config = ConfigParser()
|
config = ConfigParser()
|
||||||
config[self.name] = {"account": account, "password": password}
|
config[self.name] = {"account": account, "password": password}
|
||||||
@ -207,6 +208,9 @@ class Bot(ClientXMPP):
|
|||||||
if nick:
|
if nick:
|
||||||
config[self.name]["nick"] = nick
|
config[self.name]["nick"] = nick
|
||||||
|
|
||||||
|
if avatar:
|
||||||
|
config[self.name]["avatar"] = avatar
|
||||||
|
|
||||||
with open(self.CONFIG_FILE, "w") as file_handle:
|
with open(self.CONFIG_FILE, "w") as file_handle:
|
||||||
config.write(file_handle)
|
config.write(file_handle)
|
||||||
|
|
||||||
@ -225,6 +229,11 @@ class Bot(ClientXMPP):
|
|||||||
nick = (
|
nick = (
|
||||||
self.args.nick or self.config.nick or environ.get("XBOT_NICK", None)
|
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:
|
if not account:
|
||||||
self.log.error("Unable to discover account")
|
self.log.error("Unable to discover account")
|
||||||
@ -241,8 +250,7 @@ class Bot(ClientXMPP):
|
|||||||
self.account = account
|
self.account = account
|
||||||
self.password = password
|
self.password = password
|
||||||
self.nick = nick
|
self.nick = nick
|
||||||
|
self.avatar = avatar
|
||||||
self.avatar = self.args.avatar
|
|
||||||
|
|
||||||
def register_xmpp_event_handlers(self):
|
def register_xmpp_event_handlers(self):
|
||||||
"""Register functions against specific XMPP event handlers."""
|
"""Register functions against specific XMPP event handlers."""
|
||||||
|
Reference in New Issue
Block a user