From 56e5e35b5340e313a13c182f1d6852197081e78625aa446d7b22412e321f09f9 Mon Sep 17 00:00:00 2001 From: andrea Date: Sat, 26 Jul 2025 18:28:46 +0200 Subject: [PATCH] upstart bot --- bot.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/bot.py b/bot.py index 3e85dba..7ca49a0 100644 --- a/bot.py +++ b/bot.py @@ -1,3 +1,5 @@ +import os as _os + from telegram.ext import Application from telegram.ext import CommandHandler from telegram.ext import MessageHandler @@ -30,10 +32,22 @@ async def bot_start(update, context): await update.message.reply_text('Ho creato il mondo di gioco', reply_markup=reply_markup) context.application.bot_data['arena'] = Arena +async def update_bot(update, context): + update.message.reply_text('Sto aggiornando il Bot...') + chat_id = update.effective_chat.id + if update.message.chat.id not in _botsyms.SUPER_USERS: return print(f'update_bot: user {chat_id} not allowed') + print(f'update_bot: {chat_id} bot is updating...') + os.system('cd ~/repo/battle_royale_sim; git pull') + os.system('systemctl --user start battle_royale.service') + update.message.reply_text('Bot aggiornato e riavviato!') + print(f'update_bot: {chat_id} bot successfully updated') + async def bot_commands(update, context): text= update.message.text chat_id = update.effective_chat.id + if text == 'upstart': return await update_bot(update, context) + if text == 'Init/Restart': print(f'bot_command: {chat_id} Init/Restart') return await bot_start(update, context)