(botId, bot, msg)
| 3713 | } else if (msg.document) { |
| 3714 | bot.sendMessage(msg.chat.id, |
| 3715 | 'Sorry, I can currently process only <b>checksums</b>, not files themselves.', |
| 3716 | {parse_mode: 'HTML', reply_to_message_id: msg.message_id} |
| 3717 | ).catch(globalErrorHandler()); |
| 3718 | return (msg.document.file_name && msg.document.file_name.endsWith('.apk')) || |
| 3719 | (msg.document.mime_type && msg.document.mime_type === APK_MIME_TYPE); |
| 3720 | } |
| 3721 | } |
| 3722 | |
| 3723 | function messageCallback (botId, bot, msg) { |
| 3724 | if (msg.chat.type !== 'private') |
| 3725 | return; |
| 3726 | |
| 3727 | if (msg.from && msg.from.is_bot) { |
| 3728 | console.error('Received message from bot', |
| 3729 | 'from:', JSON.stringify(msg.from), |
| 3730 | 'chat:', JSON.stringify(msg.chat), |
| 3731 | 'text:', msg.text || 'null' |
| 3732 | ); |
| 3733 | return; |
| 3734 | } |
| 3735 | |
| 3736 | storeObject('user', msg.from); |
| 3737 | storeObject('user', msg.forward_from); |
| 3738 | storeObject('chat', msg.sender_chat); |
| 3739 | storeObject('chat', msg.chat); |
| 3740 | |
| 3741 | let command = null, commandArgs = ''; |
| 3742 | |
| 3743 | if (msg.text && msg.entities && msg.entities.length) { |
| 3744 | for (let i = 0; i < msg.entities.length; i++) { |
| 3745 | const entity = msg.entities[i]; |
| 3746 | if (entity.type === 'bot_command' && entity.offset === 0) { |
| 3747 | command = entity.length === msg.text.length ? msg.text : msg.text.substring(0, entity.length); |
| 3748 | commandArgs = msg.text.length > command.length + 1 ? msg.text.substring(command.length + 1) : ''; |
| 3749 | break; |
| 3750 | } |
| 3751 | } |
| 3752 | } |
| 3753 | |
| 3754 | if (botId === 'public' && (msg.chat.username == null || ![BETA_CHAT_ID, PR_CHAT_ID].includes(msg.chat.username))) { |
| 3755 | try { |
| 3756 | const success = processPublicCommand(botId, bot, msg, command, commandArgs); |
| 3757 | if (success) { |
| 3758 | return; |
| 3759 | } |
| 3760 | } catch (e) { |
| 3761 | console.log(e); |
| 3762 | return; |
| 3763 | } |
| 3764 | } |
| 3765 | if (botId === 'private' && msg.chat.id === ADMIN_USER_ID && !msg.reply_to_message) { |
| 3766 | processPrivateCommand(botId, bot, msg, command, commandArgs); |
| 3767 | return; |
| 3768 | } |
| 3769 | |
| 3770 | // Chat through forwarded messages |
| 3771 | |
| 3772 | /*if (!msg.from || msg.from.id !== ADMIN_USER_ID) { |
no test coverage detected