2022-07-21 12:40:09 +00:00
|
|
|
import main
|
2022-09-05 06:20:30 +00:00
|
|
|
from yaml import dump
|
2022-07-21 12:40:09 +00:00
|
|
|
|
2022-07-21 12:39:41 +00:00
|
|
|
|
2020-11-01 19:54:24 +00:00
|
|
|
class BlacklistCommand:
|
|
|
|
def __init__(self, *args):
|
|
|
|
self.blacklist(*args)
|
|
|
|
|
2022-09-05 06:20:30 +00:00
|
|
|
def blacklist(
|
|
|
|
self, addr, authed, data, obj, spl, success, failure, info, incUsage, length
|
|
|
|
):
|
2020-11-01 19:54:24 +00:00
|
|
|
if authed:
|
|
|
|
if length == 1:
|
|
|
|
info(dump(main.blacklist))
|
|
|
|
return
|
|
|
|
elif length == 4:
|
|
|
|
if spl[1] == "add":
|
|
|
|
if spl[2] in main.blacklist.keys():
|
|
|
|
main.blacklist[spl[2]].append(spl[3])
|
|
|
|
else:
|
|
|
|
main.blacklist[spl[2]] = [spl[3]]
|
|
|
|
success("Blacklisted %s on %s" % (spl[3], spl[2]))
|
|
|
|
main.saveConf("blacklist")
|
|
|
|
return
|
|
|
|
elif spl[1] == "del":
|
|
|
|
if spl[2] in main.blacklist.keys():
|
|
|
|
if spl[3] in main.blacklist[spl[2]]:
|
|
|
|
main.blacklist[spl[2]].remove(spl[3])
|
|
|
|
if len(main.blacklist[spl[2]]) == 0:
|
|
|
|
del main.blacklist[spl[2]]
|
|
|
|
else:
|
|
|
|
failure("Not in list: %s" % spl[3])
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
failure("No such entry: %s" % spl[2])
|
|
|
|
return
|
|
|
|
success("Removed blacklist %s on %s" % (spl[3], spl[2]))
|
|
|
|
main.saveConf("blacklist")
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
incUsage("blacklist")
|
|
|
|
return
|
|
|
|
else:
|
|
|
|
incUsage(None)
|