[AntiAbuse] Add !listignore, fix a bug

master
sfan5 2014-06-22 11:55:42 +02:00
parent 418e72a19d
commit 70e868d934
2 changed files with 14 additions and 5 deletions

View File

@ -1,6 +1,6 @@
Commands
========
Required arguments are enclosed in { and }, optional arguments are enclosed in \[ and \]
Required arguments are enclosed in { and }, optional arguments are enclosed in [ and ]
<i>$botname</i> refers to the name of the IRC bot, e.g. MinetestBot
@ -16,6 +16,7 @@ Required arguments are enclosed in { and }, optional arguments are enclosed in \
<tr> <td><b>antiabuse.py</b></td> <td></td> <td></td> </tr>
<tr> <td>!ignore {user}</td> <td>Add user to ignore list</td> <td><i>Admins</i></td> </tr>
<tr> <td>!unignore {user}</td> <td>Remove user from ignore list</td> <td><i>Admins</i></td> </tr>
<tr> <td>!listignore</td> <td>List all ignored users</td> <td><i>Admins</i></td> </tr>
<tr> <td><b>calc.py</b></td> <td></td> <td></td> </tr>
<tr> <td>!c {expression}</td> <td>Calculate expression</td> <td>Anyone</td> </tr>
<tr> <td><b>chop.py</b></td> <td></td> <td></td> </tr>

View File

@ -6,8 +6,8 @@ Copyright 2012, sfan5
import time, sqlite3
antiabuse = {}
antiabuse["timeout"] = {}
antiabuse["ignorelist"] = []
antiabuse["cooldown_l"] = {}
antiabuse["cooldown"] = 3 # seconds
def aa_hook(phenny, input):
@ -21,11 +21,11 @@ def aa_hook(phenny, input):
# Cooldown
try:
ot = antiabuse["cooldown"][input.nick]
ot = antiabuse["cooldown_l"][input.nick]
except:
ot = 0
antiabuse["cooldown"][input.nick] = time.time()
if antiabuse["cooldown"][input.nick] - antiabuse["cooldown"] < ot:
antiabuse["cooldown_l"][input.nick] = time.time()
if antiabuse["cooldown_l"][input.nick] - antiabuse["cooldown"] < ot:
return True # abort command
pass
@ -82,6 +82,14 @@ def unignore(phenny, input):
unignore.commands = ['unignore']
unignore.priority = 'high'
def listignore(phenny, input):
if not input.admin:
return
phenny.reply(', '.join(antiabuse['ignorelist']))
listignore.commands = ['listignore']
listignore.priority = 'high'
db = sqlite3.connect("antiabuse.sqlite")
c = db.cursor()
c.execute('''CREATE TABLE IF NOT EXISTS ignore (nick text)''')