Code:
from flask import Flask, request
import telebot
from telebot import types
secret = ""
bot = telebot.TeleBot(TOKEN, threaded=False)
bot.remove_webhook()
bot.set_webhook(url="https://USER.pythonanywhere.com/")
app = Flask(__name__)
@app.route('/', methods=["POST"])
def webhook():
bot.process_new_updates([telebot.types.Update.de_json(request.stream.read().decode("utf-8"))])
return "!", 200
@bot.message_handler(commands=['start', 'help'])
def startCommand(message):
bot.send_message(message.chat.id, 'Hi *' + message.chat.first_name + '*!' , parse_mode='Markdown', reply_markup=types.ReplyKeyboardRemove())
I installed the library using pip install pyTelegramBotAPI
. I have seen solutions using virtual environments but I can't seem to figure out how to set that up exactly.