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

added per-group and per-channel templates

This commit is contained in:
Fedor Katurov 2021-05-20 17:33:42 +07:00
parent a3fcb429ce
commit 3f2e07b391
5 changed files with 28 additions and 5 deletions

View file

@ -2,7 +2,7 @@ import { ConfigGroup, GroupInstance, VkConfig, VkEvent } from "./types";
import { API, Updates, Upload } from "vk-io";
import logger from "../logger";
import { Request, Response } from "express";
import { flatten, has, keys } from "ramda";
import { flatten, has, keys, prop } from "ramda";
import { NextFunction } from "connect";
import { VkEventHandler } from "./handlers/VkEventHandler";
import { vkEventToHandler } from "./handlers";
@ -137,7 +137,11 @@ export class VkService {
return flatten(
group.channels.map((chan) =>
chan.events.reduce((acc, event) => {
const template = new Template(this.templates[event]);
const template = new Template(
prop(event, chan?.templates) ||
prop(event, group?.templates) ||
prop(event, this.templates)
);
const handler = new vkEventToHandler[event](
event,