Commit 5d54d2e3d78bead628ba794d8dcbe2c2f84588fd
1 parent
fac58c4980
Exists in
master
Add config.custom_ping.add_buddies_on_init
Showing 2 changed files with 24 additions and 0 deletions Side-by-side Diff
config.sample.json
lib/custom-ping.js
... | ... | @@ -112,9 +112,32 @@ const pingSender = async () => { |
112 | 112 | pingSender(); |
113 | 113 | }; |
114 | 114 | |
115 | +const addBuddiesOnInit = () => { | |
116 | + if ( | |
117 | + !config.custom_ping || !config.custom_ping.send_to | |
118 | + || !Array.isArray(config.custom_ping.send_to) | |
119 | + || !config.custom_ping.send_to.length | |
120 | + ) { | |
121 | + return; | |
122 | + } | |
123 | + | |
124 | + logger.verbose(`${MODULE_NAME} 3BBD9A02: Adding custom ping targets as buddies`, { | |
125 | + targets: config.custom_ping.send_to, | |
126 | + }); | |
127 | + | |
128 | + config.custom_ping.send_to.forEach((target) => { | |
129 | + bot.subscribe(target); | |
130 | + }); | |
131 | +}; | |
132 | + | |
115 | 133 | const setBot = (botFromCaller) => { |
116 | 134 | logger.verbose(`${MODULE_NAME} A063F39F: Bot registered for custom ping`); |
117 | 135 | bot = botFromCaller; |
136 | + | |
137 | + if (config.custom_ping && config.custom_ping.add_buddies_on_init) { | |
138 | + addBuddiesOnInit(); | |
139 | + } | |
140 | + | |
118 | 141 | pingSender(); |
119 | 142 | }; |
120 | 143 | exports.setBot = setBot; |