Implement channel blacklisting
This commit is contained in:
parent
cb21ad8fca
commit
1f178a20ed
|
@ -10,4 +10,5 @@ conf/network.dat
|
|||
conf/alias.json
|
||||
conf/irc.json
|
||||
conf/dist.sh
|
||||
conf/blacklist.json
|
||||
env/
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
import main
|
||||
from yaml import dump
|
||||
|
||||
class BlacklistCommand:
|
||||
def __init__(self, *args):
|
||||
self.blacklist(*args)
|
||||
|
||||
def blacklist(self, addr, authed, data, obj, spl, success, failure, info, incUsage, length):
|
||||
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)
|
|
@ -32,5 +32,6 @@
|
|||
"confirm": "confirm <network> <num> <token>",
|
||||
"pending": "pending [<network>]",
|
||||
"authcheck": "authcheck [<network>]",
|
||||
"recheckauth": "recheckauth [<network>]"
|
||||
"recheckauth": "recheckauth [<network>]",
|
||||
"blacklist": "blacklist <network> <channel>"
|
||||
}
|
||||
|
|
|
@ -181,6 +181,10 @@ class IRCBot(IRCClient):
|
|||
increment = 0.8
|
||||
for i in channels:
|
||||
if not i in self.channels:
|
||||
if self.net in main.blacklist.keys():
|
||||
if i in main.blacklist[self.net]:
|
||||
debug("Not joining blacklisted channel %s on %s - %i" % (i, self.net, self.num))
|
||||
continue
|
||||
debug(self.net, "-", self.num, ": joining", i, "in", sleeptime, "seconds")
|
||||
reactor.callLater(sleeptime, self.join, i)
|
||||
sleeptime += increment
|
||||
|
|
1
main.py
1
main.py
|
@ -24,6 +24,7 @@ filemap = {
|
|||
"aliasdata": ["aliasdata.json", "data for alias generation", "json"],
|
||||
"alias": ["alias.json", "provisioned alias data", "json"],
|
||||
"irc": ["irc.json", "IRC network definitions", "json"],
|
||||
"blacklist": ["blacklist.json", "IRC channel blacklist", "json"],
|
||||
|
||||
# Binary (pickle) configs
|
||||
"network": ["network.dat", "network list", "pickle"]
|
||||
|
|
Loading…
Reference in New Issue