core: /whois - Bot crash and never respond.

Required Information

  • PHP version: 7.0.13
  • PHP Telegram Bot version: 0.39.0
  • Using MySQL database: yes
  • Update Method: Webhook
  • Self-signed certificate: no
  • RAW update (if available):

Expected behaviour

Bot should reply to commands.

Actual behaviour

Bot stucks and is not responding to any messages/commands after an unknown issue. Sometimes I can solve this cleaning DB or removing/uploading again files.

Steps to reproduce

Execute /whois <string>, and randomly all commands stop working. Bot don’t reply anymore to any command after this.

Extra details

Dumps: _error.log = empty

_access.log:

{"update_id":990XXXXX, "edited_message":{"message_id":5XXX,"from":{"id":32XXXXXX"first_name":"nesttle","username":"nesttle"},"chat":{"id":32XXXXXX,"first_name":"nesttle","username":"nesttle","type":"private"},"date":148646XXX,"edit_date":1486468XXX,"text":"/whois testing","entities":[{"type":"bot_command","offset":0,"length":6}]}}
{"update_id":990XXXXX, "edited_message":{"message_id":5XXX,"from":{"id":32XXXXXX"first_name":"nesttle","username":"nesttle"},"chat":{"id":32XXXXXX,"first_name":"nesttle","username":"nesttle","type":"private"},"date":148646XXX,"edit_date":1486468XXX,"text":"/whois testing","entities":[{"type":"bot_command","offset":0,"length":6}]}}
{"update_id":990XXXXX, "edited_message":{"message_id":5XXX,"from":{"id":32XXXXXX"first_name":"nesttle","username":"nesttle"},"chat":{"id":32XXXXXX,"first_name":"nesttle","username":"nesttle","type":"private"},"date":148646XXX,"edit_date":1486468XXX,"text":"/whois testing","entities":[{"type":"bot_command","offset":0,"length":6}]}}
{"update_id":990XXXXX, "edited_message":{"message_id":5XXX,"from":{"id":32XXXXXX"first_name":"nesttle","username":"nesttle"},"chat":{"id":32XXXXXX,"first_name":"nesttle","username":"nesttle","type":"private"},"date":148646XXX,"edit_date":1486468XXX,"text":"/whois testing","entities":[{"type":"bot_command","offset":0,"length":6}]}}
{"update_id":990XXXXX, "edited_message":{"message_id":5XXX,"from":{"id":32XXXXXX"first_name":"nesttle","username":"nesttle"},"chat":{"id":32XXXXXX,"first_name":"nesttle","username":"nesttle","type":"private"},"date":148646XXX,"edit_date":1486468XXX,"text":"/whois testing","entities":[{"type":"bot_command","offset":0,"length":6}]}}

_update.log

{"update_id":990XXXXX, "edited_message":{"message_id":5XXX,"from":{"id":32XXXXXX,"first_name":"nesttle","username":"nesttle"},"chat":{"id":32XXXXXX,"first_name":"nesttle","username":"nesttle","type":"private"},"date":14864XXXXX,"edit_date":14864XXXXX,"text":"/whois testing","entities":[{"type":"bot_command","offset":0,"length":6}]}}

Command which made my bot crash:

[12:57] nesttle: /whois AB1234c
[12:57] MYBOT: Chat not found!

After that, I executed correctly 2 commands, but looks like bot stucks on command above (I can see again and again same input on dumps: _update.log and _access.log)

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 2
  • Comments: 20 (5 by maintainers)

Most upvoted comments

Ok, this seems related to an issue I had as well at some point, where updates weren’t being saved to the DB any more. After truncating it worked for me again too, so some SQL query is messing stuff up…

What if there is some kind of issue with PHP7?

Any chance you could try running the bot :

  • using PHP 5.6
  • with getUpdates() script

I remember getting 500 error in the past,

You could try using cgi to handle webhook which would redirect post data as a parameter to hook,php

#!/bin/bash

echo "Status: 200 OK\r\n"
POST_DATA=$(cat)

echo "Content-Type: application/json"
echo ""

/usr/local/bin/php hook.php $POST_DATA > /dev/null 2>&1 &

exit;

(adjust php part to the correct one)

You might have to add cgi handler to .htaccess:

<Files *.cgi>
    AddHandler cgi-script .cgi
    Options +ExecCGI
</Files>

Next, you will need to add this to the top of your webhook script:

if (defined('STDIN')) {
    unset($argv[0]);
    $POST = implode(' ', $argv);
}

And later, after initalizing the bot:

if (!empty($POST)) {
    $telegram->setCustomInput($POST);
}