C
C
ChaykaStar2020-12-01 01:02:57
Python
ChaykaStar, 2020-12-01 01:02:57

How to pick up a message in a telegram bot and send it to the Telebot mailing list, IMPORTANT not forward_message?

All the best time! It is necessary to implement mass mailing of messages with Inline_keyboard, the client generates messages of this type in a third-party bot and sends it to our bot. forward_message is not suitable, because in this case the signature "Forwarded from N" is above the message. I can't find the right solution.

@bot.message_handler(func=lambda msg: msg.forward_date != None, content_types=['photo', 'document', 'text'])
def ResendMessages(msg):
  print(msg)
  stopping == 'None'
  try:
    global last_message, count_blocked, count
    last_message = msg.message_id
    if msg.from_user.id in admin_id:
      count = 0
      count_blocked = 0
      with open('last_mass_sending_message.txt', 'w', encoding = 'UTF-8') as mes_base:		
        mes_base.write(f'{count_blocked}\n{count}\n{last_message}')
      with open('users_dbase.json', 'r') as ub:
        users_ids = json.load(ub)
        units = len(users_ids)
      for user in users_ids:
        print(user)
        try:
          print(msg.message_id)
          # bot.forward_message(user, admin_id[0], msg.message_id)
          bot.send_message(user, msg.text)
          count += 1
        except Exception as e:
          print(e)
          count_blocked += 1
        if stopping == 'stop_the_function':
          break
    with open('last_mass_sending_message.txt', 'w', encoding = 'UTF-8') as mes_base:
      mes_base.write(f'{count_blocked}\n{count}\n{last_message}')
    if stopping != 'stop_the_function':
      bot.send_message(admin_id[0], f'Рассылка завершена', reply_markup = markup_inline_back)

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