forked from swee/MeowNex
Update cc/give
This commit is contained in:
parent
fdcd44ef16
commit
c605ac2f4c
1 changed files with 15 additions and 1 deletions
16
cc/give
16
cc/give
|
@ -1,14 +1,28 @@
|
||||||
from sys import argv
|
from sys import argv
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
import re
|
||||||
conn = sqlite3.connect("/home/sweebotirc/sbirc.db")
|
conn = sqlite3.connect("/home/sweebotirc/sbirc.db")
|
||||||
database = conn.cursor()
|
database = conn.cursor()
|
||||||
|
def getperms(self, mask: str):
|
||||||
|
try:
|
||||||
|
self.database.execute(f"SELECT * FROM users;")
|
||||||
|
output = self.database.fetchall()
|
||||||
|
for i in output:
|
||||||
|
if re.match(i[0].replace("*", ".+"), mask):
|
||||||
|
return i[1]
|
||||||
|
return ''
|
||||||
|
except:
|
||||||
|
print(traceback.format_exc())
|
||||||
|
return ''
|
||||||
if argv[2] == "full":
|
if argv[2] == "full":
|
||||||
if len(argv) == 5:
|
if len(argv) == 5:
|
||||||
if argv[3] == argv[2]:
|
if argv[3] == argv[2]:
|
||||||
print(argv[1] + ": You wanna give yourself permissions!?")
|
print(argv[1] + ": You wanna give yourself permissions!?")
|
||||||
else:
|
else:
|
||||||
perms = getperms(argv[3])
|
perms = getperms(argv[3])
|
||||||
if perms != "":
|
if argv[4] in perms:
|
||||||
|
print("The specified user already has these permissions.")
|
||||||
|
elif perms != "":
|
||||||
database.execute("UPDATE users SET perms = '" + perms + "," + argv[4] + "' WHERE username = '" + argv[3] + "';")
|
database.execute("UPDATE users SET perms = '" + perms + "," + argv[4] + "' WHERE username = '" + argv[3] + "';")
|
||||||
print(argv[1] + ": Successfully appended '" + argv[4] + "' to the permissions of " + argv[3])
|
print(argv[1] + ": Successfully appended '" + argv[4] + "' to the permissions of " + argv[3])
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue