W
W
Whoiam3212020-05-23 12:48:54
Python
Whoiam321, 2020-05-23 12:48:54

Telebot feedback bot?

I am writing a Telegram bot. The idea is simple, the user writes a message to the bot, which in turn redirects it to the channel. This has already been implemented. How to implement a response to a user through a channel using Reply?

import telebot
from telebot import TeleBot

bot: TeleBot = telebot.TeleBot('1111111111:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA')
TO_CHAT_ID = -1111111111111

@bot.message_handler(commands=['start'])
def start_message(message):
    markup = telebot.types.InlineKeyboardMarkup()
    markup.add(telebot.types.InlineKeyboardButton(text='1', callback_data=1))
    markup.add(telebot.types.InlineKeyboardButton(text='2', callback_data=2))
    markup.add(telebot.types.InlineKeyboardButton(text='3', callback_data=3))
    bot.send_message(message.chat.id, text="Choose one option here", reply_markup=markup)

    @bot.callback_query_handler(func=lambda call: True)
    def query_handler(call):

        bot.answer_callback_query(callback_query_id=call.id, text='Bla Bla')
        answer = ''
        if call.data == '1':
            answer = 'Info0'
        elif call.data == '2':
            answer = 'Info1'
        elif call.data == '3':
            answer = 'Info2'

        bot.send_message(call.message.chat.id, answer)


    @bot.message_handler(content_types=['text', 'document', 'photo'])
    def all_messages(message):
            bot.forward_message(TO_CHAT_ID, message.chat.id, message.message_id)
            bot.send_message(message.chat.id,
                     str(message.from_user.first_name) + ',' + ' Bla Bla Bla Bla')

    if int(message.chat.id) == TO_CHAT_ID:
        bot.forward_message(message.reply_to_message.forward_from.id, TO_CHAT_ID, message.text)
        bot.send_message(TO_CHAT_ID, text)

if __name__ == '__main__':
     bot.polling(none_stop=True, interval=0)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question