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

added help command

This commit is contained in:
Fedor Katurov 2023-12-30 18:09:02 +07:00
parent 6d3f511807
commit 621b03fb70
12 changed files with 91 additions and 9 deletions

View file

@ -16,6 +16,8 @@ export const defaultConfig: Config = {
groups: [],
},
templates: {
help: "templates/help.md",
help_admin: "templates/help_admin.md",
message_new: "templates/message_new.md",
wall_post_new: "templates/post_new.md",
group_join: "templates/group_join.md",

View file

@ -13,12 +13,18 @@ const data = fs.readFileSync(
"utf8"
);
const userConfig = yaml.load(data) as Config;
const userConfig = yaml.load<Config>(data);
const config =
(userConfig && merge(defaultConfig, userConfig)) || defaultConfig;
export default function prepareConfig() {
validateConfig(config);
config.telegram.templates = {
help: config.templates.help,
help_admin: config.templates.help_admin,
};
return config;
}

View file

@ -4,7 +4,8 @@ import { HttpConfig } from "../api/http/types";
import { LoggerConfig } from "../service/logger/types";
import { PostgresConfig } from "../service/db/postgres/types";
export type TemplateConfig = Record<VkEvent, string>;
export type TemplateConfig = Record<VkEvent, string> &
Partial<Record<"help" | "help_admin", string>>;
export interface Config extends Record<string, any> {
http: HttpConfig;

View file

@ -11,6 +11,8 @@ export const templateConfigSchema = object().required().shape({
wall_post_new: string().required(),
group_join: string().required(),
group_leave: string().required(),
help: string().optional(),
help_admin: string().optional(),
});
export const templateOptionalSchema = object().shape({