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):
|
def c(phenny, input):
|
||||||
"""Google calculator."""
|
"""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):
|
if not input.group(2):
|
||||||
return phenny.reply("Nothing to calculate.")
|
return phenny.reply("Nothing to calculate.")
|
||||||
q = input.group(2).encode('utf-8')
|
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)
|
return formartirc_user(arr[0],arr[1],arr[2],arr[3],arr[4],with_userid=True)
|
||||||
|
|
||||||
def search_forumuser(phenny, input):
|
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)
|
arg = input.group(2)
|
||||||
if not arg:
|
if not arg:
|
||||||
return phenny.reply("Give me a username")
|
return phenny.reply("Give me a username")
|
||||||
|
|
6
ping.py
6
ping.py
|
@ -7,7 +7,11 @@ About: http://inamidst.com/phenny/
|
||||||
|
|
||||||
import random
|
import random
|
||||||
|
|
||||||
def hello(phenny, input):
|
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'))
|
greeting = random.choice(('Hi', 'Hey', 'Hello'))
|
||||||
punctuation = random.choice(('', '!'))
|
punctuation = random.choice(('', '!'))
|
||||||
phenny.say(greeting + ' ' + input.nick + punctuation)
|
phenny.say(greeting + ' ' + input.nick + punctuation)
|
||||||
|
|
44
rutils.py
44
rutils.py
|
@ -7,6 +7,10 @@ import base64, binascii
|
||||||
|
|
||||||
def rev(phenny, input):
|
def rev(phenny, input):
|
||||||
"""reverse string"""
|
"""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):
|
if not input.group(2):
|
||||||
return phenny.reply("Nothing to reverse.")
|
return phenny.reply("Nothing to reverse.")
|
||||||
q = input.group(2).encode('utf-8')
|
q = input.group(2).encode('utf-8')
|
||||||
|
@ -21,6 +25,10 @@ rev.priority = 'low'
|
||||||
|
|
||||||
def b64e(phenny, input):
|
def b64e(phenny, input):
|
||||||
"""base64 encode"""
|
"""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):
|
if not input.group(2):
|
||||||
return phenny.reply("Nothing to encode.")
|
return phenny.reply("Nothing to encode.")
|
||||||
q = input.group(2).encode('utf-8')
|
q = input.group(2).encode('utf-8')
|
||||||
|
@ -34,6 +42,10 @@ b64e.priority = 'low'
|
||||||
|
|
||||||
def b64d(phenny, input):
|
def b64d(phenny, input):
|
||||||
"""base64 decode"""
|
"""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):
|
if not input.group(2):
|
||||||
return phenny.reply("Nothing to decode.")
|
return phenny.reply("Nothing to decode.")
|
||||||
q = input.group(2).encode('utf-8')
|
q = input.group(2).encode('utf-8')
|
||||||
|
@ -47,6 +59,10 @@ b64d.priority = 'low'
|
||||||
|
|
||||||
def b32e(phenny, input):
|
def b32e(phenny, input):
|
||||||
"""base32 encode"""
|
"""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):
|
if not input.group(2):
|
||||||
return phenny.reply("Nothing to encode.")
|
return phenny.reply("Nothing to encode.")
|
||||||
q = input.group(2).encode('utf-8')
|
q = input.group(2).encode('utf-8')
|
||||||
|
@ -60,6 +76,10 @@ b32e.priority = 'low'
|
||||||
|
|
||||||
def b32d(phenny, input):
|
def b32d(phenny, input):
|
||||||
"""base32 decode"""
|
"""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):
|
if not input.group(2):
|
||||||
return phenny.reply("Nothing to decode.")
|
return phenny.reply("Nothing to decode.")
|
||||||
q = input.group(2).encode('utf-8')
|
q = input.group(2).encode('utf-8')
|
||||||
|
@ -73,6 +93,10 @@ b32d.priority = 'low'
|
||||||
|
|
||||||
def b16e(phenny, input):
|
def b16e(phenny, input):
|
||||||
"""base16 encode"""
|
"""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):
|
if not input.group(2):
|
||||||
return phenny.reply("Nothing to encode.")
|
return phenny.reply("Nothing to encode.")
|
||||||
q = input.group(2).encode('utf-8')
|
q = input.group(2).encode('utf-8')
|
||||||
|
@ -99,6 +123,10 @@ b16d.priority = 'low'
|
||||||
|
|
||||||
def crc32(phenny, input):
|
def crc32(phenny, input):
|
||||||
"""crc32 hash"""
|
"""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):
|
if not input.group(2):
|
||||||
return phenny.reply("Nothing to hash.")
|
return phenny.reply("Nothing to hash.")
|
||||||
q = input.group(2).encode('utf-8')
|
q = input.group(2).encode('utf-8')
|
||||||
|
@ -110,6 +138,10 @@ crc32.priority = 'low'
|
||||||
|
|
||||||
def hex_(phenny, input):
|
def hex_(phenny, input):
|
||||||
"""hexlify http://docs.python.org/2/library/binascii.html#binascii.hexlify"""
|
"""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):
|
if not input.group(2):
|
||||||
return phenny.reply("Nothing to hexlify.")
|
return phenny.reply("Nothing to hexlify.")
|
||||||
q = input.group(2).encode('utf-8')
|
q = input.group(2).encode('utf-8')
|
||||||
|
@ -123,6 +155,10 @@ hex_.priority = 'low'
|
||||||
|
|
||||||
def unhex(phenny, input):
|
def unhex(phenny, input):
|
||||||
"""unhexlify http://docs.python.org/2/library/binascii.html#binascii.unhexlify"""
|
"""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):
|
if not input.group(2):
|
||||||
return phenny.reply("Nothing to unhexlify.")
|
return phenny.reply("Nothing to unhexlify.")
|
||||||
q = input.group(2).encode('utf-8')
|
q = input.group(2).encode('utf-8')
|
||||||
|
@ -136,6 +172,10 @@ unhex.priority = 'low'
|
||||||
|
|
||||||
def uuencode(phenny, input):
|
def uuencode(phenny, input):
|
||||||
"""uuencode"""
|
"""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):
|
if not input.group(2):
|
||||||
return phenny.reply("Nothing to encode.")
|
return phenny.reply("Nothing to encode.")
|
||||||
q = input.group(2).encode('utf-8')
|
q = input.group(2).encode('utf-8')
|
||||||
|
@ -149,6 +189,10 @@ uuencode.priority = 'low'
|
||||||
|
|
||||||
def uudecode(phenny, input):
|
def uudecode(phenny, input):
|
||||||
"""uudecode"""
|
"""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):
|
if not input.group(2):
|
||||||
return phenny.reply("Nothing to decode.")
|
return phenny.reply("Nothing to decode.")
|
||||||
q = input.group(2).encode('utf-8')
|
q = input.group(2).encode('utf-8')
|
||||||
|
|
17
search.py
17
search.py
|
@ -11,7 +11,6 @@ http://inamidst.com/phenny/
|
||||||
import web, re
|
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_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):
|
class Grab(web.urllib.URLopener):
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
|
@ -59,6 +58,10 @@ def formatnumber(n):
|
||||||
|
|
||||||
def g(phenny, input):
|
def g(phenny, input):
|
||||||
"""Queries Google for the specified 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)
|
query = input.group(2)
|
||||||
if not query:
|
if not query:
|
||||||
return phenny.reply('.g what?')
|
return phenny.reply('.g what?')
|
||||||
|
@ -66,10 +69,6 @@ def g(phenny, input):
|
||||||
if bw in query:
|
if bw in query:
|
||||||
print("[LOG]: %s queried Google Result for '%s' | DENIED: Badword" % (input.nick,query))
|
print("[LOG]: %s queried Google Result for '%s' | DENIED: Badword" % (input.nick,query))
|
||||||
return phenny.reply("Gross!")
|
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')
|
query = query.encode('utf-8')
|
||||||
print("[LOG]: %s queried Google Result for '%s'" % (input.nick,query))
|
print("[LOG]: %s queried Google Result for '%s'" % (input.nick,query))
|
||||||
uri = google_search(query)
|
uri = google_search(query)
|
||||||
|
@ -85,6 +84,10 @@ g.priority = 'high'
|
||||||
g.example = '.g minetest'
|
g.example = '.g minetest'
|
||||||
|
|
||||||
def gc(phenny, input):
|
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):
|
if not input.group(2):
|
||||||
return phenny.reply("No query term.")
|
return phenny.reply("No query term.")
|
||||||
query = input.group(2).encode('utf-8')
|
query = input.group(2).encode('utf-8')
|
||||||
|
@ -93,10 +96,6 @@ def gc(phenny, input):
|
||||||
if bw in query:
|
if bw in query:
|
||||||
print("[LOG]: %s queried Google Result Number for '%s' | DENIED: Badword" % (input.nick,query))
|
print("[LOG]: %s queried Google Result Number for '%s' | DENIED: Badword" % (input.nick,query))
|
||||||
return phenny.reply("Gross!")
|
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))
|
print("[LOG]: %s queried Google Result Number for '%s'" % (input.nick,query))
|
||||||
if result:
|
if result:
|
||||||
phenny.say(query + ": " + result)
|
phenny.say(query + ": " + result)
|
||||||
|
|
4
seen.py
4
seen.py
|
@ -13,6 +13,10 @@ from tools import deprecated
|
||||||
|
|
||||||
def seen(phenny, input):
|
def seen(phenny, input):
|
||||||
""".seen <nick> - Reports when <nick> was last seen."""
|
""".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)
|
nick = input.group(2)
|
||||||
if not nick:
|
if not nick:
|
||||||
return phenny.reply("Need a nickname to search for...")
|
return phenny.reply("Need a nickname to search for...")
|
||||||
|
|
|
@ -8,6 +8,10 @@ import web, math, random
|
||||||
from xml.dom import minidom
|
from xml.dom import minidom
|
||||||
|
|
||||||
def read_server():
|
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/")
|
bytes = web.get("http://servers.minetest.ru/")
|
||||||
shim = '<table>'
|
shim = '<table>'
|
||||||
shim2 = '</table>'
|
shim2 = '</table>'
|
||||||
|
|
|
@ -7,6 +7,10 @@ Copyright 2012, sfan5
|
||||||
import socket, time
|
import socket, time
|
||||||
|
|
||||||
def serverup(phenny, input):
|
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)
|
arg = input.group(2)
|
||||||
if not arg:
|
if not arg:
|
||||||
return phenny.reply("Give me a Server Address")
|
return phenny.reply("Give me a Server Address")
|
||||||
|
|
|
@ -6,6 +6,10 @@ Copyright 2013, sfan5
|
||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
def shorten(phenny, input):
|
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)
|
arg = input.group(2)
|
||||||
if not arg:
|
if not arg:
|
||||||
arg = "" # Function continues and prints Help Message
|
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
|
return "Sorry, couldn't get a tweet from %s" % link
|
||||||
|
|
||||||
def twitter(phenny, input):
|
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)
|
arg = input.group(2)
|
||||||
if not arg:
|
if not arg:
|
||||||
return phenny.reply("Give me a link, a username, or a tweet id")
|
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))
|
return sentence + ' - ' + (wikiuri % (term))
|
||||||
|
|
||||||
def wik(phenny, input):
|
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]
|
origterm = input.groups()[1]
|
||||||
if not origterm:
|
if not origterm:
|
||||||
return phenny.say('Perhaps you meant ".wik Zen"?')
|
return phenny.say('Perhaps you meant ".wik Zen"?')
|
||||||
|
|
Loading…
Reference in New Issue