From b917b495f78cc9425971cc086fc52db4a52c68f5 Mon Sep 17 00:00:00 2001 From: prplz Date: Tue, 18 Mar 2014 16:20:12 +1100 Subject: [PATCH 1/4] Use unicode string for returned message in geoip --- plugins/geoip.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/geoip.py b/plugins/geoip.py index e46cde9..b7ca61d 100644 --- a/plugins/geoip.py +++ b/plugins/geoip.py @@ -51,4 +51,4 @@ def geoip(inp): data["cc"] = record["country_code"] or "N/A" data["country"] = record["country_name"] or "Unknown" data["city"] = record["city"] or "Unknown" - return "\x02Country:\x02 {country} ({cc}), \x02City:\x02 {city}{region}".format(**data) + return u"\x02Country:\x02 {country} ({cc}), \x02City:\x02 {city}{region}".format(**data) From e46cb5c8260ad595f36fec52b0a8609231f2a423 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Wed, 19 Mar 2014 17:40:21 +1300 Subject: [PATCH 2/4] Update twitter.py --- plugins/twitter.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/twitter.py b/plugins/twitter.py index 1983cef..c83ea67 100644 --- a/plugins/twitter.py +++ b/plugins/twitter.py @@ -28,8 +28,10 @@ def get_api(bot): @hook.regex(*TWITTER_RE) def twitter_url(match, bot=None): + # Find the tweet ID from the URL tweet_id = match.group(1) + # Get the tweet using the tweepy API api = get_api(bot) if not api: return @@ -39,6 +41,7 @@ def twitter_url(match, bot=None): except tweepy.error.TweepError: return + # Format the return the text of the tweet text = " ".join(tweet.text.split()) if user.verified: @@ -122,8 +125,9 @@ def twitter(inp, bot=None): user = tweet.user else: # ??? - return "Unknown Error" + return "Invalid Input" + # Format the return the text of the tweet text = " ".join(tweet.text.split()) if user.verified: From 7f3b433209361080de3a8872163714d6c60b4ae8 Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Thu, 27 Mar 2014 10:08:54 +1300 Subject: [PATCH 3/4] Fix lastfm --- plugins/lastfm.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/lastfm.py b/plugins/lastfm.py index 87ca6e7..b928b1e 100644 --- a/plugins/lastfm.py +++ b/plugins/lastfm.py @@ -36,10 +36,10 @@ def lastfm(inp, nick='', db=None, bot=None, notice=None): api_key=api_key, user=user, limit=1) if 'error' in response: - return "Error: {}.".format(response["message"]) + return u"Error: {}.".format(response["message"]) if not "track" in response["recenttracks"] or len(response["recenttracks"]["track"]) == 0: - return 'No recent tracks for user "{}" found.'.format(user) + return u'No recent tracks for user "{}" found.'.format(user) tracks = response["recenttracks"]["track"] @@ -66,11 +66,11 @@ def lastfm(inp, nick='', db=None, bot=None, notice=None): album = track["album"]["#text"] artist = track["artist"]["#text"] - out = '{} {} "{}"'.format(user, status, title) + out = u'{} {} "{}"'.format(user, status, title) if artist: - out += " by \x02{}\x0f".format(artist) + out += u" by \x02{}\x0f".format(artist) if album: - out += " from the album \x02{}\x0f".format(album) + out += u" from the album \x02{}\x0f".format(album) # append ending based on what type it was out += ending From 5ee62107f942de1e96877bd3072e20cf19d5549e Mon Sep 17 00:00:00 2001 From: Luke Rogers Date: Mon, 31 Mar 2014 20:23:45 +1300 Subject: [PATCH 4/4] unbold --- plugins/spotify.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/spotify.py b/plugins/spotify.py index ae0b339..9897235 100644 --- a/plugins/spotify.py +++ b/plugins/spotify.py @@ -45,7 +45,7 @@ def spotify(inp): except IndexError: return "Could not find track." url = sptfy(gateway.format(type, id)) - return u"\x02{}\x02 by \x02{}\x02 - \x02{}\x02".format(data["tracks"][0]["name"], + return u"\x02{}\x02 by \x02{}\x02 - {}".format(data["tracks"][0]["name"], data["tracks"][0]["artists"][0]["name"], url) @@ -62,7 +62,7 @@ def spalbum(inp): except IndexError: return "Could not find album." url = sptfy(gateway.format(type, id)) - return u"\x02{}\x02 by \x02{}\x02 - \x02{}\x02".format(data["albums"][0]["name"], + return u"\x02{}\x02 by \x02{}\x02 - {}".format(data["albums"][0]["name"], data["albums"][0]["artists"][0]["name"], url) @@ -79,7 +79,7 @@ def spartist(inp): except IndexError: return "Could not find artist." url = sptfy(gateway.format(type, id)) - return u"\x02{}\x02 - \x02{}\x02".format(data["artists"][0]["name"], url) + return u"\x02{}\x02 - {}".format(data["artists"][0]["name"], url) @hook.regex(*http_re) @@ -94,13 +94,13 @@ def spotify_url(match): name = data["track"]["name"] artist = data["track"]["artists"][0]["name"] album = data["track"]["album"]["name"] - return u"Spotify Track: \x02{}\x02 by \x02{}\x02 from the album \x02{}\x02 - \x02{}\x02".format(name, artist, + return u"Spotify Track: \x02{}\x02 by \x02{}\x02 from the album \x02{}\x02 - {}".format(name, artist, album, sptfy( gateway.format(type, spotify_id))) elif type == "artist": - return u"Spotify Artist: \x02{}\x02 - \x02{}\x02".format(data["artist"]["name"], + return u"Spotify Artist: \x02{}\x02 - {}".format(data["artist"]["name"], sptfy(gateway.format(type, spotify_id))) elif type == "album": - return u"Spotify Album: \x02{}\x02 - \x02{}\x02 - \x02{}\x02".format(data["album"]["artist"], + return u"Spotify Album: \x02{}\x02 - \x02{}\x02 - {}".format(data["album"]["artist"], data["album"]["name"], sptfy(gateway.format(type, spotify_id)))