(botId, bot, msg, command, commandArgsRaw)
| 2247 | } |
| 2248 | |
| 2249 | function processPrivateCommand (botId, bot, msg, command, commandArgsRaw) { |
| 2250 | if (msg.chat.id !== ADMIN_USER_ID) { |
| 2251 | return; |
| 2252 | } |
| 2253 | switch (command) { |
| 2254 | case '/start': { |
| 2255 | // TODO? |
| 2256 | break; |
| 2257 | } |
| 2258 | case '/value': { |
| 2259 | if (commandArgsRaw) { |
| 2260 | db.get(commandArgsRaw, {valueEncoding: 'json'}, (err, value) => { |
| 2261 | if (err) { |
| 2262 | bot.sendMessage(msg.chat.id, '*Key not found!*', {parse_mode: 'MarkdownV2'}).catch(globalErrorHandler()); |
| 2263 | } else { |
| 2264 | bot.sendMessage(msg.chat.id, '<code>' + JSON.stringify(value) + '</code>', {parse_mode: 'HTML'}).catch(globalErrorHandler()); |
| 2265 | } |
| 2266 | }); |
| 2267 | } else { |
| 2268 | bot.sendMessage(msg.chat.id, 'Key not specified.').catch(globalErrorHandler()); |
| 2269 | } |
| 2270 | break; |
| 2271 | } |
| 2272 | case '/keys': { |
| 2273 | let keys = []; |
| 2274 | db.createReadStream({values: false}) |
| 2275 | .on('data', (data) => { |
| 2276 | keys.push('<code>' + data + '</code>'); |
| 2277 | }) |
| 2278 | .on('end', () => { |
| 2279 | sendArray(bot, msg.chat.id, keys, 'HTML'); |
| 2280 | }); |
| 2281 | break; |
| 2282 | } |
| 2283 | case '/values': { |
| 2284 | let values = []; |
| 2285 | db.createReadStream() |
| 2286 | .on('data', (data) => { |
| 2287 | values.push('<code>' + data.key + '</code>:\n<pre>' + data.value + '</pre>'); |
| 2288 | }) |
| 2289 | .on('end', () => { |
| 2290 | sendArray(bot, msg.chat.id, values, 'HTML', '\n\n'); |
| 2291 | }); |
| 2292 | break; |
| 2293 | } |
| 2294 | case '/abort': { |
| 2295 | if (!cur.pending_build) { |
| 2296 | bot.sendMessage(msg.chat.id, 'No build is in progress!').catch(globalErrorHandler()); |
| 2297 | return; |
| 2298 | } |
| 2299 | cur.pending_build.abort(); |
| 2300 | break; |
| 2301 | } |
| 2302 | case '/version': { |
| 2303 | getGitData((gitData) => { |
| 2304 | getAppVersion((version) => { |
| 2305 | let text = '<b>App Version</b>: <code>' + version.name + '</code>\n'; |
| 2306 | text += '<b>Commit</b>: <a href="' + gitData.remoteUrl + '/tree/' + gitData.commit.long + '">' + gitData.commit.short + '</a>'; |
no test coverage detected