Answer the question
In order to leave comments, you need to log in
Why Telegram bot constantly sends a welcome message?
I made a greeting using a check for a message sent by the user. If you start a conversation with the bot, he will successfully send it, after which he continues to do this every 5-10 seconds. To receive updates, I use a webhook, accepting requests for pythonanywhere.
proxy_url = "http://proxy.server:3128"
telepot.api._pools = {
'default': urllib3.ProxyManager(proxy_url=proxy_url, num_pools=3, maxsize=10, retries=False, timeout=30),
}
telepot.api._onetime_pool_spec = (urllib3.ProxyManager, dict(proxy_url=proxy_url, num_pools=1, maxsize=1, retries=False, timeout=30))
secret = "<ключ>"
bot = telepot.Bot('<токен бота>')
bot.setWebhook("https://ganduras3.pythonanywhere.com/{}".format(secret), max_connections=100000000)
app = Flask(__name__)
@app.route('/{}'.format(secret), methods=["POST"])
def telegram_webhook():
update = request.get_json()
if "message" in update:
text = update["message"]["text"]
chat_id = update["message"]["chat"]["id"]
if text == '/start':
bot.sendMessage(chat_id, 'здравствуйте, добрые люди с toster.ru')
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