Skip to content

Instantly share code, notes, and snippets.

@cr5315
Created May 10, 2014 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cr5315/7219e8fd3a05bc61b5fa to your computer and use it in GitHub Desktop.
Save cr5315/7219e8fd3a05bc61b5fa to your computer and use it in GitHub Desktop.
addie.cc module for my IRC bot (based on Code by Liamraystanley)
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