Answer the question
In order to leave comments, you need to log in
Why telegram bot on python2.7 works on 3.4 no?
Wrote an elementary bot in python, the code works if run on 2.7 with warnings about SSL, the code does not work on py3, it starts, but does not accept commands. Maybe it has something to do with blocking? How can you run?
from telegram.ext import Updater, CommandHandler
def start_bot(bot, update):
mytext = """Hello world /start
"""
update.message.reply_text(mytext)
print("start")
def main():
updtr = Updater('MY_TOKEN')
updtr.dispatcher.add_handler(CommandHandler("start", start_bot))
updtr.start_polling()
updtr.idle()
if __name__ == "__main__":
main()
Answer the question
In order to leave comments, you need to log in
It's hard to say so, try logging (insert code before def main
:
import logging
logging.basicConfig(
handlers=[
logging.FileHandler(
'bot.log',
'w',
'utf-8'
)
],
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.DEBUG,
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question