Бот Telegram, который я создал с помощью Python, не обновляет свои результаты, когда я редактирую скрипт.Python

Программы на Python
Anonymous
Бот Telegram, который я создал с помощью Python, не обновляет свои результаты, когда я редактирую скрипт.

Сообщение Anonymous »

Я создал бота для Telegram, используя pip python-telegram-bot. После первой отладки все работало гладко, но теперь, когда я пытаюсь изменить/добавить выходные данные или отредактировать код, это вообще не влияет на работу бота.
Я попытался перезапустить скрипт, надеясь, что он чем-то занимается. с задержкой в ​​Интернете и серверами Telegram, которые не помогли.
from typing import final
from telegram import Update
from telegram.ext import Application, CommandHandler, MessageHandler, filters, ContextTypes

TOKEN: final = "(Redacted)"
BOT_USERNAME: final = '@ForsakenEarth_bot'

async def start_command(update: Update, context: ContextTypes.DEFAULT_TYPE):
await update.message.reply_text('bot works')

async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE):
await update.message.reply_text('Help command works')

async def custom_command(update: Update, context: ContextTypes.DEFAULT_TYPE):
await update.message.reply_text('custom command works')

def handle_response(text: str) -> str:
processed: str = text.lower()
if 'hello' in processed:
return 'hey there'
if 'how are you' in processed:
return 'Im fine'
if 'test' in processed:
return "Failed"
if 'select' in processed:
return start()
return 'I do not understand'

async def handle_message(update: Update, context: ContextTypes.DEFAULT_TYPE):
message_type: str = update.message.chat.type
text: str = update.message.text
print(f'User({update.message.chat.id}) in {message_type}: "{text}"')

if message_type == 'supergroup' or message_type == 'group':
if BOT_USERNAME in text:
new_text: str = text.replace(BOT_USERNAME, '').strip()
response: str = handle_response(new_text)
else:
return
else:
response: str = handle_response(text)

print('Bot:', response)
await update.message.reply_text(response)

async def error(update: Update, context: ContextTypes.DEFAULT_TYPE):
print(f'Update{update} caused error{context.error}')

if __name__ == '__main__':
print('Starting bot...')
app = Application.builder().token(TOKEN).build()

app.add_handler(CommandHandler('start', start_command))
app.add_handler(CommandHandler('help', help_command))
app.add_handler(CommandHandler('custom', custom_command))

app.add_handler(MessageHandler(filters.TEXT, handle_message))

app.add_error_handler(error)

print('polling...')
app.run_polling(poll_interval=3)


Подробнее здесь: https://stackoverflow.com/questions/782 ... hen-i-edit

Вернуться в «Python»