feat(decorators): TelegrafCommand added

This commit is contained in:
Aleksandr Bukhalo
2020-03-19 16:39:47 +03:00
parent 6fddfd26f0
commit c0ffdeff34
5 changed files with 39 additions and 0 deletions

View File

@@ -53,6 +53,11 @@ export class TelegrafExplorer implements OnModuleInit {
instance[key],
);
this.handleTelegrafHears(instance, key, telegraf, metadata);
} else if (this.metadataAccessor.isTelegrafCommand(instance[key])) {
const metadata = this.metadataAccessor.getTelegrafCommandMetadata(
instance[key],
);
this.handleTelegrafCommand(instance, key, telegraf, metadata);
}
},
);
@@ -92,4 +97,13 @@ export class TelegrafExplorer implements OnModuleInit {
) {
telegraf.hears(metadata.triggers, instance[key].bind(instance));
}
handleTelegrafCommand(
instance: object,
key: string,
telegraf: Telegraf<ContextMessageUpdate>,
metadata: any,
) {
telegraf.command(metadata.commands, instance[key].bind(instance));
}
}