Answer the question
In order to leave comments, you need to log in
You need to somehow stop the cycle and after checking the moderator continue it. Telegram bot (Telebot). How to do it?
Here is a check for the user's message, after that the text of the message, the user's chat ID and the message ID are written to the global sheets
@bot.message_handler(content_types=['text'])
def send(message): # ПРОВЕРКА МОДЕРАТОРОМ
global Id_pp_users, Id_chat_user, Id_message_user # List
bot.send_message(message.chat.id,
"*Подождите, менеджер проверяет введённый ID...*\n Это может занять какое-то время...".format(
message.from_user, bot.get_me()),
parse_mode="Markdown")
if message.text.isdigit():
if len(str(message.text)) >= 8:
Id_pp_users.append(message.text)
Id_chat_user.append(message.chat.id)
Id_message_user.append(message.message_id)
funcFor()
def funcFor():
global chat_user_id
markup = types.InlineKeyboardMarkup(row_width=2)
item = types.InlineKeyboardButton("Подтвердить", callback_data='Successful')
item2 = types.InlineKeyboardButton("Отменить", callback_data='Failed')
item3 = types.InlineKeyboardButton("Недостаточный депозит", callback_data='FailedDep')
markup.add(item, item2, item3)
length1 = len(Id_pp_users)
length2 = len(Id_chat_user)
length3 = len(Id_message_user)
i = 0
j = 0
g = 0
while i < length1:
while j < length2:
while g < length3:
if i and j and g == 0:
bot.forward_message(TO_CHAT_ID, Id_chat_user[j], Id_message_user[g])
bot.send_message(TO_CHAT_ID,
Id_pp_users[i].format(bot.get_me()), reply_markup=markup)
chat_user_id = Id_chat_user[j]
else:
i += 1
j += 1
g += 1
@bot.callback_query_handler(func=lambda call: True)
def check(call):
if call.message:
if call.data == "Successful":
bot.send_message(chat_user_id, "Текст который отправится рользователю")
bot.send_message(TO_CHAT_ID, "*Подтверждено*", parse_mode="Markdown")
elif call.data == "Failed":
bot.send_message(chat_user_id, "Текст который отправится рользователю")
bot.send_message(TO_CHAT_ID, "*Отказано*", parse_mode="Markdown")
elif call.data == "FailedDep":
bot.send_message(chat_user_id, "Текст который отправится рользователю")
bot.send_message(TO_CHAT_ID, "*Отказано по причине...*", parse_mode="Markdown"
Answer the question
In order to leave comments, you need to log in
No. You need to change the architecture of the bot, so you will not achieve results.
1. Incoming requests are added to the queue (and better in the database).
2. The bot periodically checks for unverified requests and throws them out to the manager. Since the manager is a leisurely creature, this can be done once every couple of minutes or even less often.
3. Based on the response from the manager, the request is marked as verified (approved/rejected).
4. The bot periodically checks to see if there are valid but not processed requests. If there are, processes them and marks them as processed.
5. Optional: Periodically, requests marked as processed are deleted from the database.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question