Answer the question
In order to leave comments, you need to log in
Why does the bot send the result of the action to me and not to the user?
Good afternoon, the problem is that when I use the bot, everything works correctly, but when others try to use it, it answers all commands, but for some reason sends the result of the calculation to me, what's the matter?
@bot.message_handler(commands=['spam'])
def start_message(message):
bot.send_message(message.chat.id, 'Пиши что угодно')
@bot.message_handler(content_types=['text'])
def get_text(message):
text = message.text
markup = telebot.types.InlineKeyboardMarkup()
markup.add(telebot.types.InlineKeyboardButton(text='Десять', callback_data=10))
markup.add(telebot.types.InlineKeyboardButton(text='Пятьдесят', callback_data=50))
markup.add(telebot.types.InlineKeyboardButton(text='Сто', callback_data=100))
bot.send_message(message.chat.id, text="Выбери сколько раз повторить", 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='11111')
so = []
bot.send_message(message.chat.id, f'Пишем {call.data} раз')
for i in range(int(call.data)):
so.append(text)
sos = '\n'.join(so)
bot.send_message(message.chat.id, sos)
Answer the question
In order to leave comments, you need to log in
Why did you make a nested function structure? They should all be top notch.
@bot.message_handler(commands=['spam'])
def start_message(message):
bot.send_message(message.chat.id, 'Пиши что угодно')
@bot.message_handler(content_types=['text'])
def get_text(message):
text = message.text
markup = telebot.types.InlineKeyboardMarkup()
markup.add(telebot.types.InlineKeyboardButton(text='Десять', callback_data=10))
markup.add(telebot.types.InlineKeyboardButton(text='Пятьдесят', callback_data=50))
markup.add(telebot.types.InlineKeyboardButton(text='Сто', callback_data=100))
bot.send_message(message.chat.id, text="Выбери сколько раз повторить", 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='11111')
so = []
bot.send_message(message.chat.id, f'Пишем {call.data} раз')
for i in range(int(call.data)):
so.append(text)
sos = '\n'.join(so)
bot.send_message(call.message.chat.id, sos)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question