Made setplaying write to a temp file that gets loaded on start, added command to reset the status

dev
pocketjawa 2017-08-11 21:04:58 -04:00
parent 2d5819df59
commit ed3e20f50a
2 changed files with 17 additions and 2 deletions

View File

@ -10,6 +10,7 @@
**!ups**: Print the status of the main UPS. Updated once a minute.
**!tohru**: Posts a random pic of the one and only Tohru!
**!setplaying**: Sets the bot's Now Playing status to whatever you say (eg !setplaying with Tohru)
**!resetplaying**: Resets the bot's Now Playing status.
**!xkcd**: Posts a random xkcd comic
**!xkcd latest**: Posts the latest xkcd comic
**!xkcd x**: Posts xkcd comic number x (if it exists)

View File

@ -50,7 +50,11 @@ def on_ready():
print(client.user.id)
print('------')
yield from client.send_message(bot_channel_id, "This isn't Tatooine...")
yield from client.change_presence(game=discord.Game(name='with some droids'))
if os.path.isfile(cwd + "/tmp/status.txt"):
status_file = open(cwd + "/tmp/status.txt", "r")
yield from client.change_presence(game=discord.Game(name=status_file.read()))
else:
yield from client.change_presence(game=discord.Game(name='with some droids'))
@client.event
@asyncio.coroutine
@ -112,7 +116,17 @@ def on_message(message):
#Sets the bot's Now Playing status
elif message.content.lower().startswith('!setplaying'):
yield from client.change_presence(game=discord.Game(name=message.content.partition(' ')[2]))
args = message.content.partition(' ')[2]
yield from client.change_presence(game=discord.Game(name=args))
conf_file = open(cwd + "/tmp/status.txt", "w")
conf_file.write(args)
conf_file.close()
#Reset bot's Now Playing status
elif message.content.lower().startswith('!resetplaying'):
if os.path.isfile(cwd + "/tmp/status.txt"):
os.remove(cwd + "/tmp/status.txt")
yield from client.change_presence(game=discord.Game(name='with some droids'))
#xkcd comic fetcher
elif message.content.lower().startswith('!xkcd'):