Answer the question
In order to leave comments, you need to log in
How to display telegram bot messages to the network itself?
problem: an ancient project, it used to run perfectly, but now a draft of a regular telegram bot is failing. Namely, it does not give any answers in the telegram itself. There is text in the output console, but nothing in the cart itself. I tried to reinstall the whole python from 0 with cleaning modules, rewrite this draft from scratch. What is the problem?
from telegram.ext import Updater, CommandHandler
from glob import glob
from random import choice
import logging
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level = logging.INFO,
filename='bot.log'
)
def greet_user(bot, update):
text = 'Привет, меня зовут бот Name!\n'
print(text)
text2 = "text"
update.message.reply_text(text + text2)
text3 = 'Хорошего дня, надеюсь, мы увидимся ещё!'
update.message.reply_text(text3)
def version_bot(bot, update):
verinfo = "text"
print(verinfo)
update.message.reply_text(verinfo)
def send_cat_picture(bot, update):
cat_list = glob('images/cat*.jp*g')
cat_pic = choice(cat_list)
bot.send_photo(chat_id=update.message.chat.id, photo=open(cat_pic, 'rb'))
def main():
mybot = Updater("TOKEN")
logging.info('Бот запускается...')
dp = mybot.dispatcher
dp.add_handler(CommandHandler('start', greet_user))
dp.add_handler(CommandHandler('cat', send_cat_picture))
dp.add_handler(CommandHandler('version', version_bot))
mybot.start_polling()
mybot.idle()
main()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question