Fixed formatting and removed unused imports.
This commit is contained in:
parent
fb62640ccc
commit
fa97d4659c
6 changed files with 31 additions and 33 deletions
|
@ -1,14 +1,14 @@
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from util import hook, text
|
from util import hook
|
||||||
from fnmatch import fnmatch
|
from fnmatch import fnmatch
|
||||||
|
|
||||||
|
|
||||||
@hook.sieve
|
@hook.sieve
|
||||||
def sieve_suite(bot, input, func, kind, args):
|
def sieve_suite(bot, input, func, kind, args):
|
||||||
if input.command == 'PRIVMSG' and\
|
if input.command == 'PRIVMSG' and \
|
||||||
input.nick.endswith('bot') and args.get('ignorebots', True):
|
input.nick.endswith('bot') and args.get('ignorebots', True):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if kind == "command":
|
if kind == "command":
|
||||||
if input.trigger in bot.config.get('disabled_commands', []):
|
if input.trigger in bot.config.get('disabled_commands', []):
|
||||||
|
@ -34,7 +34,6 @@ def sieve_suite(bot, input, func, kind, args):
|
||||||
if args.get('adminonly', False):
|
if args.get('adminonly', False):
|
||||||
args["permissions"] = ["adminonly"]
|
args["permissions"] = ["adminonly"]
|
||||||
|
|
||||||
|
|
||||||
if args.get('permissions', False):
|
if args.get('permissions', False):
|
||||||
groups = bot.config.get("permissions", [])
|
groups = bot.config.get("permissions", [])
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,15 @@
|
||||||
from util import hook
|
from util import hook
|
||||||
import re
|
|
||||||
|
|
||||||
@hook.regex(r'^(s|S)/.*/.*/\S*$')
|
@hook.regex(r'^(s|S)/.*/.*/\S*$')
|
||||||
def correction(inp, say=None, input=None, notice=None, db=None):
|
def correction(inp, say=None, notice=None, db=None):
|
||||||
|
|
||||||
splitinput = input.msg.split("/")
|
splitinput = input.msg.split("/")
|
||||||
if splitinput[3]:
|
if splitinput[3]:
|
||||||
nick = splitinput[3]
|
nick = splitinput[3]
|
||||||
else:
|
else:
|
||||||
nick = input.nick
|
nick = input.nick
|
||||||
last_message = db.execute("select name, quote from seen_user where name"
|
last_message = db.execute("select name, quote from seen_user where name"
|
||||||
" like ? and chan = ?", (nick.lower(), input.chan.lower())).fetchone()
|
" like ? and chan = ?", (nick.lower(), input.chan.lower())).fetchone()
|
||||||
|
|
||||||
if last_message:
|
if last_message:
|
||||||
splitinput = input.msg.split("/")
|
splitinput = input.msg.split("/")
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
from util import hook, http, web
|
from util import hook, http, web
|
||||||
from urllib import urlencode
|
|
||||||
from spotify import spotifyfunc as spotify
|
from spotify import spotifyfunc as spotify
|
||||||
|
|
||||||
url = "http://search.azlyrics.com/search.php?q="
|
url = "http://search.azlyrics.com/search.php?q="
|
||||||
|
@ -43,6 +42,7 @@ def lyrics(inp):
|
||||||
lyricsum = " / ".join(lyricsum.strip().split("\r\n")[0:4]) # truncate, format
|
lyricsum = " / ".join(lyricsum.strip().split("\r\n")[0:4]) # truncate, format
|
||||||
else:
|
else:
|
||||||
lyricsum = " / ".join(lyricsum.strip().split("\n")[0:4]) # truncate, format
|
lyricsum = " / ".join(lyricsum.strip().split("\n")[0:4]) # truncate, format
|
||||||
return "\x02%s\x02 by \x02%s\x02 %s%s%s - %s" % (title, artist, web.try_isgd(link), spurl, pasteurl, lyricsum[:-3])
|
return "\x02%s\x02 by \x02%s\x02 %s%s%s - %s" % (
|
||||||
|
title, artist, web.try_isgd(link), spurl, pasteurl, lyricsum[:-3])
|
||||||
else:
|
else:
|
||||||
return "No song results. " + url + inp.replace(" ", "+")
|
return "No song results. " + url + inp.replace(" ", "+")
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
from util import hook
|
from util import hook
|
||||||
import re
|
import re
|
||||||
import itertools
|
|
||||||
|
|
||||||
pattern = re.compile(r'^(?P<count>\d+)x (?P<name>.+?): (?P<ingredients>.*)$')
|
pattern = re.compile(r'^(?P<count>\d+)x (?P<name>.+?): (?P<ingredients>.*)$')
|
||||||
|
|
||||||
|
@ -32,9 +31,9 @@ with open("plugins/data/recipes.txt") as f:
|
||||||
if not match:
|
if not match:
|
||||||
continue
|
continue
|
||||||
recipelist.append(Recipe(line=line,
|
recipelist.append(Recipe(line=line,
|
||||||
output=match.group("name").lower(),
|
output=match.group("name").lower(),
|
||||||
ingredients=match.group("ingredients"),
|
ingredients=match.group("ingredients"),
|
||||||
count=match.group("count")))
|
count=match.group("count")))
|
||||||
|
|
||||||
ids = []
|
ids = []
|
||||||
|
|
||||||
|
@ -51,7 +50,7 @@ with open("plugins/data/itemids.txt") as f:
|
||||||
@hook.command("mcid")
|
@hook.command("mcid")
|
||||||
@hook.command
|
@hook.command
|
||||||
def mcitem(input, reply=None):
|
def mcitem(input, reply=None):
|
||||||
"mcitem <item/id> -- gets the id from an item or vice versa"
|
"""mcitem <item/id> -- gets the id from an item or vice versa"""
|
||||||
input = input.lower().strip()
|
input = input.lower().strip()
|
||||||
|
|
||||||
if input == "":
|
if input == "":
|
||||||
|
@ -71,8 +70,7 @@ def mcitem(input, reply=None):
|
||||||
return "No matches found."
|
return "No matches found."
|
||||||
|
|
||||||
if len(results) > 12:
|
if len(results) > 12:
|
||||||
reply("There are too many options, please narrow your search. " \
|
reply("There are too many options, please narrow your search. (%s)" % len(results))
|
||||||
"(%s)" % len(results))
|
|
||||||
return
|
return
|
||||||
|
|
||||||
out = ", ".join(results)
|
out = ", ".join(results)
|
||||||
|
@ -83,7 +81,7 @@ def mcitem(input, reply=None):
|
||||||
@hook.command("mccraft")
|
@hook.command("mccraft")
|
||||||
@hook.command
|
@hook.command
|
||||||
def mcrecipe(input, reply=None):
|
def mcrecipe(input, reply=None):
|
||||||
"mcrecipe <item> -- gets the crafting recipe for an item"
|
"""mcrecipe <item> -- gets the crafting recipe for an item"""
|
||||||
input = input.lower().strip()
|
input = input.lower().strip()
|
||||||
|
|
||||||
results = [recipe.line for recipe in recipelist
|
results = [recipe.line for recipe in recipelist
|
||||||
|
@ -93,8 +91,7 @@ def mcrecipe(input, reply=None):
|
||||||
return "No matches found."
|
return "No matches found."
|
||||||
|
|
||||||
if len(results) > 3:
|
if len(results) > 3:
|
||||||
reply("There are too many options, please narrow your search. " \
|
reply("There are too many options, please narrow your search. (%s)" % len(results))
|
||||||
"(%s)" % len(results))
|
|
||||||
return
|
return
|
||||||
|
|
||||||
for result in results:
|
for result in results:
|
||||||
|
|
|
@ -1,17 +1,21 @@
|
||||||
from util import hook, http
|
from util import hook
|
||||||
import socket
|
import socket
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import DNS
|
import DNS
|
||||||
# Please remember to install the dependancy 'pydns'
|
# Please remember to install the dependancy 'pydns'
|
||||||
pydns_installed = True
|
pydns_installed = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pydns_installed = False
|
pydns_installed = False
|
||||||
|
|
||||||
|
|
||||||
def format_motd(motd):
|
def format_motd(motd):
|
||||||
empty = ""
|
empty = ""
|
||||||
colors = [u"\x0300,\xa7f", u"\x0301,\xa70", u"\x0302,\xa71", u"\x0303,\xa72", u"\x0304,\xa7c", u"\x0305,\xa74", u"\x0306,\xa75", u"\x0307,\xa76", u"\x0308,\xa7e", u"\x0309,\xa7a", u"\x0310,\xa73", u"\x0311,\xa7b", u"\x0312,\xa71", u"\x0313,\xa7d", u"\x0314,\xa78", u"\x0315,\xa77", u"\x02,\xa7l", u"\x0310,\xa79", u"\x09,\xa7o", u"\x13,\xa7m", u"\x0f,\xa7r", u"\x15,\xa7n"];
|
colors = [u"\x0300,\xa7f", u"\x0301,\xa70", u"\x0302,\xa71", u"\x0303,\xa72", u"\x0304,\xa7c", u"\x0305,\xa74",
|
||||||
|
u"\x0306,\xa75", u"\x0307,\xa76", u"\x0308,\xa7e", u"\x0309,\xa7a", u"\x0310,\xa73", u"\x0311,\xa7b",
|
||||||
|
u"\x0312,\xa71", u"\x0313,\xa7d", u"\x0314,\xa78", u"\x0315,\xa77", u"\x02,\xa7l", u"\x0310,\xa79",
|
||||||
|
u"\x09,\xa7o", u"\x13,\xa7m", u"\x0f,\xa7r", u"\x15,\xa7n"];
|
||||||
for s in colors:
|
for s in colors:
|
||||||
lcol = s.split(",")
|
lcol = s.split(",")
|
||||||
motd = motd.replace(lcol[1], lcol[0])
|
motd = motd.replace(lcol[1], lcol[0])
|
||||||
|
@ -46,8 +50,8 @@ def mcping_connect(host, port):
|
||||||
return message
|
return message
|
||||||
|
|
||||||
except:
|
except:
|
||||||
return "Error pinging " + host + ":" + str(port) +\
|
return "Error pinging " + host + ":" + str(port) + \
|
||||||
", is it up? Double-check your address!"
|
", is it up? Double-check your address!"
|
||||||
|
|
||||||
|
|
||||||
def srvData(domain):
|
def srvData(domain):
|
||||||
|
@ -57,13 +61,13 @@ def srvData(domain):
|
||||||
|
|
||||||
for getsrv in srv_result.answers:
|
for getsrv in srv_result.answers:
|
||||||
if getsrv['typename'] == 'SRV':
|
if getsrv['typename'] == 'SRV':
|
||||||
data = [getsrv['data'][2],getsrv['data'][3]]
|
data = [getsrv['data'][2], getsrv['data'][3]]
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
def mcping(inp):
|
def mcping(inp):
|
||||||
"mcping <server>[:port] - Ping a Minecraft server to check status."
|
"""mcping <server>[:port] - Ping a Minecraft server to check status."""
|
||||||
inp = inp.strip().split(" ")[0]
|
inp = inp.strip().split(" ")[0]
|
||||||
|
|
||||||
if ":" in inp:
|
if ":" in inp:
|
||||||
|
@ -86,7 +90,7 @@ def mcping(inp):
|
||||||
host = str(getdata[1])
|
host = str(getdata[1])
|
||||||
port = int(getdata[0])
|
port = int(getdata[0])
|
||||||
return format_motd(mcping_connect(host, port))
|
return format_motd(mcping_connect(host, port))
|
||||||
except:
|
except:
|
||||||
return "Error pinging %s, is it up? Double-check your address!" % inp
|
return "Error pinging %s, is it up? Double-check your address!" % inp
|
||||||
else:
|
else:
|
||||||
return "Error pinging %s, is it up? Double-check your address!" % inp
|
return "Error pinging %s, is it up? Double-check your address!" % inp
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
import re
|
from util import hook
|
||||||
|
|
||||||
from util import hook, http
|
|
||||||
from util.execute import eval_py
|
from util.execute import eval_py
|
||||||
|
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
def python(inp):
|
def python(inp):
|
||||||
"python <prog> -- Executes <prog> as Python code."
|
"""python <prog> -- Executes <prog> as Python code."""
|
||||||
|
|
||||||
return eval_py(inp)
|
return eval_py(inp)
|
||||||
|
|
Reference in a new issue