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:
parent
2a08ec9f86
commit
b2c7728d06
2 changed files with 4 additions and 4 deletions
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue