From 93c39b3f281f6669217585552c3d7c4a0d4f4266 Mon Sep 17 00:00:00 2001 From: Casey Link Date: Sat, 5 Feb 2011 14:12:47 -0500 Subject: [PATCH] correctly handle resolving and whitesace --- modules/lastfm.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/modules/lastfm.py b/modules/lastfm.py index 0493a32..81e1666 100644 --- a/modules/lastfm.py +++ b/modules/lastfm.py @@ -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 = nick + 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: