1
0
mirror of https://github.com/MrDetonia/Maki.git synced 2024-11-14 08:49:35 -05:00

v0.18.0 added reload feature for auto-updating

This commit is contained in:
Zac Herd 2016-12-01 23:31:18 +00:00
parent 8c4b5cf0e9
commit 1af33fb13c
2 changed files with 38 additions and 1 deletions

32
bootstrap.sh Executable file
View File

@ -0,0 +1,32 @@
#!/bin/bash
# user to effectively run bot as (so we can safely run as root for pip)
puser="admin"
while :
do
date
echo Updating repository...
runuser -m $puser -c 'git pull'
# if root we can update discord.py
if [ "$EUID" -eq 0 ]
then
echo Updating discord.py...
python3 -m pip install -U https://github.com/Rapptz/discord.py/archive/master.zip#egg=discord.py[voice]
fi
echo Starting Maki...
runuser -m $puser -c 'rm -f ./reload'
runuser -m $puser -c 'python3 bot.py'
# okay to quit if rval was not 0
if [ ! -f ./reload ]
then
echo no reload file, stopping for realsies...
exit
fi
done
exit

7
bot.py
View File

@ -31,7 +31,7 @@ from secret import token, lfmkey
# CONFIGURATION # CONFIGURATION
# bot version # bot version
version = "v0.17.5" version = "v0.18.0"
# text shown by .help command # text shown by .help command
helptext = """I am a Discord bot written in Python helptext = """I am a Discord bot written in Python
@ -177,6 +177,11 @@ def on_message(message):
run = False run = False
yield from client.send_message(message.channel, 'But will I dream? ;_;') yield from client.send_message(message.channel, 'But will I dream? ;_;')
yield from client.logout() yield from client.logout()
if message.content[5:] == 'reload':
# touch a file called 'reload' which signals we should restart
with open('reload', 'a'):
os.utime('reload', None)
else: else:
# user not admin, refuse # user not admin, refuse
response = 'Don\'t be so rude! >:(' response = 'Don\'t be so rude! >:('