feat(decorators): TelegrafAction added

This commit is contained in:
Aleksandr Bukhalo
2020-03-19 17:20:13 +03:00
parent 7d3e266f0f
commit 511f9ebd77
5 changed files with 41 additions and 0 deletions

View File

@@ -87,6 +87,11 @@ export class TelegrafExplorer implements OnModuleInit {
instance[key],
);
this.handleTelegrafCashtag(instance, key, telegraf, metadata);
} else if (this.metadataAccessor.isTelegrafAction(instance[key])) {
const metadata = this.metadataAccessor.getTelegrafActionMetadata(
instance[key],
);
this.handleTelegrafAction(instance, key, telegraf, metadata);
}
},
);
@@ -202,4 +207,14 @@ export class TelegrafExplorer implements OnModuleInit {
// @ts-ignore
telegraf.cashtag(metadata.cashtag, instance[key].bind(instance));
}
handleTelegrafAction(
instance: object,
key: string,
telegraf: Telegraf<ContextMessageUpdate>,
metadata: any,
) {
// @ts-ignore
telegraf.cashtag(metadata.triggers, instance[key].bind(instance));
}
}