Merge branch 'develop' into refresh
Conflicts: plugins/spotify.py
This commit is contained in:
commit
4f2a3b099b
4 changed files with 21 additions and 13 deletions
|
@ -51,4 +51,4 @@ def geoip(inp):
|
||||||
data["cc"] = record["country_code"] or "N/A"
|
data["cc"] = record["country_code"] or "N/A"
|
||||||
data["country"] = record["country_name"] or "Unknown"
|
data["country"] = record["country_name"] or "Unknown"
|
||||||
data["city"] = record["city"] 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)
|
||||||
|
|
|
@ -36,10 +36,10 @@ def lastfm(inp, nick='', db=None, bot=None, notice=None):
|
||||||
api_key=api_key, user=user, limit=1)
|
api_key=api_key, user=user, limit=1)
|
||||||
|
|
||||||
if 'error' in response:
|
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:
|
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"]
|
tracks = response["recenttracks"]["track"]
|
||||||
|
|
||||||
|
@ -66,11 +66,11 @@ def lastfm(inp, nick='', db=None, bot=None, notice=None):
|
||||||
album = track["album"]["#text"]
|
album = track["album"]["#text"]
|
||||||
artist = track["artist"]["#text"]
|
artist = track["artist"]["#text"]
|
||||||
|
|
||||||
out = '{} {} "{}"'.format(user, status, title)
|
out = u'{} {} "{}"'.format(user, status, title)
|
||||||
if artist:
|
if artist:
|
||||||
out += " by \x02{}\x0f".format(artist)
|
out += u" by \x02{}\x0f".format(artist)
|
||||||
if album:
|
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
|
# append ending based on what type it was
|
||||||
out += ending
|
out += ending
|
||||||
|
|
|
@ -45,7 +45,8 @@ def spotify(inp):
|
||||||
except IndexError:
|
except IndexError:
|
||||||
return "Could not find track."
|
return "Could not find track."
|
||||||
url = sptfy(gateway.format(type, id))
|
url = sptfy(gateway.format(type, id))
|
||||||
return "\x02{}\x02 by \x02{}\x02 - \x02{}\x02".format(data["tracks"][0]["name"],
|
|
||||||
|
return "\x02{}\x02 by \x02{}\x02 - {}".format(data["tracks"][0]["name"],
|
||||||
data["tracks"][0]["artists"][0]["name"], url)
|
data["tracks"][0]["artists"][0]["name"], url)
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,7 +63,8 @@ def spalbum(inp):
|
||||||
except IndexError:
|
except IndexError:
|
||||||
return "Could not find album."
|
return "Could not find album."
|
||||||
url = sptfy(gateway.format(type, id))
|
url = sptfy(gateway.format(type, id))
|
||||||
return "\x02{}\x02 by \x02{}\x02 - \x02{}\x02".format(data["albums"][0]["name"],
|
|
||||||
|
return "\x02{}\x02 by \x02{}\x02 - {}".format(data["albums"][0]["name"],
|
||||||
data["albums"][0]["artists"][0]["name"], url)
|
data["albums"][0]["artists"][0]["name"], url)
|
||||||
|
|
||||||
|
|
||||||
|
@ -79,7 +81,8 @@ def spartist(inp):
|
||||||
except IndexError:
|
except IndexError:
|
||||||
return "Could not find artist."
|
return "Could not find artist."
|
||||||
url = sptfy(gateway.format(type, id))
|
url = sptfy(gateway.format(type, id))
|
||||||
return "\x02{}\x02 - \x02{}\x02".format(data["artists"][0]["name"], url)
|
|
||||||
|
return "\x02{}\x02 - {}".format(data["artists"][0]["name"], url)
|
||||||
|
|
||||||
|
|
||||||
@hook.regex(*http_re)
|
@hook.regex(*http_re)
|
||||||
|
@ -94,13 +97,14 @@ def spotify_url(match):
|
||||||
name = data["track"]["name"]
|
name = data["track"]["name"]
|
||||||
artist = data["track"]["artists"][0]["name"]
|
artist = data["track"]["artists"][0]["name"]
|
||||||
album = data["track"]["album"]["name"]
|
album = data["track"]["album"]["name"]
|
||||||
return "Spotify Track: \x02{}\x02 by \x02{}\x02 from the album \x02{}\x02 - \x02{}\x02".format(name, artist,
|
|
||||||
|
return "Spotify Track: \x02{}\x02 by \x02{}\x02 from the album \x02{}\x02 - {}".format(name, artist,
|
||||||
album, sptfy(
|
album, sptfy(
|
||||||
gateway.format(type, spotify_id)))
|
gateway.format(type, spotify_id)))
|
||||||
elif type == "artist":
|
elif type == "artist":
|
||||||
return "Spotify Artist: \x02{}\x02 - \x02{}\x02".format(data["artist"]["name"],
|
return "Spotify Artist: \x02{}\x02 - {}".format(data["artist"]["name"],
|
||||||
sptfy(gateway.format(type, spotify_id)))
|
sptfy(gateway.format(type, spotify_id)))
|
||||||
elif type == "album":
|
elif type == "album":
|
||||||
return "Spotify Album: \x02{}\x02 - \x02{}\x02 - \x02{}\x02".format(data["album"]["artist"],
|
return "Spotify Album: \x02{}\x02 - \x02{}\x02 - {}".format(data["album"]["artist"],
|
||||||
data["album"]["name"],
|
data["album"]["name"],
|
||||||
sptfy(gateway.format(type, spotify_id)))
|
sptfy(gateway.format(type, spotify_id)))
|
||||||
|
|
|
@ -28,8 +28,10 @@ def get_api(bot):
|
||||||
|
|
||||||
@hook.regex(*TWITTER_RE)
|
@hook.regex(*TWITTER_RE)
|
||||||
def twitter_url(match, bot=None):
|
def twitter_url(match, bot=None):
|
||||||
|
# Find the tweet ID from the URL
|
||||||
tweet_id = match.group(1)
|
tweet_id = match.group(1)
|
||||||
|
|
||||||
|
# Get the tweet using the tweepy API
|
||||||
api = get_api(bot)
|
api = get_api(bot)
|
||||||
if not api:
|
if not api:
|
||||||
return
|
return
|
||||||
|
@ -39,6 +41,7 @@ def twitter_url(match, bot=None):
|
||||||
except tweepy.error.TweepError:
|
except tweepy.error.TweepError:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Format the return the text of the tweet
|
||||||
text = " ".join(tweet.text.split())
|
text = " ".join(tweet.text.split())
|
||||||
|
|
||||||
if user.verified:
|
if user.verified:
|
||||||
|
@ -122,8 +125,9 @@ def twitter(inp, bot=None):
|
||||||
user = tweet.user
|
user = tweet.user
|
||||||
else:
|
else:
|
||||||
# ???
|
# ???
|
||||||
return "Unknown Error"
|
return "Invalid Input"
|
||||||
|
|
||||||
|
# Format the return the text of the tweet
|
||||||
text = " ".join(tweet.text.split())
|
text = " ".join(tweet.text.split())
|
||||||
|
|
||||||
if user.verified:
|
if user.verified:
|
||||||
|
|
Reference in a new issue