Commit 697a69d56dd215887486a20f5754a65d8ed2c56b
1 parent
a64644d00a
Exists in
master
subscribe on connect
Showing 1 changed file with 18 additions and 1 deletions Side-by-side Diff
index.js
... | ... | @@ -47,7 +47,7 @@ function isInIgnoreList(sender) { |
47 | 47 | if (isMe(sender)) { |
48 | 48 | return true; |
49 | 49 | } |
50 | - | |
50 | + | |
51 | 51 | if (!config || !config.globals || (sender == config.globals.keepalive_id)) { |
52 | 52 | return true; |
53 | 53 | } |
... | ... | @@ -111,10 +111,27 @@ function reportToSMSIN(from, message) { |
111 | 111 | }); |
112 | 112 | } |
113 | 113 | |
114 | +function subscribeToPartners() { | |
115 | + if (!config.h2h_out.allow_response_from) { | |
116 | + return; | |
117 | + } | |
118 | + | |
119 | + let partners = config.h2h_out.allow_response_from.trim().split(/\s*,\s*/); | |
120 | + let count = partners.length; | |
121 | + for (let i=0; i<count; i++) { | |
122 | + xmpp.subscribe(partners[i]); | |
123 | + } | |
124 | +} | |
125 | + | |
114 | 126 | xmpp.on('online', function(data) { |
115 | 127 | logger.info('XMPP online', {data: data}); |
116 | 128 | logger.info('Connected with JID: ' + data.jid.user); |
117 | 129 | |
130 | + try { | |
131 | + subscribeToPartners(); | |
132 | + } | |
133 | + catch(e) {} | |
134 | + | |
118 | 135 | setTimeout(function() { |
119 | 136 | warming_up = false; |
120 | 137 | logger.info('BOT selesai warming up, pesan-pesan selanjutnya akan diproses'); |