N
N
Nikita228Gym2021-07-16 08:07:03
Python
Nikita228Gym, 2021-07-16 08:07:03

How can I delete the selected part of SMS in VK?

I don’t know how to delete selected SMS in a row in VK

, for example, the dialogue:
hello ,
how are you
aaa
(I write the command "delete {number of sms that I want to delete})" delete 3)
and it deletes sms = [hello, how are you, aaa]

примерный мой код:
def primer():
    commands

for event in longpoll.listen():
    if event.type == VkEventType.MESSAGE_NEW and event.from_me:
        try:
            if event.text == "пример":
                commands ()


I want to do that I could delete sms help please

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WolfInChains, 2021-07-16
@Nikita228gym

Aren't you tired of sending the same "code", with different questions, and asking to write a bot instead of you? So you won't learn anything. It's time to think a little.
You only need 2 methods. The first one is
https://vk.com/dev/messages.getHistory
Use it to get the IDs of the latest messages and sort, leaving only those where the sender's ID is equal to your ID. To specify the number of messages to delete, you can simply split the command via split and then reduce the resulting list with message IDs by the number from the command plus 1 (to delete the message with the command itself).
Then just put the message IDs (before that, having combined them into 1 line through join) into the
https://vk.com/dev/messages.delete method
There is enough information on the Internet about split and join.
Nothing complicated, you just need to think a little, and not ask to write everything for you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question