Answer the question
In order to leave comments, you need to log in
How to collect several information and send it at the right time?
LongPoll VKontakte returns various events, and one of them in object.action is chat_invite_user, which fires every time a new participant is invited to the conversation.
And this event is checked in my code and every time a new participant is invited, my bot greets him: "Welcome you First Name Last Name!", but there is such a function in VK where you can invite several participants at once and for example if the conversation administrator invites 10 participants, the bot greets everyone with a separate message, which is extremely inconvenient and not beautiful, I would like to implement something like this: "Greetings to you First Name Last Name, First Name Last Name, First Name Last Name ...", but I can't imagine how to do it, because longpoll sends a separate event for each.
The code:
from vkbottle import Bot, Message
from vkbottle.rule import ChatActionRule
from modules import get_name, settings
bot = Bot(tokens=settings.TOKEN, group_id=settings.GROUP_ID)
@bot.on.chat_message(ChatActionRule(["chat_invite_user"]))
async def invite(ans: Message):
first_name, last_name, id = get_name(ans.action.member_id)
await ans(f"Приветствуем вас @id{id} ({first_name} {last_name})")
bot.run_polling(skip_updates=False)
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