upstart bot

This commit is contained in:
andrea
2025-07-26 18:28:46 +02:00
parent f55a6a2cdb
commit 56e5e35b53

14
bot.py
View File

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