Commit bfd6b2b9856490442df8403cce2adb146c8acb5c
1 parent
3f8c030761
Exists in
master
logging when ignoring message
Showing 1 changed file with 12 additions and 2 deletions Side-by-side Diff
index.js
... | ... | @@ -68,7 +68,14 @@ function getChatId(partner) { |
68 | 68 | catch(e) { |
69 | 69 | return; |
70 | 70 | } |
71 | +} | |
72 | + | |
73 | +function hasIgnoreKeywords(message) { | |
74 | + if (message.trim().indexOf('/') == 0) { | |
75 | + return true; | |
76 | + } | |
71 | 77 | |
78 | + return false; | |
72 | 79 | } |
73 | 80 | |
74 | 81 | bot.getMe().then(function (me) { |
... | ... | @@ -88,11 +95,14 @@ bot.on('text', function (msg) { |
88 | 95 | if (now - msg.date > config.message_max_age){ |
89 | 96 | var message = "Pesan anda diabaikan, silahkan diulang beberapa saat lagi jika diperlukan: " + msg.text; |
90 | 97 | logger.info(message, {msg: msg, age: age, max_age: config.message_max_age}); |
91 | - //bot.sendMessage(msg.chat.id, message); | |
92 | - sendMessage(from, message); | |
98 | + sendMessage(from, message); | |
93 | 99 | return; |
94 | 100 | } |
95 | 101 | |
102 | + if (hasIgnoreKeywords(msg.text)) { | |
103 | + return; | |
104 | + } | |
105 | + | |
96 | 106 | var greeting_prefix = "Pesan anda telah diterima:"; |
97 | 107 | if (config.greeting_prefix) { |
98 | 108 | greeting_prefix = config.greeting_prefix; |