diff --git a/lib/command-handler/listtrx.js b/lib/command-handler/listtrx.js index 70bd069..3d546c8 100644 --- a/lib/command-handler/listtrx.js +++ b/lib/command-handler/listtrx.js @@ -1,5 +1,7 @@ const coreEndpoint = '/histories/trx'; +const config = require('komodo-sdk/config'); + const commandError = require('./error'); const coreapi = require('../coreapi'); @@ -7,8 +9,24 @@ function help(keyword, commandGroup) { return `Untuk melihat list transaksi${ commandGroup === 'listtrxall' ? ' termasuk downline': ''}, ketik perintah dengan format: ${ keyword.toUpperCase() }.<PIN> atau ${ keyword.toUpperCase() }.<TANGGAL>.<PIN>. Format tanggal YYYY-MM-DD, contoh 2018-12-31 untuk tanggal 31 Desember 2018.`; } -function execute(tokens, params, cb) { +module.exports = (tokens, params, cb) => { + if (params.commandGroup === 'listtrxall') { + const blacklisted = ((config.blacklist_help_for_origins || []).indexOf(params.origin || '') >= 0) + || ((config.blacklist_help_for_origin_transports || []).indexOf(params.origin_transport || '') >= 0); + + if (blacklisted) { + const body = `Perintah "${tokens[0]}" tdk tersedia pd jalur SMS dan sejenis.`; + const responseParams = { + body + } + + cb(null, null, responseParams); + return; + } + } + + if (!tokens || tokens.length < 2) { const responseParams = { body: `${ commandError.ERR_INVALID_FORMAT }. ${ help(tokens[0], params.commandGroup) }` @@ -33,6 +51,4 @@ function execute(tokens, params, cb) { }; coreapi(coreEndpoint, coreParams, 'GET', cb); -} - -module.exports = execute; \ No newline at end of file +};