UNPKG

nestwhats

Version:

A whatsapp-web.js wrapper for NestJS to create WhatsApp bots

20 lines (19 loc) 924 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ParseArgs = exports.Args = exports.Arguments = void 0; const common_1 = require("@nestjs/common"); const context_1 = require("../../context"); const parse_args_pipe_1 = require("../pipes/parse-args.pipe"); exports.Arguments = (0, common_1.createParamDecorator)((index, context) => { var _a; const moduleContext = context_1.NestWhatsExecutionContext.create(context); const [message] = moduleContext.getContext(); const discovery = moduleContext.getDiscovery(); if (!discovery.isCommand()) return null; const args = message.body.split(/ +/g).slice(1); return index !== undefined ? ((_a = args[index]) !== null && _a !== void 0 ? _a : null) : args; }); exports.Args = exports.Arguments; const ParseArgs = (dto) => (0, exports.Args)(new parse_args_pipe_1.ParseArgsPipe(dto)); exports.ParseArgs = ParseArgs;