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

Function processPrivateCommand

main.js:2249–3583  ·  view source on GitHub ↗
(botId, bot, msg, command, commandArgsRaw)

Source from the content-addressed store, hash-verified

2247}
2248
2249function 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>';

Callers 1

messageCallbackFunction · 0.85

Calls 15

globalErrorHandlerFunction · 0.85
sendArrayFunction · 0.85
getGitDataFunction · 0.85
getAppVersionFunction · 0.85
getLocalChangesFunction · 0.85
escapeHtmlFunction · 0.85
gitPullFunction · 0.85
ucfirstFunction · 0.85
nextBuildIdFunction · 0.85
emptyFunction · 0.85

Tested by

no test coverage detected