Answer the question
In order to leave comments, you need to log in
How do I call the asynchronous aiogram function dp.register_message_handler(...)?
There is an aiogram bot, but it has a function for sending from a telegram client
async def send_message(url):
api_id = ххххххххххх
api_hash = 'хххххххххххххххххххх'
client = TelegramClient('TeleSender', api_id, api_hash)
await client.start()
channel = await client.get_entity(url)
c = await client.get_participants(channel, limit=50000)
for user in c:
try:
u = user.username
await client.send_message(u, 'Тестовая рассылка.')
except Exception as e:
print(e)
@dp.message_handler()
async def messages(message):
if message.text == 'Заказать рассылку':
await message.reply( 'Пришлите ссылку на канал или чат с целевой аудиторией для рассылки')
dp.register_message_handler(message.text, send_message)
TypeError('unsupported callable') from ex TypeError: unsupported callable
await dp.register_message_handler(message.text, send_message)
dp.register_message_handler(message.text, await send_message)
dp.register_message_handler(await send_message(message.text))
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question