def Reload(cmd):
debug(cmd.text)
if not cmd.from_user.username == botadm:
bot.reply_to(cmd, "Só patrão pode isso.")
return
try:
debug(cmd)
bot.reply_to(cmd, "Reloading...")
if os.path.exists(SCRIPTHOME):
os.chdir(SCRIPTHOME)
oscmd = "git pull -f"
debug(oscmd)
os.system(oscmd)
botname = "stallmanbot.py"
debug(oscmd)
oscmd = "diff -q %s %s/bin/%s" % (botname, HOME, botname)
res = os.system(oscmd)
if res:
# new version detected
res = os.system("%s %s" % (sys.executable, sys.argv[0]))
if res != 0:
debug("Versão bugada")
bot.send_message(cmd.chat.id, "Python crashed. Vou carregar saporra não. Vai que...")
return
debug("Updating bot...")
shutil.copy(botname, "%s/bin/%s" % (HOME, botname))
bot.send_message(cmd.chat.id, "Bot version updated.")
# check first
python = sys.executable
os.execl(python, python, *sys.argv)
except Exception as e:
try:
bot.reply_to(cmd, u"Deu merda... %s" % e)
except Exception as z:
print u"%s" % z
评论列表
文章目录