Fix configuration

This commit is contained in:
Schimon Jehudah 2024-01-24 18:59:10 +00:00
parent 2f6b86522f
commit 8dcff0b2fe
3 changed files with 15 additions and 15 deletions

View file

@ -237,16 +237,16 @@ def main():
# Try configuration file # Try configuration file
values = get_value( values = get_value(
"accounts", "XMPP Client", [ "accounts", "XMPP Client", [
"alias", "username", "password", "hostname", "port"]) "alias", "jid", "password", "hostname", "port"])
alias = values[0] alias = values[0]
username = values[1] jid = values[1]
password = values[2] password = values[2]
hostname = values[3] hostname = values[3]
port = values[4] port = values[4]
# Use arguments if were given # Use arguments if were given
if args.jid: if args.jid:
username = args.jid jid = args.jid
if args.password: if args.password:
password = args.password password = args.password
if args.alias: if args.alias:
@ -257,8 +257,8 @@ def main():
port = args.port port = args.port
# Prompt for credentials if none were given # Prompt for credentials if none were given
if not username: if not jid:
username = input("Username: ") jid = input("JID: ")
if not password: if not password:
password = getpass("Password: ") password = getpass("Password: ")
if not alias: if not alias:
@ -266,9 +266,9 @@ def main():
match xmpp_type: match xmpp_type:
case "client": case "client":
JabberClient(username, password, alias) JabberClient(jid, password, alias)
case "component": case "component":
JabberComponent(username, password, hostname, port, alias) JabberComponent(jid, password, hostname, port, alias)
sys.exit(0) sys.exit(0)
if __name__ == "__main__": if __name__ == "__main__":

View file

@ -2,13 +2,15 @@
# and also from which accounts it receives instructions. # and also from which accounts it receives instructions.
[XMPP] [XMPP]
# JID of bot master
operator =
reconnect_timeout = 30 reconnect_timeout = 30
type = client type = client
#type = component #type = component
[XMPP Client] [XMPP Client]
alias = Slixfeed alias = Slixfeed
username = jid =
password = password =
# Hostname (also address) may be an i2p or onion hostname # Hostname (also address) may be an i2p or onion hostname
hostname = hostname =
@ -17,22 +19,20 @@ port =
[XMPP Component] [XMPP Component]
alias = Slixfeed alias = Slixfeed
username = jid =
password = password =
hostname = hostname =
port = port =
[XMPP Profile] [XMPP Profile]
name = Slixfeed name = Slixfeed
alias = Slixfeed nickname = Slixfeed
role = Syndication News Bot role = Syndication News Bot
organization = RSS Task Force organization = RSS Task Force
url = https://gitgud.io/sjehuda/slixfeed url = https://gitgud.io/sjehuda/slixfeed
description = XMPP news bot (supports Atom, JSON, RDF and RSS). description = XMPP news bot (supports Atom, JSON, RDF and RSS).
note = This is a syndication news bot powered by Slixfeed. note = This is a syndication news bot powered by Slixfeed.
birthday = 21 June 2022 birthday = 21 June 2022
# JID of bot master
operator =
[XMPP Proxy] [XMPP Proxy]
# NOTE You might want to consider support for socks4 too (this # NOTE You might want to consider support for socks4 too (this

View file

@ -202,7 +202,7 @@ async def message(self, message):
response = None response = None
match message_lowercase: match message_lowercase:
# case "breakpoint": # case "breakpoint":
# if jid == get_value("accounts", "XMPP Profile", "operator"): # if jid == get_value("accounts", "XMPP", "operator"):
# breakpoint() # breakpoint()
# print("task_manager[jid]") # print("task_manager[jid]")
# print(task_manager[jid]) # print(task_manager[jid])
@ -372,7 +372,7 @@ async def message(self, message):
send_reply_message(self, message, response) send_reply_message(self, message, response)
case _ if message_lowercase.startswith("bookmark -"): case _ if message_lowercase.startswith("bookmark -"):
if jid == get_value( if jid == get_value(
"accounts", "XMPP Profile", "operator"): "accounts", "XMPP", "operator"):
muc_jid = message_text[11:] muc_jid = message_text[11:]
await bookmark.remove(self, muc_jid) await bookmark.remove(self, muc_jid)
response = ( response = (
@ -386,7 +386,7 @@ async def message(self, message):
send_reply_message(self, message, response) send_reply_message(self, message, response)
case "bookmarks": case "bookmarks":
if jid == get_value( if jid == get_value(
"accounts", "XMPP Profile", "operator"): "accounts", "XMPP", "operator"):
response = await action.list_bookmarks(self) response = await action.list_bookmarks(self)
else: else:
response = ( response = (