feat(decorators): TelegrafHelp added

This commit is contained in:
Aleksandr Bukhalo
2020-03-19 16:44:05 +03:00
parent c0ffdeff34
commit fa3a7f5258
5 changed files with 47 additions and 17 deletions

View File

@@ -41,8 +41,6 @@ export class TelegrafExplorer implements OnModuleInit {
(key: string) => {
if (this.metadataAccessor.isTelegrafUse(instance[key])) {
this.handleTelegrafUse(instance, key, telegraf);
} else if (this.metadataAccessor.isTelegrafStart(instance[key])) {
this.handleTelegrafStart(instance, key, telegraf);
} else if (this.metadataAccessor.isTelegrafOn(instance[key])) {
const metadata = this.metadataAccessor.getTelegrafOnMetadata(
instance[key],
@@ -58,6 +56,10 @@ export class TelegrafExplorer implements OnModuleInit {
instance[key],
);
this.handleTelegrafCommand(instance, key, telegraf, metadata);
} else if (this.metadataAccessor.isTelegrafStart(instance[key])) {
this.handleTelegrafStart(instance, key, telegraf);
} else if (this.metadataAccessor.isTelegrafHelp(instance[key])) {
this.handleTelegrafHelp(instance, key, telegraf);
}
},
);
@@ -81,14 +83,6 @@ export class TelegrafExplorer implements OnModuleInit {
telegraf.on(metadata.updateTypes, instance[key].bind(instance));
}
handleTelegrafStart(
instance: object,
key: string,
telegraf: Telegraf<ContextMessageUpdate>,
) {
telegraf.start(instance[key].bind(instance));
}
handleTelegrafHears(
instance: object,
key: string,
@@ -106,4 +100,20 @@ export class TelegrafExplorer implements OnModuleInit {
) {
telegraf.command(metadata.commands, instance[key].bind(instance));
}
handleTelegrafStart(
instance: object,
key: string,
telegraf: Telegraf<ContextMessageUpdate>,
) {
telegraf.start(instance[key].bind(instance));
}
handleTelegrafHelp(
instance: object,
key: string,
telegraf: Telegraf<ContextMessageUpdate>,
) {
telegraf.help(instance[key].bind(instance));
}
}