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

use command instead of hears

This commit is contained in:
Fedor Katurov 2023-12-30 17:29:28 +07:00
parent 2a08ec9f86
commit b2c7728d06
2 changed files with 4 additions and 4 deletions

View file

@ -30,7 +30,7 @@ async function main() {
await httpApi.listen();
await telegramApi.probe();
telegram.hears(/\/roll(.*)/, roll);
telegram.hears("roll", roll);
logger.info("bot successfully started");
} catch (e) {

View file

@ -162,12 +162,12 @@ export class TelegramService {
};
public hears = (
what: string | RegExp,
command: string,
callback: (
text: string
) => string | Promise<string | undefined> | undefined | void
) =>
this.bot.hears(what, async (ctx) => {
this.bot.command(command, async (ctx) => {
let text: string | void | undefined = "%% not received %%";
try {
@ -191,7 +191,7 @@ export class TelegramService {
ctx.reply(text, { parse_mode: "MarkdownV2" });
} catch (error) {
console.warn(
`error replying to ${what} (${ctx.update.message.text}) with message "${text}"`,
`error replying to ${command} (${ctx.update.message.text}) with message "${text}"`,
error
);
}