more API key stuff

This commit is contained in:
Luke Rogers 2012-02-16 23:30:06 +13:00
parent 8b1f46cb83
commit c0fb393b52
3 changed files with 7 additions and 4 deletions

View file

@ -33,6 +33,7 @@ if not os.path.exists('config'):
"bitly_user": "INSERT USERNAME FROM bitly.com HERE", "bitly_user": "INSERT USERNAME FROM bitly.com HERE",
"bitly_api": "INSERT API KEY FROM bitly.com HERE", "bitly_api": "INSERT API KEY FROM bitly.com HERE",
"wolframalpha": "INSERT API KEY FROM wolframalpha.com HERE", "wolframalpha": "INSERT API KEY FROM wolframalpha.com HERE",
"lastfm": "INSERT API KEY FROM lastfm HERE",
"mc_user": "INSERT MINECRAFT USERNAME HERE (used to check login servers in mctools.py)", "mc_user": "INSERT MINECRAFT USERNAME HERE (used to check login servers in mctools.py)",
"mc_pass": "INSERT MINECRAFT PASSWORD HERE (used to check login servers in mctools.py)" "mc_pass": "INSERT MINECRAFT PASSWORD HERE (used to check login servers in mctools.py)"
}, },

View file

@ -34,7 +34,7 @@ answers = [g + "As I see it, yes",
r + "Very doubtful"] r + "Very doubtful"]
@hook.command('8ball') @hook.command('8ball')
def ask(inp, me=None): def eightball(inp, me=None):
".8ball <question> - The all knowing magic eight ball, in electronic form. Ask a question and the answer shall be provided." ".8ball <question> - The all knowing magic eight ball, in electronic form. Ask a question and the answer shall be provided."
global nextresponsenumber global nextresponsenumber
inp = inp.strip() inp = inp.strip()

View file

@ -1,18 +1,20 @@
from util import hook, http from util import hook, http
api_key = "71ebca1c7e6b12ccd900efed95f7c1e0"
api_url = "http://ws.audioscrobbler.com/2.0/?format=json" api_url = "http://ws.audioscrobbler.com/2.0/?format=json"
@hook.command @hook.command
def lastfm(inp, nick='', say=None): def lastfm(inp, nick='', say=None, bot=None):
if inp: if inp:
user = inp user = inp
else: else:
user = nick user = nick
api_key = bot.config.get("api_keys", {}).get("lastfm", None)
if api_key is None:
return "error: no api key set"
response = http.get_json(api_url, method="user.getrecenttracks", response = http.get_json(api_url, method="user.getrecenttracks",
api_key=api_key, user=user, limit=1) api_key=api_key, user=user, limit=1)