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

Function processPublicCommand

main.js:3641–3713  ·  view source on GitHub ↗
(botId, bot, msg, command, commandArgs)

Source from the content-addressed store, hash-verified

3639}
3640
3641function processPublicCommand (botId, bot, msg, command, commandArgs) {
3642 if (msg.text) {
3643 if (command === '/start') {
3644 const welcome = () => {
3645 bot.sendMessage(msg.chat.id,
3646 'Hello! I am the official <b>Telegram X</b> bot.\n\n' +
3647 'You can send me <b>checksum</b> of an <b>APK file</b> you downloaded, and I can tell whether it corresponds to any <b>Telegram X</b> build I am aware of.\n\n' +
3648 '<b>Note</b>: you can always grab a fresh APK from @tgx_log.',
3649 {parse_mode: 'HTML'}
3650 ).catch(globalErrorHandler());
3651 };
3652 if (commandArgs === 'crash') {
3653 // Do nothing. Wait for incoming crash file.
3654 } else if (commandArgs === 'feedback') {
3655 bot.sendMessage(msg.chat.id, 'Hello! I am the official <b>Telegram X</b> bot.\n\n' +
3656 'It seems that you want to leave feedback on <b>Telegram X</b>.\n\n' +
3657 'If you want to just write a public app review, you can leave it on <a href="' + MARKET_URL + '">Google Play</a>.\n\n' +
3658 'Meanwhile you can send me <b>checksum</b> of an <b>APK file</b> you downloaded from anywhere, and I can tell whether it corresponds to any <b>Telegram X</b> build I am aware of.',
3659 {parse_mode: 'HTML'}
3660 ).catch(globalErrorHandler());
3661 } else if (matchChecksum(commandArgs)) {
3662 const checksum = matchChecksum(commandArgs);
3663 findApkByHash(checksum, (err, apk) => {
3664 if (err) {
3665 bot.sendMessage(msg.chat.id,
3666 '<code>' + checksum + '</code> seems to be a hash, but it does not correspond to any <b>Telegram X</b> build I am aware of.',
3667 {parse_mode: 'HTML'/*, reply_to_message_id: msg.message_id*/}
3668 ).catch(globalErrorHandler());
3669 } else {
3670 bot.sendMessage(msg.chat.id, getChecksumMessage(checksum, apk, true),
3671 {
3672 parse_mode: 'HTML',
3673 disable_web_page_preview: true /*, reply_to_message_id: msg.message_id*/
3674 }
3675 ).catch(globalErrorHandler());
3676 }
3677 });
3678 } else {
3679 welcome();
3680 }
3681 return true;
3682 }
3683 if (!command) {
3684 const checksum = matchChecksum(msg.text);
3685 if (checksum) {
3686 findApkByHash(checksum, (err, apk) => {
3687 if (err) {
3688 bot.sendMessage(msg.chat.id,
3689 'This hash does not correspond to any <b>Telegram X</b> I am aware of.',
3690 {parse_mode: 'HTML', reply_to_message_id: msg.message_id}
3691 ).catch(globalErrorHandler());
3692 } else {
3693 bot.sendMessage(msg.chat.id, getChecksumMessage(checksum, apk, false),
3694 {
3695 parse_mode: 'HTML',
3696 disable_web_page_preview: true,
3697 reply_to_message_id: msg.message_id
3698 }

Callers 1

messageCallbackFunction · 0.85

Calls 5

globalErrorHandlerFunction · 0.85
matchChecksumFunction · 0.85
findApkByHashFunction · 0.85
getChecksumMessageFunction · 0.85
welcomeFunction · 0.85

Tested by

no test coverage detected