Answer the question
In order to leave comments, you need to log in
How to make the bot react to messages that you reply to, and not forward?
def isAdmins(event, cmd):
if event.type == VkBotEventType.MESSAGE_NEW and event.object.text.lower() == cmd:
if event.obj.from_id in admins:
return True
return False
while True:
try:
for event in longpoll.listen():
if isAdmins(event, 'kick' and 'кик'):
if event.obj["fwd_messages"]:
user_id = event.obj["fwd_messages"][0]["from_id"]
vk.messages.send(peer_id=event.object.peer_id, sticker_id='11724', message='Исключаю @id' + str(user_id) + '(пользователя)...' '\n❌ Бан на сутки!\n После истечения срока написать ... или ...\n Чтобы узнать правила напишите в @letsbot (ЛС боту) "Правила".', random_id=0)
time.sleep(1)
vk.messages.removeChatUser(chat_id=event.chat_id, user_id=user_id, member_id=user_id)
vk.messages.send(peer_id=event.object.peer_id, message='@id' + str(user_id) + '(Пользователь) был успешно исключён из беседы на сутки ✔.', random_id=0)
except Exception as e:
print(e)
Answer the question
In order to leave comments, you need to log in
Read the documentation for the message type.
Each forwarded message is passed in the fwd_messages field, if this field is not present or it is empty, the message is not forwarded.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question