UNPKG

@kaufman-bot/currency-converter-server

Version:

Command to convert one currency to another

38 lines 1.67 kB
"use strict"; var CurrencyConverterService_1; Object.defineProperty(exports, "__esModule", { value: true }); exports.CurrencyConverterService = void 0; const tslib_1 = require("tslib"); const html_scraper_server_1 = require("@kaufman-bot/html-scraper-server"); const common_1 = require("@nestjs/common"); let CurrencyConverterService = CurrencyConverterService_1 = class CurrencyConverterService { constructor(scraperService) { this.scraperService = scraperService; this.handlerId = CurrencyConverterService_1.name; } onHelp(msg, ctx) { return tslib_1.__awaiter(this, void 0, void 0, function* () { return yield this.scraperService.onHelp(msg, ctx, CurrencyConverterService_1.name); }); } onMessage(msg, ctx) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const result = yield this.scraperService.onMessage(msg, ctx, CurrencyConverterService_1.name); if ((result === null || result === void 0 ? void 0 : result.type) === 'text' && /^[.,0-9]+$/.test(result.text.split(' ')[0])) { return { type: 'text', message: msg, text: result.text.split(' ')[0], }; } return result; }); } }; CurrencyConverterService = CurrencyConverterService_1 = tslib_1.__decorate([ (0, common_1.Injectable)(), tslib_1.__metadata("design:paramtypes", [html_scraper_server_1.ScraperService]) ], CurrencyConverterService); exports.CurrencyConverterService = CurrencyConverterService; //# sourceMappingURL=currency-converter.service.js.map