Browse Source

Improve shortutils and rutils

master
sfan5 8 years ago
parent
commit
0a839cfade
  1. 91
      rutils.py
  2. 111
      shortutils.py

91
rutils.py

@ -22,83 +22,24 @@ def rev(phenny, input):
rev.commands = ['rev','reverse']
rev.priority = 'low'
def b64e(phenny, input):
"""base64 encode"""
if not input.group(2):
return phenny.reply("Nothing to encode.")
q = input.group(2).encode('utf-8')
try:
return phenny.say(rs(base64.b64encode(q)))
except BaseException as e:
return phenny.reply("Failed to handle data")
b64e.commands = ['b64e','base64encode']
b64e.priority = 'low'
def b64d(phenny, input):
"""base64 decode"""
if not input.group(2):
return phenny.reply("Nothing to decode.")
q = input.group(2).encode('utf-8')
try:
return phenny.say(rs(base64.b64decode(q)))
except BaseException as e:
return phenny.reply("Failed to handle data")
b64d.commands = ['b64d','base64decode']
b64d.priority = 'low'
def b32e(phenny, input):
"""base32 encode"""
if not input.group(2):
return phenny.reply("Nothing to encode.")
q = input.group(2).encode('utf-8')
try:
return phenny.say(rs(base64.b32encode(q)))
except BaseException as e:
return phenny.reply("Failed to handle data")
b32e.commands = ['b32e','base32encode']
b32e.priority = 'low'
def b32d(phenny, input):
"""base32 decode"""
if not input.group(2):
return phenny.reply("Nothing to decode.")
def make_thing(cmds, func):
def m(phenny, input):
if not input.group(2): return
q = input.group(2).encode('utf-8')
try:
return phenny.say(rs(base64.b32decode(q)))
phenny.say(rs(func(q)))
except BaseException as e:
return phenny.reply("Failed to handle data")
b32d.commands = ['b32d','base32decode']
b32d.priority = 'low'
def b16e(phenny, input):
"""base16 encode"""
if not input.group(2):
return phenny.reply("Nothing to encode.")
q = input.group(2).encode('utf-8')
try:
return phenny.say(rs(base64.b16encode(q)))
except BaseException as e:
return phenny.reply("Failed to handle data")
b16e.commands = ['b16e','base16encode']
b16e.priority = 'low'
def b16d(phenny, input):
"""base16 decode"""
if not input.group(2):
return phenny.reply("Nothing to decode.")
q = input.group(2).encode('utf-8')
try:
return phenny.say(rs(base64.b16decode(q)))
except BaseException as e:
return phenny.reply("Failed to handle data")
b16d.commands = ['b16d','base16decode']
b16d.priority = 'low'
phenny.reply("Failed to handle data")
m.commands = cmds
m.priority = "low"
return m
b64e = make_thing(['b64e','base64encode'], base64.b64encode)
b64d = make_thing(['b64d','base64decode'], base64.b64decode)
b32e = make_thing(['b32e','base32encode'], base64.b32encode)
b32d = make_thing(['b32d','base32decode'], base64.b32decode)
b16e = make_thing(['b16e','base16encode'], base64.b16encode)
b16d = make_thing(['b16d','base16decode'], base64.b16decode)
def crc32(phenny, input):
"""crc32 hash"""
@ -153,8 +94,8 @@ def regex(phenny, input):
t.start()
t.join(3.0)
if t.is_alive():
phenny.reply("Regex took to long to compute")
t.terminate()
phenny.reply("Regex took to long to compute")
return
m = q.get()
if m == []:

111
shortutils.py

@ -13,25 +13,24 @@ import random
import urllib2
import json
def rtfm(phenny, input):
"""Manual reference command"""
if input.group(2):
def make_cmd(cmd, txt):
def m(phenny, input):
t = txt
if input.group(2):
u = input.group(2).strip() + ", "
else:
t = t[0].upper() + t[1:]
else:
u = ""
phenny.say(u + "someone thinks you should read the manual. The wiki for dev related questions is at http://dev.minetest.net , the regular wiki is at http://wiki.minetest.net. ")
phenny.say(u + t)
m.commands = cmd
return m
rtfm.commands = ['rtfm']
def questions(phenny, input):
"""Ask smart questions"""
if input.group(2):
u = input.group(2).strip() + ", "
else:
u = ""
phenny.say(u + "someone thinks that your question is inaccurate or doesn't follow the guidelines. Read here how to make it right: http://catb.org/~esr/faqs/smart-questions.html")
questions.commands = ['questions']
rtfm = make_cmd("rtfm", "someone thinks you should read the manual. The development wiki is at http://dev.minetest.net, the regular wiki is at http://wiki.minetest.net.")
questions = make_cmd("questions", "someone thinks that your question is inaccurate or doesn't follow the guidelines. Read the guidelines here: http://catb.org/~esr/faqs/smart-questions.html")
pil = make_cmd("pil", "someone thinks you need to brush up on or learn Lua, please go to: http://lua.org/pil/")
git = make_cmd("git", "someone thinks you need to brush up on or learn Git, please go to: http://git-scm.com/book/")
stfu = make_cmd("stfu", "someone thinks you need to shut the fuck up before you get muted.")
proc = make_cmd("proc", "someone thinks you need to stop procrastinating.")
def next(phenny, input):
"""Next one please"""
@ -39,50 +38,6 @@ def next(phenny, input):
next.commands = ['next']
def pil(phenny, input):
"""Lua Manual link"""
for x in phenny.bot.commands["high"].values():
if x[0].__name__ == "aa_hook":
if x[0](phenny, input):
return
if input.group(2):
u = input.group(2).strip() + ", "
else:
u = ""
phenny.say(u + "someone thinks you need to brush up on or learn Lua, please go to: http://lua.org/pil/")
pil.commands = ['pil']
def git(phenny, input):
"""Git Manual link"""
if input.group(2):
u = input.group(2).strip() + ", "
else:
u = ""
phenny.say(u + "someone thinks you need to brush up on or learn Git, please go to: http://git-scm.com/book/")
git.commands = ['git']
def stfu(phenny, input):
"""usage: !stfu [nick]"""
if input.group(2):
u = input.group(2).strip() + ", "
else:
u = ""
phenny.say(u + "someone thinks you need to shut the fuck up before you get muted.")
stfu.commands = ['stfu']
def proc(phenny, input):
"""usage: !proc [nick]"""
if input.group(2):
u = input.group(2).strip() + ", "
else:
u = ""
phenny.say(u + "someone thinks you need to stop procrastinating.")
proc.commands = ['proc']
def doge(phenny, input):
"""much wow, very function, such programming"""
if random.randint(0, 1) == 0:
@ -92,7 +47,41 @@ def doge(phenny, input):
data = json.loads(data)
phenny.say("DOGE is at " + data['return']['markets']['DOGE']['lasttradeprice'] + " BTC")
else:
phenny.say("http://is.gd/zgopNT") # http://fc09.deviantart.net/fs70/f/2014/002/d/f/wow_by_kawiku-d70lb8q.png
links = [
"http://is.gd/zgopNT", # http://fc09.deviantart.net/fs70/f/2014/002/d/f/wow_by_kawiku-d70lb8q.png
"http://i.imgur.com/JphfPur.jpg",
"http://i.imgur.com/2MmvpGR.jpg",
"https://people.mozilla.org/~smartell/meme/such-logo.gif",
"http://i.imgur.com/e16WWlK.gif",
"http://i.imgur.com/6wx9Mf9.png",
"http://i.imgur.com/1GVIKve.jpg",
"http://i.imgur.com/606BPbS.png",
"http://i.imgur.com/VcwHcBO.jpg",
"http://i.imgur.com/3pnQciA.jpg",
"http://i.imgur.com/ampdE1n.jpg",
"http://i.imgur.com/QIqDXZw.gif",
"http://i.imgur.com/PoYoFXg.jpg",
"http://i.imgur.com/xcrvGLn.jpg",
"http://25.media.tumblr.com/282b439e00e13be63e932425388afa7d/tumblr_muopr4oEjG1qbhxqdo1_1280.jpg",
"http://i.imgur.com/EW37mvz.jpg",
"http://i.imgur.com/F2vYL4j.gif",
"http://25.media.tumblr.com/5b1de230c236cbc6310ae000e1a5cdc2/tumblr_mu7uxmD9i31rdj00zo1_500.jpg",
"http://i.imgur.com/Ck3qYFb.jpg",
"http://i.imgur.com/wp9x7GY.gif",
"https://pp.vk.me/c607929/v607929263/624e/K6NMxz0Cj7U.jpg",
"http://i.imgur.com/q7VKiiK.gif",
"http://i.imgur.com/RKHNg3v.jpg",
"http://i.imgur.com/l0YSsre.jpg",
"http://i.imgur.com/YRdsSHn.jpg",
"http://i.imgur.com/HhjNnIX.png",
"http://i.imgur.com/qLbktNN.jpg",
"http://i.imgur.com/NOIyL1K.jpg",
"http://i.imgur.com/v7gjzme.jpg",
"http://i.imgur.com/uI51MQy.png",
"http://i.imgur.com/JBXo2M5.jpg",
]
# ^ How to be productive on a Saturday
phenny.say(random.choice(links))
doge.commands = ['doge']

Loading…
Cancel
Save