Add global AntiAbuse module, remove badnick list from search.py
parent
8b2448105f
commit
45cfd0fb2e
|
@ -0,0 +1,56 @@
|
|||
#!/usr/bin/env python
|
||||
"""
|
||||
antiabuse.py - Phenny AntiAbuse Module
|
||||
Copyright 2012, Sfan5
|
||||
"""
|
||||
import time
|
||||
|
||||
antiabuse = {}
|
||||
antiabuse["timeout"] = {}
|
||||
antiabuse["ignorelist"] = ["KikaRz","LandMine","LandMineMT","markveidemanis"]
|
||||
antiabuse["s_timeout"] = 3 # in Seconds
|
||||
antiabuse["f_set"] = False
|
||||
|
||||
def aa_hook(phenny, input):
|
||||
if input.admin or input.owner:
|
||||
return False
|
||||
#Ignore-List check
|
||||
if input.nick in antiabuse["ignorelist"]:
|
||||
return True # abort command
|
||||
#Timeout check
|
||||
try:
|
||||
ot = antiabuse["timeout"][input.nick]
|
||||
except:
|
||||
ot = 0
|
||||
antiabuse["timeout"][input.nick] = time.time()
|
||||
if antiabuse["timeout"][input.nick] - antiabuse["s_timeout"] < ot:
|
||||
return True # abort command
|
||||
|
||||
return False
|
||||
aa_hook.event = 'THISWONTHAPPEN'
|
||||
aa_hook.priority = 'high'
|
||||
aa_hook.rule = r'h^'
|
||||
#Warning: Uses a very very dirty hack to achieve that other modules can access this function
|
||||
|
||||
|
||||
def ignore(phenny, input):
|
||||
if not input.admin or not input.owner: return
|
||||
arg = input.group(2)
|
||||
antiabuse["ignorelist"].append(arg)
|
||||
phenny.reply("'%s' added to ignore list." % arg)
|
||||
|
||||
ignore.commands = ['ignore']
|
||||
ignore.priority = 'high'
|
||||
|
||||
def unignore(phenny, input):
|
||||
if not input.admin or not input.owner: return
|
||||
arg = input.group(2)
|
||||
try:
|
||||
antiabuse["ignorelist"].remove(arg)
|
||||
except:
|
||||
return
|
||||
phenny.reply("'%s' removed from ignore list." % arg)
|
||||
|
||||
unignore.commands = ['unignore']
|
||||
unignore.priority = 'high'
|
||||
|
4
calc.py
4
calc.py
|
@ -30,6 +30,10 @@ subs = [
|
|||
|
||||
def c(phenny, input):
|
||||
"""Google calculator."""
|
||||
for x in phenny.bot.commands["high"].values():
|
||||
if x[0].__name__ == "aa_hook":
|
||||
if x[0](phenny, input):
|
||||
return # Abort function
|
||||
if not input.group(2):
|
||||
return phenny.reply("Nothing to calculate.")
|
||||
q = input.group(2).encode('utf-8')
|
||||
|
|
|
@ -61,6 +61,10 @@ def formatirc_user_a(arr):
|
|||
return formartirc_user(arr[0],arr[1],arr[2],arr[3],arr[4],with_userid=True)
|
||||
|
||||
def search_forumuser(phenny, input):
|
||||
for x in phenny.bot.commands["high"].values():
|
||||
if x[0].__name__ == "aa_hook":
|
||||
if x[0](phenny, input):
|
||||
return # Abort function
|
||||
arg = input.group(2)
|
||||
if not arg:
|
||||
return phenny.reply("Give me a username")
|
||||
|
|
4
ping.py
4
ping.py
|
@ -8,6 +8,10 @@ About: http://inamidst.com/phenny/
|
|||
import random
|
||||
|
||||
def hello(phenny, input):
|
||||
for x in phenny.bot.commands["high"].values():
|
||||
if x[0].__name__ == "aa_hook":
|
||||
if x[0](phenny, input):
|
||||
return # Abort function
|
||||
greeting = random.choice(('Hi', 'Hey', 'Hello'))
|
||||
punctuation = random.choice(('', '!'))
|
||||
phenny.say(greeting + ' ' + input.nick + punctuation)
|
||||
|
|
44
rutils.py
44
rutils.py
|
@ -7,6 +7,10 @@ import base64, binascii
|
|||
|
||||
def rev(phenny, input):
|
||||
"""reverse string"""
|
||||
for x in phenny.bot.commands["high"].values():
|
||||
if x[0].__name__ == "aa_hook":
|
||||
if x[0](phenny, input):
|
||||
return # Abort function
|
||||
if not input.group(2):
|
||||
return phenny.reply("Nothing to reverse.")
|
||||
q = input.group(2).encode('utf-8')
|
||||
|
@ -21,6 +25,10 @@ rev.priority = 'low'
|
|||
|
||||
def b64e(phenny, input):
|
||||
"""base64 encode"""
|
||||
for x in phenny.bot.commands["high"].values():
|
||||
if x[0].__name__ == "aa_hook":
|
||||
if x[0](phenny, input):
|
||||
return # Abort function
|
||||
if not input.group(2):
|
||||
return phenny.reply("Nothing to encode.")
|
||||
q = input.group(2).encode('utf-8')
|
||||
|
@ -34,6 +42,10 @@ b64e.priority = 'low'
|
|||
|
||||
def b64d(phenny, input):
|
||||
"""base64 decode"""
|
||||
for x in phenny.bot.commands["high"].values():
|
||||
if x[0].__name__ == "aa_hook":
|
||||
if x[0](phenny, input):
|
||||
return # Abort function
|
||||
if not input.group(2):
|
||||
return phenny.reply("Nothing to decode.")
|
||||
q = input.group(2).encode('utf-8')
|
||||
|
@ -47,6 +59,10 @@ b64d.priority = 'low'
|
|||
|
||||
def b32e(phenny, input):
|
||||
"""base32 encode"""
|
||||
for x in phenny.bot.commands["high"].values():
|
||||
if x[0].__name__ == "aa_hook":
|
||||
if x[0](phenny, input):
|
||||
return # Abort function
|
||||
if not input.group(2):
|
||||
return phenny.reply("Nothing to encode.")
|
||||
q = input.group(2).encode('utf-8')
|
||||
|
@ -60,6 +76,10 @@ b32e.priority = 'low'
|
|||
|
||||
def b32d(phenny, input):
|
||||
"""base32 decode"""
|
||||
for x in phenny.bot.commands["high"].values():
|
||||
if x[0].__name__ == "aa_hook":
|
||||
if x[0](phenny, input):
|
||||
return # Abort function
|
||||
if not input.group(2):
|
||||
return phenny.reply("Nothing to decode.")
|
||||
q = input.group(2).encode('utf-8')
|
||||
|
@ -73,6 +93,10 @@ b32d.priority = 'low'
|
|||
|
||||
def b16e(phenny, input):
|
||||
"""base16 encode"""
|
||||
for x in phenny.bot.commands["high"].values():
|
||||
if x[0].__name__ == "aa_hook":
|
||||
if x[0](phenny, input):
|
||||
return # Abort function
|
||||
if not input.group(2):
|
||||
return phenny.reply("Nothing to encode.")
|
||||
q = input.group(2).encode('utf-8')
|
||||
|
@ -99,6 +123,10 @@ b16d.priority = 'low'
|
|||
|
||||
def crc32(phenny, input):
|
||||
"""crc32 hash"""
|
||||
for x in phenny.bot.commands["high"].values():
|
||||
if x[0].__name__ == "aa_hook":
|
||||
if x[0](phenny, input):
|
||||
return # Abort function
|
||||
if not input.group(2):
|
||||
return phenny.reply("Nothing to hash.")
|
||||
q = input.group(2).encode('utf-8')
|
||||
|
@ -110,6 +138,10 @@ crc32.priority = 'low'
|
|||
|
||||
def hex_(phenny, input):
|
||||
"""hexlify http://docs.python.org/2/library/binascii.html#binascii.hexlify"""
|
||||
for x in phenny.bot.commands["high"].values():
|
||||
if x[0].__name__ == "aa_hook":
|
||||
if x[0](phenny, input):
|
||||
return # Abort function
|
||||
if not input.group(2):
|
||||
return phenny.reply("Nothing to hexlify.")
|
||||
q = input.group(2).encode('utf-8')
|
||||
|
@ -123,6 +155,10 @@ hex_.priority = 'low'
|
|||
|
||||
def unhex(phenny, input):
|
||||
"""unhexlify http://docs.python.org/2/library/binascii.html#binascii.unhexlify"""
|
||||
for x in phenny.bot.commands["high"].values():
|
||||
if x[0].__name__ == "aa_hook":
|
||||
if x[0](phenny, input):
|
||||
return # Abort function
|
||||
if not input.group(2):
|
||||
return phenny.reply("Nothing to unhexlify.")
|
||||
q = input.group(2).encode('utf-8')
|
||||
|
@ -136,6 +172,10 @@ unhex.priority = 'low'
|
|||
|
||||
def uuencode(phenny, input):
|
||||
"""uuencode"""
|
||||
for x in phenny.bot.commands["high"].values():
|
||||
if x[0].__name__ == "aa_hook":
|
||||
if x[0](phenny, input):
|
||||
return # Abort function
|
||||
if not input.group(2):
|
||||
return phenny.reply("Nothing to encode.")
|
||||
q = input.group(2).encode('utf-8')
|
||||
|
@ -149,6 +189,10 @@ uuencode.priority = 'low'
|
|||
|
||||
def uudecode(phenny, input):
|
||||
"""uudecode"""
|
||||
for x in phenny.bot.commands["high"].values():
|
||||
if x[0].__name__ == "aa_hook":
|
||||
if x[0](phenny, input):
|
||||
return # Abort function
|
||||
if not input.group(2):
|
||||
return phenny.reply("Nothing to decode.")
|
||||
q = input.group(2).encode('utf-8')
|
||||
|
|
17
search.py
17
search.py
|
@ -11,7 +11,6 @@ http://inamidst.com/phenny/
|
|||
import web, re
|
||||
|
||||
search_badwords = ["porn","p0rn","pr0n","pron","redtube","sex","pussy","hot","weed","smoking","drug","penis","vagina"] #Thank KikaRz, LandMine and RagnarLaud for this
|
||||
search_badnicks = ["KikaRz","LandMine","LandMineMT"]
|
||||
|
||||
class Grab(web.urllib.URLopener):
|
||||
def __init__(self, *args):
|
||||
|
@ -59,6 +58,10 @@ def formatnumber(n):
|
|||
|
||||
def g(phenny, input):
|
||||
"""Queries Google for the specified input."""
|
||||
for x in phenny.bot.commands["high"].values():
|
||||
if x[0].__name__ == "aa_hook":
|
||||
if x[0](phenny, input):
|
||||
return # Abort function
|
||||
query = input.group(2)
|
||||
if not query:
|
||||
return phenny.reply('.g what?')
|
||||
|
@ -66,10 +69,6 @@ def g(phenny, input):
|
|||
if bw in query:
|
||||
print("[LOG]: %s queried Google Result for '%s' | DENIED: Badword" % (input.nick,query))
|
||||
return phenny.reply("Gross!")
|
||||
for bn in search_badnicks:
|
||||
if bn in input.nick:
|
||||
print("[LOG]: %s queried Google Result for '%s' | DENIED: Badnick" % (input.nick,query))
|
||||
return phenny.reply("Nope!")
|
||||
query = query.encode('utf-8')
|
||||
print("[LOG]: %s queried Google Result for '%s'" % (input.nick,query))
|
||||
uri = google_search(query)
|
||||
|
@ -85,6 +84,10 @@ g.priority = 'high'
|
|||
g.example = '.g minetest'
|
||||
|
||||
def gc(phenny, input):
|
||||
for x in phenny.bot.commands["high"].values():
|
||||
if x[0].__name__ == "aa_hook":
|
||||
if x[0](phenny, input):
|
||||
return # Abort function
|
||||
if not input.group(2):
|
||||
return phenny.reply("No query term.")
|
||||
query = input.group(2).encode('utf-8')
|
||||
|
@ -93,10 +96,6 @@ def gc(phenny, input):
|
|||
if bw in query:
|
||||
print("[LOG]: %s queried Google Result Number for '%s' | DENIED: Badword" % (input.nick,query))
|
||||
return phenny.reply("Gross!")
|
||||
for bn in search_badnicks:
|
||||
if bn in input.nick:
|
||||
print("[LOG]: %s queried Google Result Number for '%s' | DENIED: Badnick" % (input.nick,query))
|
||||
return phenny.reply("Nope!")
|
||||
print("[LOG]: %s queried Google Result Number for '%s'" % (input.nick,query))
|
||||
if result:
|
||||
phenny.say(query + ": " + result)
|
||||
|
|
4
seen.py
4
seen.py
|
@ -13,6 +13,10 @@ from tools import deprecated
|
|||
|
||||
def seen(phenny, input):
|
||||
""".seen <nick> - Reports when <nick> was last seen."""
|
||||
for x in phenny.bot.commands["high"].values():
|
||||
if x[0].__name__ == "aa_hook":
|
||||
if x[0](phenny, input):
|
||||
return # Abort function
|
||||
nick = input.group(2)
|
||||
if not nick:
|
||||
return phenny.reply("Need a nickname to search for...")
|
||||
|
|
|
@ -8,6 +8,10 @@ import web, math, random
|
|||
from xml.dom import minidom
|
||||
|
||||
def read_server():
|
||||
for x in phenny.bot.commands["high"].values():
|
||||
if x[0].__name__ == "aa_hook":
|
||||
if x[0](phenny, input):
|
||||
return # Abort function
|
||||
bytes = web.get("http://servers.minetest.ru/")
|
||||
shim = '<table>'
|
||||
shim2 = '</table>'
|
||||
|
|
|
@ -7,6 +7,10 @@ Copyright 2012, sfan5
|
|||
import socket, time
|
||||
|
||||
def serverup(phenny, input):
|
||||
for x in phenny.bot.commands["high"].values():
|
||||
if x[0].__name__ == "aa_hook":
|
||||
if x[0](phenny, input):
|
||||
return # Abort function
|
||||
arg = input.group(2)
|
||||
if not arg:
|
||||
return phenny.reply("Give me a Server Address")
|
||||
|
|
|
@ -6,6 +6,10 @@ Copyright 2013, sfan5
|
|||
import urllib
|
||||
|
||||
def shorten(phenny, input):
|
||||
for x in phenny.bot.commands["high"].values():
|
||||
if x[0].__name__ == "aa_hook":
|
||||
if x[0](phenny, input):
|
||||
return # Abort function
|
||||
arg = input.group(2)
|
||||
if not arg:
|
||||
arg = "" # Function continues and prints Help Message
|
||||
|
|
|
@ -69,6 +69,10 @@ def id_tweet(tid):
|
|||
return "Sorry, couldn't get a tweet from %s" % link
|
||||
|
||||
def twitter(phenny, input):
|
||||
for x in phenny.bot.commands["high"].values():
|
||||
if x[0].__name__ == "aa_hook":
|
||||
if x[0](phenny, input):
|
||||
return # Abort function
|
||||
arg = input.group(2)
|
||||
if not arg:
|
||||
return phenny.reply("Give me a link, a username, or a tweet id")
|
||||
|
|
|
@ -132,6 +132,10 @@ def wikipedia(term, language='en', last=False):
|
|||
return sentence + ' - ' + (wikiuri % (term))
|
||||
|
||||
def wik(phenny, input):
|
||||
for x in phenny.bot.commands["high"].values():
|
||||
if x[0].__name__ == "aa_hook":
|
||||
if x[0](phenny, input):
|
||||
return # Abort function
|
||||
origterm = input.groups()[1]
|
||||
if not origterm:
|
||||
return phenny.say('Perhaps you meant ".wik Zen"?')
|
||||
|
|
Loading…
Reference in New Issue