fixed lastfm for default user

This commit is contained in:
neersighted 2012-02-28 08:17:18 +08:00 committed by lukeroge
parent ea2468b742
commit b3326e0fe9

View file

@ -1,7 +1,13 @@
from util import hook, http from util import hook, http
@hook.command('l')
@hook.command('lfm')
@hook.command @hook.command
def lastfm(inp, nick='', say=None, db=None, bot=None): def lastfm(inp, nick='', say=None, db=None, bot=None):
if inp:
user = inp
else:
user = nick
".lastfm <user> - display the now playing (or recent) tracks of a LastFM user" ".lastfm <user> - display the now playing (or recent) tracks of a LastFM user"
db.execute("create table if not exists lastfm(nick primary key, acc)") db.execute("create table if not exists lastfm(nick primary key, acc)")
sql = db.execute("select acc from lastfm where nick=lower(?)", (nick,)).fetchone(); sql = db.execute("select acc from lastfm where nick=lower(?)", (nick,)).fetchone();
@ -10,7 +16,6 @@ def lastfm(inp, nick='', say=None, db=None, bot=None):
if api_key is None: if api_key is None:
return "error: no api key set" return "error: no api key set"
if sql: if sql:
if not inp: user = sql[0] if not inp: user = sql[0]
else: else: