浏览代码

v0.18.0 added reload feature for auto-updating

master
Zac Herd 7 年前
父节点
当前提交
1af33fb13c
共有 2 个文件被更改,包括 38 次插入1 次删除
  1. +32
    -0
      bootstrap.sh
  2. +6
    -1
      bot.py

+ 32
- 0
bootstrap.sh 查看文件

@@ -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

+ 6
- 1
bot.py 查看文件

@@ -31,7 +31,7 @@ from secret import token, lfmkey
# CONFIGURATION

# bot version
version = "v0.17.5"
version = "v0.18.0"

# text shown by .help command
helptext = """I am a Discord bot written in Python
@@ -177,6 +177,11 @@ def on_message(message):
run = False
yield from client.send_message(message.channel, 'But will I dream? ;_;')
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:
# user not admin, refuse
response = 'Don\'t be so rude! >:('


正在加载...
取消
保存