Update sweebot.py
All checks were successful
Check syntax / check (push) Successful in 9s

This commit is contained in:
Nova Cat 2024-12-28 18:27:44 -08:00
parent b8c0350c1d
commit e31069ccb7

View file

@ -65,11 +65,14 @@ class config:
def __init__(self): def __init__(self):
self.conn = sqlite3.connect(environ["SBconfig"]) self.conn = sqlite3.connect(environ["SBconfig"])
self.database = self.conn.cursor() self.database = self.conn.cursor()
def perms(self, cloak: str): def perms(self, mask: str):
try: try:
self.database.execute(f"SELECT * FROM users WHERE username = ?;", [cloak]) self.database.execute(f"SELECT * FROM users;")
output = self.database.fetchall() output = self.database.fetchall()
return output[0][1] for i in output:
if re.match(i[0].replace("*", ".+"), mask):
return i[1]
return ''
except: except:
print(traceback.format_exc()) print(traceback.format_exc())
return '' return ''
@ -329,8 +332,9 @@ while True:
channel = text.split("PRIVMSG")[1].split(" ")[1] channel = text.split("PRIVMSG")[1].split(" ")[1]
nick = text.split(" ")[0][1:].split("!")[0] nick = text.split(" ")[0][1:].split("!")[0]
username = text.split(" ")[0][1:].split("@")[1] username = text.split(" ")[0][1:].split("@")[1]
mask = text.split(" ")[0][1:]
try: try:
perms = sbconfig.perms(username) perms = sbconfig.perms(mask)
except: except:
perms = "" perms = ""
print(command) print(command)
@ -442,9 +446,9 @@ while True:
elif command[0] == "$perms": elif command[0] == "$perms":
if len(command) == 2: if len(command) == 2:
if sbconfig.perms(command[1]) != "": if sbconfig.perms(command[1]) != "":
irc.send_irc(channel, nick + ": permissions of cloak " + command[1] + ": " + sbconfig.perms(command[1])) irc.send_irc(channel, nick + ": permissions of user " + command[1] + ": " + sbconfig.perms(command[1]))
else: else:
irc.send_irc(channel, nick + ": The cloak " + command[1] + " Doesn't have permissions.") irc.send_irc(channel, nick + ": The user wildcard at " + command[1] + " Doesn't have permissions.")
else: else:
if perms != "": if perms != "":
irc.send_irc(channel, nick + ": " + perms) irc.send_irc(channel, nick + ": " + perms)