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:
parent
80c19127dc
commit
174dcac9e6
2 changed files with 16 additions and 4 deletions
|
@ -1,7 +1,7 @@
|
||||||
import { VkEventHandler } from "./VkEventHandler";
|
import { VkEventHandler } from "./VkEventHandler";
|
||||||
import { WallPostContext } from "vk-io";
|
import { WallPostContext } from "vk-io";
|
||||||
import { NextMiddleware } from "middleware-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 { ConfigGroup } from "../types";
|
||||||
import { ExtraReplyMessage } from "telegraf/typings/telegram-types";
|
import { ExtraReplyMessage } from "telegraf/typings/telegram-types";
|
||||||
import {
|
import {
|
||||||
|
@ -56,7 +56,19 @@ export class PostNewHandler extends VkEventHandler<Fields, Values> {
|
||||||
const id = context?.wall?.id;
|
const id = context?.wall?.id;
|
||||||
const postType = context?.wall?.postType;
|
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();
|
await next();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -134,7 +146,7 @@ export class PostNewHandler extends VkEventHandler<Fields, Values> {
|
||||||
return type === "post";
|
return type === "post";
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.channel.post_types.includes(type);
|
return this.channel.post_types.includes(type as WallPostType);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -18,7 +18,7 @@ export interface ConfigGroup {
|
||||||
export interface GroupChannel {
|
export interface GroupChannel {
|
||||||
id: string;
|
id: string;
|
||||||
events: VkEvent[];
|
events: VkEvent[];
|
||||||
post_types: WallPostType;
|
post_types: WallPostType[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum VkEvent {
|
export enum VkEvent {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue