MCPcopy Index your code
hub / github.com/TGX-Android/Publisher / sendArray

Function sendArray

main.js:2138–2164  ·  view source on GitHub ↗
(bot, chatId, array, parseMode, delimiter)

Source from the content-addressed store, hash-verified

2136main();
2137
2138function sendArray (bot, chatId, array, parseMode, delimiter) {
2139 if (!array || !array.length) {
2140 bot.sendMessage(chatId, '<b>Nothing found!</b>', {parse_mode: 'HTML'}).catch(globalErrorHandler());
2141 return;
2142 }
2143 if (!delimiter) {
2144 delimiter = '\n';
2145 }
2146 let remaining = array.length;
2147 let text = '';
2148 while (remaining > 0) {
2149 const item = array[array.length - remaining];
2150 if (text.length + item.length + (text.length ? delimiter.length : 0) > 4000) {
2151 bot.sendMessage(chatId, text, {parse_mode: parseMode}).catch(globalErrorHandler());
2152 text = item;
2153 } else {
2154 if (text.length) {
2155 text += delimiter;
2156 }
2157 text += item;
2158 }
2159 remaining--;
2160 if (remaining == 0) {
2161 bot.sendMessage(chatId, text, {parse_mode: parseMode}).catch(globalErrorHandler());
2162 }
2163 }
2164}
2165
2166function sleep (milliseconds) {
2167 return new Promise(resolve => setTimeout(resolve, milliseconds))

Callers 1

processPrivateCommandFunction · 0.85

Calls 1

globalErrorHandlerFunction · 0.85

Tested by

no test coverage detected