[AntiAbuse] Show ignore list over multiple lines
This commit is contained in:
parent
3b0a9bc2c1
commit
b0b742ac2f
41
antiabuse.py
41
antiabuse.py
@ -21,7 +21,7 @@ def api_ignore(mask):
|
|||||||
|
|
||||||
def api_unignore(mask):
|
def api_unignore(mask):
|
||||||
if not mask in antiabuse["ignorelist"]:
|
if not mask in antiabuse["ignorelist"]:
|
||||||
return
|
return False
|
||||||
antiabuse['ignorelist'].remove(mask)
|
antiabuse['ignorelist'].remove(mask)
|
||||||
db = sqlite3.connect("antiabuse.sqlite")
|
db = sqlite3.connect("antiabuse.sqlite")
|
||||||
c = db.cursor()
|
c = db.cursor()
|
||||||
@ -29,6 +29,7 @@ def api_unignore(mask):
|
|||||||
c.close()
|
c.close()
|
||||||
db.commit()
|
db.commit()
|
||||||
db.close()
|
db.close()
|
||||||
|
return True
|
||||||
|
|
||||||
def api_get_ignorelist():
|
def api_get_ignorelist():
|
||||||
return antiabuse["ignorelist"]
|
return antiabuse["ignorelist"]
|
||||||
@ -39,7 +40,7 @@ class SomeObject(object):
|
|||||||
antiabuse_api = SomeObject()
|
antiabuse_api = SomeObject()
|
||||||
antiabuse_api.ignore = api_ignore
|
antiabuse_api.ignore = api_ignore
|
||||||
antiabuse_api.unignore = api_unignore
|
antiabuse_api.unignore = api_unignore
|
||||||
antiabuse_api.get_ignorelsit = api_get_ignorelist
|
antiabuse_api.get_ignorelist = api_get_ignorelist
|
||||||
|
|
||||||
_export = {
|
_export = {
|
||||||
'antiabuse': antiabuse_api,
|
'antiabuse': antiabuse_api,
|
||||||
@ -84,8 +85,11 @@ def ignore(phenny, input):
|
|||||||
if not input.admin:
|
if not input.admin:
|
||||||
return
|
return
|
||||||
arg = hmasktrans(input.group(2).strip())
|
arg = hmasktrans(input.group(2).strip())
|
||||||
api_ignore(arg)
|
r = api_ignore(arg)
|
||||||
phenny.reply("'%s' added to ignore list." % arg)
|
if r:
|
||||||
|
phenny.reply("'%s' added to ignore list." % arg)
|
||||||
|
else:
|
||||||
|
phenny.reply("'%s' not in ignore list." % arg)
|
||||||
|
|
||||||
ignore.commands = ['ignore']
|
ignore.commands = ['ignore']
|
||||||
ignore.priority = 'high'
|
ignore.priority = 'high'
|
||||||
@ -100,13 +104,34 @@ def unignore(phenny, input):
|
|||||||
unignore.commands = ['unignore']
|
unignore.commands = ['unignore']
|
||||||
unignore.priority = 'high'
|
unignore.priority = 'high'
|
||||||
|
|
||||||
|
def limjoin(ent, j, lim):
|
||||||
|
o = []
|
||||||
|
i = 0
|
||||||
|
while True:
|
||||||
|
if i == len(ent):
|
||||||
|
break
|
||||||
|
s = ""
|
||||||
|
while True:
|
||||||
|
if i == len(ent) or len(s) + len(ent[i]) > lim:
|
||||||
|
break
|
||||||
|
s += ent[i]
|
||||||
|
i += 1
|
||||||
|
s += j
|
||||||
|
o.append(s)
|
||||||
|
if len(o) > 0:
|
||||||
|
for i in range(len(o)):
|
||||||
|
o[i] = o[i][:-len(j)] # Cut off the delimiter
|
||||||
|
return o
|
||||||
|
|
||||||
|
|
||||||
def listignore(phenny, input):
|
def listignore(phenny, input):
|
||||||
if not input.admin:
|
if not input.admin:
|
||||||
return
|
return
|
||||||
s = ', '.join(antiabuse['ignorelist'])
|
if len(antiabuse['ignorelist']) == 0:
|
||||||
if s == "":
|
return phenny.reply("Ignore list empty.")
|
||||||
s = "Ignore list empty."
|
l = limjoin(antiabuse['ignorelist'], ', ', 400)
|
||||||
phenny.reply(s)
|
for s in l:
|
||||||
|
phenny.reply(s)
|
||||||
|
|
||||||
listignore.commands = ['listignore']
|
listignore.commands = ['listignore']
|
||||||
listignore.priority = 'high'
|
listignore.priority = 'high'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user