H
H
hamych2019-11-21 11:56:04
JavaScript
hamych, 2019-11-21 11:56:04

Bot buttons do not work in VK?

I have a bot in vk on javascript. And I made a keyboard / buttons that are located below the line for entering a message. They only work in PM, but when I use these buttons in conversations, they don't work. When I click on the button, the message "Help" is sent to the PM, and when I press these buttons in conversations, the following message is sent "@id bot Help" he does not see such a message, but if you write without @Id, then everything works fine. How to fix this, the players complain just :((

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pigeon1235, 2019-11-21
@Pigeon1235

It won't solve. VKontakte sends an appeal to the bot, and then a command from the button (@club1 VK) and this can only be solved by rewriting the bot so that it sees these messages

N
Nameless Man, 2019-11-24
@Almas_Almuhametov

try it

///////////////////////////
const GROUP_ID = ид группы без минуса;

const mentionPattern = new RegExp(
    String.raw`^(?:\[-${GROUP_ID}\|[^\]]+\])(?:[\s.,\'\"!?\-+]+|$)`,
    'i'
);

vk.updates.on('message', (context, next) => {
    if (context.isChat && !mentionPattern.test(context.text)) {
        return;
    }

    if (context.text) {
        context.text = context.text.replace(mentionPattern, '');   
    }

    return next();
});
//////////////////////////

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question