Commit 5d54d2e3d78bead628ba794d8dcbe2c2f84588fd

Authored by Adhidarma Hadiwinoto
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

... ... @@ -11,6 +11,7 @@
11 11 "verbose": false,
12 12 "disable_pong": false,
13 13 "allowed_from_all": false,
  14 + "add_buddies_on_init": false,
14 15 "allowed_from_partners": [],
15 16 "send_to": []
16 17 },
... ... @@ -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;