2013-09-07 00:02:57 +02: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 17:43:33 +01:00
import random
import urllib2
import json
2013-09-07 00:02:57 +02:00
def rtfm ( phenny , input ) :
""" Manual reference command """
2013-10-23 18:45:45 +02:00
if input . group ( 2 ) :
2013-10-23 17:56:33 +02:00
u = input . group ( 2 ) . strip ( ) + " , "
else :
u = " "
2013-10-23 17:28:44 +01:00
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. " )
2013-09-07 00:02:57 +02:00
2013-09-09 19:52:20 +02:00
rtfm . commands = [ ' rtfm ' ]
2013-09-07 00:02:57 +02:00
2013-09-09 18:48:24 +02:00
def questions ( phenny , input ) :
2013-09-07 00:02:57 +02:00
""" Ask smart questions """
2013-10-23 18:45:45 +02:00
if input . group ( 2 ) :
2013-10-23 17:56:33 +02:00
u = input . group ( 2 ) . strip ( ) + " , "
else :
u = " "
2013-10-23 17:28:44 +01:00
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 " )
2013-09-07 00:02:57 +02:00
2013-09-09 19:52:20 +02:00
questions . commands = [ ' questions ' ]
2013-09-07 00:02:57 +02:00
def next ( phenny , input ) :
""" Next one please """
phenny . say ( " Another satisfied customer. Next! " )
2013-09-09 19:52:20 +02:00
next . commands = [ ' next ' ]
2013-10-23 16:31:57 +01:00
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
2013-10-23 18:45:45 +02:00
if input . group ( 2 ) :
2013-10-23 17:56:33 +02:00
u = input . group ( 2 ) . strip ( ) + " , "
else :
u = " "
2013-10-23 17:27:18 +01:00
phenny . say ( u + " someone thinks you need to brush up on or learn Lua, please go to: http://lua.org/pil/ " )
2013-10-23 16:31:57 +01:00
pil . commands = [ ' pil ' ]
2013-10-23 17:11:52 +01:00
def git ( phenny , input ) :
""" Git Manual link """
2013-10-23 18:45:45 +02:00
if input . group ( 2 ) :
2013-10-23 17:11:52 +01:00
u = input . group ( 2 ) . strip ( ) + " , "
else :
u = " "
2013-10-23 17:27:18 +01:00
phenny . say ( u + " someone thinks you need to brush up on or learn Git, please go to: http://git-scm.com/book/ " )
2013-10-23 17:11:52 +01:00
2013-10-23 19:15:54 +01:00
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. " )
2014-01-07 10:28:31 +01:00
proc . commands = [ ' proc ' ]
def doge ( phenny , input ) :
""" much wow, very function, such programming """
2014-02-27 17:43:33 +01:00
if random . randint ( 0 , 1 ) == 0 :
f = urllib2 . urlopen ( ' http://pubapi.cryptsy.com/api.php?method=singlemarketdata&marketid=132 ' )
data = f . read ( )
f . close ( )
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
2014-01-07 10:28:31 +01:00
doge . commands = [ ' doge ' ]
2014-02-27 19:43:29 +01:00
def btc ( phenny , input ) :
""" Get current Bitcoin price """
for x in phenny . bot . commands [ " high " ] . values ( ) :
if x [ 0 ] . __name__ == " aa_hook " :
if x [ 0 ] ( phenny , input ) :
return
f = urllib2 . urlopen ( ' https://blockchain.info/ticker ' )
data = f . read ( )
f . close ( )
data = json . loads ( 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 ' ]