Commit ac020462ae9f45995e0764de81a4ddb61752ca3c
1 parent
f4e7983d3b
Exists in
master
Config to disable claim bonus/rebate
Showing 2 changed files with 12 additions and 1 deletions Inline Diff
config.sample.json
1 | { | 1 | { |
2 | "listener": { | 2 | "listener": { |
3 | "http": { | 3 | "http": { |
4 | "port": 32979 | 4 | "port": 32979 |
5 | } | 5 | } |
6 | }, | 6 | }, |
7 | "ip_whitelist": [ | 7 | "ip_whitelist": [ |
8 | "127.0.0.1", | 8 | "127.0.0.1", |
9 | "::ffff:127.0.0.1", | 9 | "::ffff:127.0.0.1", |
10 | "::1" | 10 | "::1" |
11 | ], | 11 | ], |
12 | "ascending_deposit": false, | 12 | "ascending_deposit": false, |
13 | "ascending_mutation": false, | 13 | "ascending_mutation": false, |
14 | "blacklist_help_for_origins": [], | 14 | "blacklist_help_for_origins": [], |
15 | "blacklist_help_for_origin_transports": [] | 15 | "blacklist_help_for_origin_transports": [], |
16 | "disable_claim_bonus": false | ||
16 | } | 17 | } |
lib/command-handler/claimbonus.js
1 | const coreEndpoint = '/rebate/claim-store'; | 1 | const coreEndpoint = '/rebate/claim-store'; |
2 | 2 | ||
3 | const config = require('komodo-sdk/config'); | ||
4 | |||
3 | const commandError = require('./error'); | 5 | const commandError = require('./error'); |
4 | const coreapi = require('../coreapi'); | 6 | const coreapi = require('../coreapi'); |
5 | 7 | ||
6 | function help(keyword) { | 8 | function help(keyword) { |
7 | return `Untuk menarik bonus ke saldo, ketik perintah dengan format:\n${ keyword.toUpperCase() }.<PIN>`; | 9 | return `Untuk menarik bonus ke saldo, ketik perintah dengan format:\n${ keyword.toUpperCase() }.<PIN>`; |
8 | } | 10 | } |
9 | 11 | ||
10 | function execute(tokens, params, cb) { | 12 | function execute(tokens, params, cb) { |
13 | if (config.disable_claim_bonus || config.disable_claim_rebate) { | ||
14 | const responseParams = { | ||
15 | body: 'Maaf permintaan anda tidak dapat dilakukan', | ||
16 | } | ||
17 | |||
18 | cb(null, null, responseParams); | ||
19 | return; | ||
20 | } | ||
11 | 21 | ||
12 | if (!tokens || tokens.length < 2) { | 22 | if (!tokens || tokens.length < 2) { |
13 | const responseParams = { | 23 | const responseParams = { |
14 | body: `${ commandError.ERR_INVALID_FORMAT }. ${ help(tokens[0]) }` | 24 | body: `${ commandError.ERR_INVALID_FORMAT }. ${ help(tokens[0]) }` |
15 | } | 25 | } |
16 | 26 | ||
17 | cb(null, null, responseParams); | 27 | cb(null, null, responseParams); |
18 | return; | 28 | return; |
19 | } | 29 | } |
20 | 30 | ||
21 | const coreParams = { | 31 | const coreParams = { |
22 | asker_terminal_name: params.from, | 32 | asker_terminal_name: params.from, |
23 | asker_terminal_password: tokens[1], | 33 | asker_terminal_password: tokens[1], |
24 | }; | 34 | }; |
25 | 35 | ||
26 | coreapi(coreEndpoint, coreParams, 'GET', cb); | 36 | coreapi(coreEndpoint, coreParams, 'GET', cb); |
27 | } | 37 | } |
28 | 38 | ||
29 | module.exports = execute; | 39 | module.exports = execute; |