Forums

Telebot, flask strange error

.

#!/usr/bin/python3.5
import telebot
from flask import Flask, request

token    = 'some_token_here'

sec = 'f5a403929s11d'

hhost    = 'https://telegatest.pythonanywhere.com/' + sec

bot = telebot.TeleBot(token, threaded=False)
bot.remove_webhook()
bot.set_webhook(url=hhost)
app = Flask(__name__)


@app.route('/' + sec, methods=['POST'])
def webhook():
    update = telebot.types.Update.de_json(request.stream.read().decode('utf-8'))
    bot.process_new_updates([update])
    return 'ok'


@bot.message_handler(commands=['help', 'start'])
def send_welcome(message):
    bot.send_message(message.chat.id,"Hi there, I am EchoBot.\n""I am here to echo your kind words back to you.")


@bot.message_handler(func=lambda message: True, content_types=['text'])
def echo_message(message):
    bot.reply_to(message, message.text)

A little mess with code sample, but code is ok, try not get triggered, sry =) problem is here, error log shows me __init__() got an unexpected keyword argument 'threaded' but i installed telebot with pip also installed pytelegrambotapi, what could go wrong?

[edit by admin: formatting]

well, after pip uninstall, pip install, telebot, pyTelegramBotAPI, many times (or after I started this topic, THANK YOU MYSTERIOUS FRIENDY MODERATOR!!!!!) all started to work as it should, no code change =)

Weird! Perhaps it was something to do with the version of pyTelegramBotAPI you had installed. Or perhaps the Python version you were installing it for? Anyway, glad to hear you got it sorted. If you hit similar problems in the future, the full stack trace would be a useful bit of information to help us help you.

i have the same problem but installing and uninstalling doesn't help

i've solved this problem. Mistake was that i installed "telebot" and "pytelegrambotapi" at the same time. I uninstalled both of them completely(pip uninstall telebot, pip uninstall pytelegrambotapi) and reinstalled only pytelegrambotapi.

Glad to know that you solved it.