This commit is contained in:
parent
b8c0350c1d
commit
e31069ccb7
1 changed files with 10 additions and 6 deletions
16
sweebot.py
16
sweebot.py
|
@ -65,11 +65,14 @@ class config:
|
|||
def __init__(self):
|
||||
self.conn = sqlite3.connect(environ["SBconfig"])
|
||||
self.database = self.conn.cursor()
|
||||
def perms(self, cloak: str):
|
||||
def perms(self, mask: str):
|
||||
try:
|
||||
self.database.execute(f"SELECT * FROM users WHERE username = ?;", [cloak])
|
||||
self.database.execute(f"SELECT * FROM users;")
|
||||
output = self.database.fetchall()
|
||||
return output[0][1]
|
||||
for i in output:
|
||||
if re.match(i[0].replace("*", ".+"), mask):
|
||||
return i[1]
|
||||
return ''
|
||||
except:
|
||||
print(traceback.format_exc())
|
||||
return ''
|
||||
|
@ -329,8 +332,9 @@ while True:
|
|||
channel = text.split("PRIVMSG")[1].split(" ")[1]
|
||||
nick = text.split(" ")[0][1:].split("!")[0]
|
||||
username = text.split(" ")[0][1:].split("@")[1]
|
||||
mask = text.split(" ")[0][1:]
|
||||
try:
|
||||
perms = sbconfig.perms(username)
|
||||
perms = sbconfig.perms(mask)
|
||||
except:
|
||||
perms = ""
|
||||
print(command)
|
||||
|
@ -442,9 +446,9 @@ while True:
|
|||
elif command[0] == "$perms":
|
||||
if len(command) == 2:
|
||||
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:
|
||||
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:
|
||||
if perms != "":
|
||||
irc.send_irc(channel, nick + ": " + perms)
|
||||
|
|
Loading…
Reference in a new issue