Merge pull request #180 from daboross/patch-2
Format all plugins to pep8 guidelines
This commit is contained in:
commit
439ef0ba1c
33 changed files with 142 additions and 107 deletions
|
@ -1,5 +1,6 @@
|
||||||
from util import hook
|
from util import hook
|
||||||
import os, sys
|
import os
|
||||||
|
import sys
|
||||||
import re
|
import re
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
|
@ -127,6 +128,7 @@ def restart(inp, nick=None, conn=None, bot=None):
|
||||||
args.insert(0, sys.executable)
|
args.insert(0, sys.executable)
|
||||||
os.execv(sys.executable, args)
|
os.execv(sys.executable, args)
|
||||||
|
|
||||||
|
|
||||||
@hook.command(autohelp=False, permissions=["botcontrol"])
|
@hook.command(autohelp=False, permissions=["botcontrol"])
|
||||||
def clearlogs(inp, input=None):
|
def clearlogs(inp, input=None):
|
||||||
"""clearlogs -- Clears the bots log(s)."""
|
"""clearlogs -- Clears the bots log(s)."""
|
||||||
|
|
|
@ -13,6 +13,7 @@ with open("plugins/data/flirts.txt") as f:
|
||||||
flirts = [line.strip() for line in f.readlines()
|
flirts = [line.strip() for line in f.readlines()
|
||||||
if not line.startswith("//")]
|
if not line.startswith("//")]
|
||||||
|
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
def lart(inp, action=None, nick=None, conn=None, notice=None):
|
def lart(inp, action=None, nick=None, conn=None, notice=None):
|
||||||
"""lart <user> -- LARTs <user>."""
|
"""lart <user> -- LARTs <user>."""
|
||||||
|
|
|
@ -10,6 +10,7 @@ def encode(key, clear):
|
||||||
enc.append(enc_c)
|
enc.append(enc_c)
|
||||||
return base64.urlsafe_b64encode("".join(enc))
|
return base64.urlsafe_b64encode("".join(enc))
|
||||||
|
|
||||||
|
|
||||||
def decode(key, enc):
|
def decode(key, enc):
|
||||||
dec = []
|
dec = []
|
||||||
enc = base64.urlsafe_b64decode(enc.encode('ascii', 'ignore'))
|
enc = base64.urlsafe_b64decode(enc.encode('ascii', 'ignore'))
|
||||||
|
|
|
@ -56,7 +56,7 @@ def encrypt(inp, bot=None, db=None, notice=None):
|
||||||
key = PBKDF2(password, salt)
|
key = PBKDF2(password, salt)
|
||||||
|
|
||||||
# generate the IV and encode it to store in the database
|
# generate the IV and encode it to store in the database
|
||||||
iv = Random.new().read(AES.block_size);
|
iv = Random.new().read(AES.block_size)
|
||||||
iv_encoded = base64.b64encode(iv)
|
iv_encoded = base64.b64encode(iv)
|
||||||
|
|
||||||
# create the AES cipher and encrypt/encode the text with it
|
# create the AES cipher and encrypt/encode the text with it
|
||||||
|
|
|
@ -20,8 +20,7 @@ def googleimage(inp):
|
||||||
raise IOError('error searching for images: {}: {}'.format(parsed['responseStatus'], ''))
|
raise IOError('error searching for images: {}: {}'.format(parsed['responseStatus'], ''))
|
||||||
if not parsed['responseData']['results']:
|
if not parsed['responseData']['results']:
|
||||||
return 'no images found'
|
return 'no images found'
|
||||||
return random.choice(parsed['responseData']['results'][:10]) \
|
return random.choice(parsed['responseData']['results'][:10])['unescapedUrl']
|
||||||
['unescapedUrl']
|
|
||||||
|
|
||||||
|
|
||||||
@hook.command('search')
|
@hook.command('search')
|
||||||
|
|
|
@ -68,6 +68,7 @@ def allowed(db, nick, nick_vote):
|
||||||
# karma_re = ('((\S+)(\+\+|\-\-))+', re.I)
|
# karma_re = ('((\S+)(\+\+|\-\-))+', re.I)
|
||||||
karma_re = ('(.+)(\+\+|\-\-)$', re.I)
|
karma_re = ('(.+)(\+\+|\-\-)$', re.I)
|
||||||
|
|
||||||
|
|
||||||
@hook.regex(*karma_re)
|
@hook.regex(*karma_re)
|
||||||
def karma_add(match, nick='', chan='', db=None, notice=None):
|
def karma_add(match, nick='', chan='', db=None, notice=None):
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ def format_motd(motd):
|
||||||
colors = [u"\x0300,\xa7f", u"\x0301,\xa70", u"\x0302,\xa71", u"\x0303,\xa72", u"\x0304,\xa7c", u"\x0305,\xa74",
|
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"\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"\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"];
|
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])
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
# Plugin by Lukeroge
|
# Plugin by Lukeroge
|
||||||
from util import hook, text, textgen
|
from util import hook, text, textgen
|
||||||
import json, os
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
GEN_DIR = "./plugins/data/name_files/"
|
GEN_DIR = "./plugins/data/name_files/"
|
||||||
|
|
|
@ -51,7 +51,6 @@ def reddit(inp):
|
||||||
return "Error: " + str(e)
|
return "Error: " + str(e)
|
||||||
data = data["data"]["children"]
|
data = data["data"]["children"]
|
||||||
|
|
||||||
|
|
||||||
# get the requested/random post
|
# get the requested/random post
|
||||||
if id_num:
|
if id_num:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -7,8 +7,13 @@ gauge_url = "http://www.mysteamgauge.com/search?username={}"
|
||||||
api_url = "http://mysteamgauge.com/user/{}.csv"
|
api_url = "http://mysteamgauge.com/user/{}.csv"
|
||||||
steam_api_url = "http://steamcommunity.com/id/{}/?xml=1"
|
steam_api_url = "http://steamcommunity.com/id/{}/?xml=1"
|
||||||
|
|
||||||
def refresh_data(name): http.get(gauge_url.format(name), timeout=25, get_method='HEAD')
|
|
||||||
def get_data(name): return http.get(api_url.format(name))
|
def refresh_data(name):
|
||||||
|
http.get(gauge_url.format(name), timeout=25, get_method='HEAD')
|
||||||
|
|
||||||
|
|
||||||
|
def get_data(name):
|
||||||
|
return http.get(api_url.format(name))
|
||||||
|
|
||||||
|
|
||||||
def is_number(s):
|
def is_number(s):
|
||||||
|
@ -91,9 +96,8 @@ def steamcalc(inp, reply=None):
|
||||||
|
|
||||||
data["size"] = "{0:.1f}".format(total_size)
|
data["size"] = "{0:.1f}".format(total_size)
|
||||||
|
|
||||||
|
reply("{name} ({state}) has {games} games with a total value of ${value}"
|
||||||
reply("{name} ({state}) has {games} games with a total value of ${value}" \
|
" and a total size of {size}GB! The average metascore for these"
|
||||||
" and a total size of {size}GB! The average metascore for these" \
|
|
||||||
" games is {average_metascore}.".format(**data))
|
" games is {average_metascore}.".format(**data))
|
||||||
|
|
||||||
if do_refresh:
|
if do_refresh:
|
||||||
|
|
|
@ -13,23 +13,29 @@ control = {'bold': '\x02', 'color': '\x03', 'italic': '\x09',
|
||||||
def color(color):
|
def color(color):
|
||||||
return control['color'] + colors[color]
|
return control['color'] + colors[color]
|
||||||
|
|
||||||
|
|
||||||
def bold():
|
def bold():
|
||||||
return control['bold']
|
return control['bold']
|
||||||
|
|
||||||
|
|
||||||
def italic():
|
def italic():
|
||||||
return control['italic']
|
return control['italic']
|
||||||
|
|
||||||
|
|
||||||
def strike():
|
def strike():
|
||||||
return control['strikethrough']
|
return control['strikethrough']
|
||||||
|
|
||||||
|
|
||||||
def reset():
|
def reset():
|
||||||
return control['reset']
|
return control['reset']
|
||||||
|
|
||||||
|
|
||||||
def underline(other=False):
|
def underline(other=False):
|
||||||
if other:
|
if other:
|
||||||
return control['underline2']
|
return control['underline2']
|
||||||
else:
|
else:
|
||||||
return control['underline']
|
return control['underline']
|
||||||
|
|
||||||
|
|
||||||
def reverse():
|
def reverse():
|
||||||
return control['reverse']
|
return control['reverse']
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import http, web
|
import http
|
||||||
|
import web
|
||||||
|
|
||||||
|
|
||||||
def eval_py(code, paste_multiline=True):
|
def eval_py(code, paste_multiline=True):
|
||||||
|
|
|
@ -29,6 +29,8 @@ def raw(format_string):
|
||||||
for x in final:
|
for x in final:
|
||||||
format_string = format_string.replace(x, final[x])
|
format_string = format_string.replace(x, final[x])
|
||||||
return format_string
|
return format_string
|
||||||
|
|
||||||
|
|
||||||
def err(format_string):
|
def err(format_string):
|
||||||
"""Format the string with standard error styling"""
|
"""Format the string with standard error styling"""
|
||||||
return "\x034\x02{}\x0f".format(format_string)
|
return "\x034\x02{}\x0f".format(format_string)
|
|
@ -184,7 +184,7 @@ def truncate_str(content, length=100, suffix='...'):
|
||||||
# Expression to match some_token and some_token="with spaces" (and similarly
|
# Expression to match some_token and some_token="with spaces" (and similarly
|
||||||
# for single-quoted strings).
|
# for single-quoted strings).
|
||||||
|
|
||||||
split_re = re.compile(r"""((?:[^\s'"]*(?:(?:"(?:[^"\\]|\\.)*" | '(?:[""" \
|
split_re = re.compile(r"""((?:[^\s'"]*(?:(?:"(?:[^"\\]|\\.)*" | '(?:["""
|
||||||
r"""^'\\]|\\.)*')[^\s'"]*)+) | \S+)""", re.VERBOSE)
|
r"""^'\\]|\\.)*')[^\s'"]*)+) | \S+)""", re.VERBOSE)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,11 +23,13 @@ colors = collections.OrderedDict([
|
||||||
|
|
||||||
strip_re = re.compile("(\x03|\x02|\x1f)(?:,?\d{1,2}(?:,\d{1,2})?)?", re.UNICODE)
|
strip_re = re.compile("(\x03|\x02|\x1f)(?:,?\d{1,2}(?:,\d{1,2})?)?", re.UNICODE)
|
||||||
|
|
||||||
|
|
||||||
def strip(text):
|
def strip(text):
|
||||||
return strip_re.sub('', text)
|
return strip_re.sub('', text)
|
||||||
|
|
||||||
# basic text tools
|
# basic text tools
|
||||||
|
|
||||||
|
|
||||||
## TODO: make this capitalize sentences correctly
|
## TODO: make this capitalize sentences correctly
|
||||||
@hook.command("capitalise")
|
@hook.command("capitalise")
|
||||||
@hook.command
|
@hook.command
|
||||||
|
@ -35,21 +37,25 @@ def capitalize(inp):
|
||||||
"""capitalize <string> -- Capitalizes <string>."""
|
"""capitalize <string> -- Capitalizes <string>."""
|
||||||
return inp.capitalize()
|
return inp.capitalize()
|
||||||
|
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
def upper(inp):
|
def upper(inp):
|
||||||
"""upper <string> -- Convert string to uppercase."""
|
"""upper <string> -- Convert string to uppercase."""
|
||||||
return inp.upper()
|
return inp.upper()
|
||||||
|
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
def lower(inp):
|
def lower(inp):
|
||||||
"""lower <string> -- Convert string to lowercase."""
|
"""lower <string> -- Convert string to lowercase."""
|
||||||
return inp.lower()
|
return inp.lower()
|
||||||
|
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
def titlecase(inp):
|
def titlecase(inp):
|
||||||
"""title <string> -- Convert string to title case."""
|
"""title <string> -- Convert string to title case."""
|
||||||
return inp.title()
|
return inp.title()
|
||||||
|
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
def swapcase(inp):
|
def swapcase(inp):
|
||||||
"""swapcase <string> -- Swaps the capitalization of <string>."""
|
"""swapcase <string> -- Swaps the capitalization of <string>."""
|
||||||
|
@ -57,21 +63,25 @@ def swapcase(inp):
|
||||||
|
|
||||||
# encoding
|
# encoding
|
||||||
|
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
def rot13(inp):
|
def rot13(inp):
|
||||||
"""rot13 <string> -- Encode <string> with rot13."""
|
"""rot13 <string> -- Encode <string> with rot13."""
|
||||||
return inp.encode('rot13')
|
return inp.encode('rot13')
|
||||||
|
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
def base64(inp):
|
def base64(inp):
|
||||||
"""base64 <string> -- Encode <string> with base64."""
|
"""base64 <string> -- Encode <string> with base64."""
|
||||||
return inp.encode('base64')
|
return inp.encode('base64')
|
||||||
|
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
def unbase64(inp):
|
def unbase64(inp):
|
||||||
"""unbase64 <string> -- Decode <string> with base64."""
|
"""unbase64 <string> -- Decode <string> with base64."""
|
||||||
return inp.decode('base64')
|
return inp.decode('base64')
|
||||||
|
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
def checkbase64(inp):
|
def checkbase64(inp):
|
||||||
try:
|
try:
|
||||||
|
@ -86,6 +96,7 @@ def checkbase64(inp):
|
||||||
else:
|
else:
|
||||||
return '"{}" is not base64 encoded'.format(inp)
|
return '"{}" is not base64 encoded'.format(inp)
|
||||||
|
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
def unescape(inp):
|
def unescape(inp):
|
||||||
"""unescape <string> -- Unescapes <string>."""
|
"""unescape <string> -- Unescapes <string>."""
|
||||||
|
@ -94,6 +105,7 @@ def unescape(inp):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return "Error: {}".format(e)
|
return "Error: {}".format(e)
|
||||||
|
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
def escape(inp):
|
def escape(inp):
|
||||||
"""escape <string> -- Escapes <string>."""
|
"""escape <string> -- Escapes <string>."""
|
||||||
|
@ -104,6 +116,7 @@ def escape(inp):
|
||||||
|
|
||||||
# length
|
# length
|
||||||
|
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
def length(inp):
|
def length(inp):
|
||||||
"""length <string> -- gets the length of <string>"""
|
"""length <string> -- gets the length of <string>"""
|
||||||
|
@ -111,6 +124,7 @@ def length(inp):
|
||||||
|
|
||||||
# reverse
|
# reverse
|
||||||
|
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
def reverse(inp):
|
def reverse(inp):
|
||||||
"""reverse <string> -- reverses <string>."""
|
"""reverse <string> -- reverses <string>."""
|
||||||
|
@ -118,6 +132,7 @@ def reverse(inp):
|
||||||
|
|
||||||
# hashing
|
# hashing
|
||||||
|
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
def hash(inp):
|
def hash(inp):
|
||||||
"""hash <string> -- Returns hashes of <string>."""
|
"""hash <string> -- Returns hashes of <string>."""
|
||||||
|
@ -126,6 +141,7 @@ def hash(inp):
|
||||||
|
|
||||||
# novelty
|
# novelty
|
||||||
|
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
def munge(inp):
|
def munge(inp):
|
||||||
"""munge <text> -- Munges up <text>."""
|
"""munge <text> -- Munges up <text>."""
|
||||||
|
@ -133,6 +149,7 @@ def munge(inp):
|
||||||
|
|
||||||
# colors - based on code by Reece Selwood - <https://github.com/hitzler/homero>
|
# colors - based on code by Reece Selwood - <https://github.com/hitzler/homero>
|
||||||
|
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
def rainbow(inp):
|
def rainbow(inp):
|
||||||
inp = unicode(inp)
|
inp = unicode(inp)
|
||||||
|
@ -147,6 +164,7 @@ def rainbow(inp):
|
||||||
out += col[i % l][1] + t
|
out += col[i % l][1] + t
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
def wrainbow(inp):
|
def wrainbow(inp):
|
||||||
inp = unicode(inp)
|
inp = unicode(inp)
|
||||||
|
@ -158,6 +176,7 @@ def wrainbow(inp):
|
||||||
out.append(col[i % l][1] + t)
|
out.append(col[i % l][1] + t)
|
||||||
return ' '.join(out)
|
return ' '.join(out)
|
||||||
|
|
||||||
|
|
||||||
@hook.command
|
@hook.command
|
||||||
def usa(inp):
|
def usa(inp):
|
||||||
inp = strip(inp)
|
inp = strip(inp)
|
||||||
|
@ -167,4 +186,3 @@ def usa(inp):
|
||||||
for i, t in enumerate(inp):
|
for i, t in enumerate(inp):
|
||||||
out += c[i % l] + t
|
out += c[i % l] + t
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
Reference in a new issue