Created
May 10, 2014 19:56
-
-
Save cr5315/7219e8fd3a05bc61b5fa to your computer and use it in GitHub Desktop.
addie.cc module for my IRC bot (based on Code by Liamraystanley)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from util.hook import * | |
import urllib2 | |
@hook(cmds=['addie'], ex='addie cr5315 doge') | |
def addie(code, input): | |
"""addie <user> <coin> - Get an address from addie.cc""" | |
try: | |
args = input.group(2).split(' ') | |
except: | |
args = [] | |
if len(args) == 0: | |
user = input.nick | |
coin = 'doge' | |
elif len(args) == 1: | |
user = args[0] | |
coin = 'doge' | |
elif len(args) >= 2: | |
user = args[0] | |
coin = args[1] | |
else: | |
return code.say('{red}{b}Invalid usage. Use %shelp addie' % code.prefix) | |
query = 'http://addie.cc/api/' + user + '/' + coin | |
# code.say(query) | |
try: | |
response = urllib2.urlopen(query) | |
address = response.read() | |
if len(address) > 0: | |
code.say('The ' + coin.upper() + ' address for ' + user + ' is ' + address) | |
else: | |
code.reply('There was an error fetching the address') | |
except: | |
code.reply('There was an error fetching the address') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment