Как сделать эффект, будто бот печатает сообщение? Вот пример моего кода:
import telebot
from functools import wraps
from telegram import (ChatAction)
bot = telebot.TeleBot("TELEGRAM_API")
# Функция, отображающая ввод сообщения
def send_typing_action(func):
"""Отправляет действие ввода при обработке команды func"""
@wraps(func)
def command_func(update, context, *args, **kwargs):
context.bot.send_chat_action(chat_id=update.effective_message.chat_id, action=ChatAction.TYPING)
return func(update, context, *args, **kwargs)
return command_func
@send_typing_action
def my_handler(update, context):
pass
# Функция, обрабатывающая команду /start
@bot.message_handler(commands=["start"])
def start(m, res=False):
bot.send_message(m.chat.id, text=f'Привет, <b>{m.from_user.first_name} {m.from_user.last_name}</b>!'f'\nДавай говорить!'.format(m.from_user), parse_mode='html')
bot.polling(none_stop=True)