minetestbot-modules/shortutils.py

100 lines
3.6 KiB
Python
Raw Normal View History

2013-09-06 15:02:57 -07:00
#!/usr/bin/env python
"""
shortutil.py - Phenny Custom Shortcut Module
Copyright 2013 jmf
Licensed under the WTFPL.
http://www.wtfpl.net/txt/copying/
Module for phenny:
http://inamidst.com/phenny/
"""
2014-02-27 08:43:33 -08:00
import random
2014-07-20 07:13:59 -07:00
import web
2014-02-27 08:43:33 -08:00
2014-06-28 07:08:20 -07:00
def make_cmd(cmd, txt):
def m(phenny, input):
t = txt
if input.group(2):
u = input.group(2).strip() + ", "
2014-06-28 07:08:20 -07:00
t = t[0].upper() + t[1:]
else:
u = ""
2014-06-28 07:08:20 -07:00
phenny.say(u + t)
2014-06-30 11:18:48 -07:00
m.commands = [cmd]
2014-06-28 07:08:20 -07:00
return m
2013-09-06 15:02:57 -07:00
2014-06-28 07:08:20 -07:00
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.")
2013-09-06 15:02:57 -07:00
def next(phenny, input):
"""Next one please"""
phenny.say("Another satisfied customer. Next!")
2013-09-09 10:52:20 -07:00
next.commands = ['next']
2014-01-07 01:28:31 -08:00
def doge(phenny, input):
"""much wow, very function, such programming"""
2014-02-27 08:43:33 -08:00
if random.randint(0, 1) == 0:
2014-07-20 10:19:35 -07:00
data, sc = web.get('http://pubapi.cryptsy.com/api.php?method=singlemarketdata&marketid=132')
2014-07-20 10:24:24 -07:00
data = str(data, 'utf-8')
2014-07-20 07:13:59 -07:00
data = web.json(data)
2014-02-27 08:43:33 -08:00
phenny.say("DOGE is at " + data['return']['markets']['DOGE']['lasttradeprice'] + " BTC")
else:
2014-06-28 07:08:20 -07:00
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))
2014-01-07 01:28:31 -08:00
doge.commands = ['doge']
def btc(phenny, input):
"""Get current Bitcoin price"""
2014-07-20 10:24:24 -07:00
data, sc = web.get('https://blockchain.info/ticker')
data = str(data, 'utf-8')
data = web.json(data)
if input.group(2):
currency = input.group(2).strip().upper()
else:
currency = 'USD'
if not currency in data.keys():
return phenny.reply('Unknown currency. Supported currencies: ' + ', '.join(data.keys()))
phenny.say('1 BTC = %.4f %s' % (data[currency]['15m'], data[currency]['symbol']))
btc.commands = ['btc']