1
0
Fork 0
mirror of https://github.com/muerwre/vk-tg-bot.git synced 2025-04-24 22:46:41 +07:00

#5 added log for post type skipper

This commit is contained in:
Fedor Katurov 2021-05-12 11:42:35 +07:00
parent 80c19127dc
commit 174dcac9e6
2 changed files with 16 additions and 4 deletions

View file

@ -1,7 +1,7 @@
import { VkEventHandler } from "./VkEventHandler";
import { WallPostContext } from "vk-io";
import { NextMiddleware } from "middleware-io";
import { UsersUserFull } from "vk-io/lib/api/schemas/objects";
import { UsersUserFull, WallPostType } from "vk-io/lib/api/schemas/objects";
import { ConfigGroup } from "../types";
import { ExtraReplyMessage } from "telegraf/typings/telegram-types";
import {
@ -56,7 +56,19 @@ export class PostNewHandler extends VkEventHandler<Fields, Values> {
const id = context?.wall?.id;
const postType = context?.wall?.postType;
if (context.isRepost || !this.isValidPostType(postType) || !id) {
if (context.isRepost || !id) {
await next();
return;
}
if (!this.isValidPostType(postType)) {
logger.info(
`skipping wall_post_new for ${
this.group.name
}#${id} since it have type '${postType}', which is not in [${this.channel.post_types.join(
","
)}]`
);
await next();
return;
}
@ -134,7 +146,7 @@ export class PostNewHandler extends VkEventHandler<Fields, Values> {
return type === "post";
}
return this.channel.post_types.includes(type);
return this.channel.post_types.includes(type as WallPostType);
}
/**

View file

@ -18,7 +18,7 @@ export interface ConfigGroup {
export interface GroupChannel {
id: string;
events: VkEvent[];
post_types: WallPostType;
post_types: WallPostType[];
}
export enum VkEvent {