correctly handle resolving and whitesace

master
Casey Link 2011-02-05 14:12:47 -05:00
parent df48e246a7
commit 93c39b3f28
1 changed files with 11 additions and 5 deletions

View File

@ -70,11 +70,17 @@ lastfm_set.rule = (['lastfm-set'], r'(\S+)\s+(?:(.*?),(.*)|(\S+))')
def now_playing(phenny, input):
nick = input.nick
user = input.group(2)
if not user or len(user.strip()) == 0:
user = resolve_username(nick)
if not user:
user = ""
arg = input.group(2)
if not arg or len(arg.strip()) == 0:
user = resolve_username(nick) # use the sender
if not user: #nick didnt resolve
user = nick
else: # use the argument
user = resolve_username(arg.strip())
if not user: # user didnt resolve
user = arg
user = user.strip()
try:
req = urlopen("%smethod=user.getrecenttracks&user=%s" % (APIURL, urlquote(user)))
except HTTPError, e: