LastFM: more immersive nowplaying output (#95)

* Making the output for nowplaying immersive

Added a simple conditional to make the output of now playing a little more aesthetically pleasing.
mogad0n is listening to Roller Mobster by Carpenter Brut [Trilogy]
vs
mogad0n listened to Roller Mobster by Carpenter Brut [Trilogy] just now.
Close #92
This commit is contained in:
mogad0n 2020-09-11 08:57:22 +05:30 committed by GitHub
parent f548d2dd54
commit 2a098528c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -113,7 +113,7 @@ class LastFM(callbacks.Plugin):
tformat = conf.supybot.reply.format.time()
time = "at %s" % datetime.fromtimestamp(time).strftime(tformat)
except KeyError: # Nothing given by the API?
time = "just now"
time = None
public_url = ''
# If the DDG plugin from this repository is loaded, we can integrate
@ -148,8 +148,12 @@ class LastFM(callbacks.Plugin):
except KeyError:
pass
s = '%s listened to %s by %s %s %s%s. %s' % (ircutils.bold(user), ircutils.bold(track),
ircutils.bold(artist), album, time, ext_info, public_url)
if time is None:
s = '%s is listening to %s by %s %s %s. %s' % (ircutils.bold(user), ircutils.bold(track),
ircutils.bold(artist), album, ext_info, public_url)
else:
s = '%s listened to %s by %s %s %s%s. %s' % (ircutils.bold(user), ircutils.bold(track),
ircutils.bold(artist), album, time, ext_info, public_url)
irc.reply(utils.str.normalizeWhitespace(s))
@wrap(["something"])