A
A
Arsen Dulaev2022-01-29 22:02:53
Bots
Arsen Dulaev, 2022-01-29 22:02:53

How to send a message to everyone subscribed to the bot?

There is a bot that performs the task of one of the available photos. You need to add the ability to send a message to all subscribed to the bot. There are IDs of all signed ones. They are in the database. Ideally, I send a message to the bot, and he sends it to everyone whose ID is in the database.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Arsen Dulaev, 2022-01-31
@raijin57

Decided this way:

import telebot
from telebot import custom_filters

bot = telebot.TeleBot('token')

@bot.message_handler(chat_id=[''], content_types=['text'])
def admin_rep(message):
    bot.send_message('', message.text)

@bot.message_handler(content_types=['text'])
def not_admin(message):
    bot.send_message(message.chat.id, "You are not allowed to use this command")

bot.add_custom_filter(custom_filters.ChatFilter())

bot.infinity_polling()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question