1
0
Fork 0
mirror of https://github.com/muerwre/vk-tg-bot.git synced 2025-04-25 06:56:40 +07:00

#4 fixed event handling

This commit is contained in:
Fedor Katurov 2021-05-06 18:04:24 +07:00
parent e2457eb8c8
commit 948f5ae67c
9 changed files with 265 additions and 11 deletions

View file

@ -60,7 +60,7 @@ export class PostNewHandler extends VkEventHandler<Fields, Values> {
return;
}
const exist = await this.getEventById(id);
const exist = await this.getEventByVkEventId(id);
if (exist) {
logger.warn(
`received duplicate entry for ${this.group.name}, ${this.type}, ${id}`
@ -212,13 +212,13 @@ export class PostNewHandler extends VkEventHandler<Fields, Values> {
return this.likes.map((like) => ({
text: withCount[like] ? `${like} ${withCount[like]}` : like,
callback_data: `/like ${this.channel} ${like}`,
callback_data: `/like ${this.channel.id} ${like}`,
}));
}
return this.likes.map((like) => ({
text: like,
callback_data: `/like ${this.channel} ${like}`,
callback_data: `/like ${this.channel.id} ${like}`,
}));
};
@ -254,11 +254,16 @@ export class PostNewHandler extends VkEventHandler<Fields, Values> {
const [, channel, emo] = ctx.match;
const event = await this.getEventByTgMessageId(id);
if (!event) {
logger.warn(`event not found for tgMessageId ${id}`);
await next();
return;
}
if (
!channel ||
!emo ||
!id ||
!event ||
channel != this.channel.id ||
!this.likes.includes(emo)
) {