Closed nikitakoschelenko closed 4 years ago
vk.updates.on(['new_message'], async (context, next) => { if (Number(context.senderId) <= 0) return; console.log(context); next(); });
pollingGroupId я указываю.
В консоли: MessageContext { id: undefined, conversationMessageId: null, peerId: undefined, peerType: 'user', senderId: undefined, senderType: 'user', createdAt: undefined, text: null, forwards: MessageForwardsCollection [], attachments: [], isOutbox: false, type: 'message', subTypes: [ 'new_message' ], state: {} }
MessageContext { id: undefined, conversationMessageId: null, peerId: undefined, peerType: 'user', senderId: undefined, senderType: 'user', createdAt: undefined, text: null, forwards: MessageForwardsCollection [], attachments: [], isOutbox: false, type: 'message', subTypes: [ 'new_message' ], state: {} }
Если не указывать pollingGroupId и изменить событие на message, то работает, но другие события Bots LongPoll не работают.
pollingGroupId
message
Решилось выбором версии vkapi 5.101 вместо 5.103.
Запуская функцией updates.start() можно не указывать id группы, т. к. он получается автоматически
updates.start()
И поставь версию обратно на 5.103
Я пытаюсь слушать события LongPoll.
vk.updates.on(['new_message'], async (context, next) => { if (Number(context.senderId) <= 0) return; console.log(context); next(); });
pollingGroupId я указываю.
В консоли:
MessageContext { id: undefined, conversationMessageId: null, peerId: undefined, peerType: 'user', senderId: undefined, senderType: 'user', createdAt: undefined, text: null, forwards: MessageForwardsCollection [], attachments: [], isOutbox: false, type: 'message', subTypes: [ 'new_message' ], state: {} }
Если не указывать
pollingGroupId
и изменить событие наmessage
, то работает, но другие события Bots LongPoll не работают.Версия последняя у vk-io, node, npm.