Hi
i want send message to channel but timeout!
but when using api.telegram.org its work.
please help me

You can do Request::sendMessage($data) with the correct parameters in $data.
What code are you using that doesn't work?
My $data in Request::sendMessage($data) equal with https://api.telegram.org/botTOKKEN/sendMessage?chat_id=@channelUserame&text=Hi men
$data['text'] = 'Hi men';
$data['chat_id'] = '@channelUserame';
My code:
public function execute()
{
$message = $this->getMessage();
$chat_id = '@channelUserame';
$text = 'Hi men';
$data = [
'chat_id' => $chat_id,
'text' => $text,
];
return Request::sendMessage($data);
}
Is bot added to the channel as admin?
@chuv1 Yes

Change your execute() code to this, and tell us if it return anything. It should send you result of the request.
public function execute() {
$message = $this->getMessage();
$chat_id = '@channelUserame';
$text = 'Hi men';
$data = [
'chat_id' => $chat_id,
'text' => $text,
];
$sent = Request::sendMessage($data);
if($sent->isOk()){
Request::sendMessage(['chat_id'=>$message->getFrom()->getId(),'text'=>'Message sent.']);
}else{
Request::sendMessage(['chat_id'=>$message->getFrom()->getId(),'text'=>'Message not sent. Reason: '.PHP_EOL.$sent->printError()]);
}
return $sent;
}
Your code did not result and go to exception.
my error log file:
[2017-05-30 21:52:47] bot_log.ERROR: Longman\TelegramBot\Exception\TelegramException: Timed out while waiting for a request spot! in /var/www/domain.me/public_html/bot/vendor/longman/telegram-bot/src/Request.php:1061
Stack trace:
#0 /var/www/domain.me/public_html/bot/vendor/longman/telegram-bot/src/Request.php(335): Longman\TelegramBot\Request::limitTelegramRequests('sendMessage', Array)
#1 /var/www/domain.me/public_html/bot/vendor/longman/telegram-bot/src/Request.php(422): Longman\TelegramBot\Request::send('sendMessage', Array)
#2 /var/www/domain.me/public_html/bot/Commands/StartCommand.php(66): Longman\TelegramBot\Request::sendMessage(Array)
#3 /var/www/domain.me/public_html/bot/vendor/longman/telegram-bot/src/Commands/Command.php(139): Longman\TelegramBot\Commands\SystemCommands\StartCommand->execute()
#4 /var/www/domain.me/public_html/bot/vendor/longman/telegram-bot/src/Telegram.php(483): Longman\TelegramBot\Commands\Command->preExecute()
#5 /var/www/domain.me/public_html/bot/vendor/longman/telegram-bot/src/Telegram.php(452): Longman\TelegramBot\Telegram->executeCommand('start')
#6 /var/www/domain.me/public_html/bot/vendor/longman/telegram-bot/src/Telegram.php(380): Longman\TelegramBot\Telegram->processUpdate(Object(Longman\TelegramBot\Entities\Update))
#7 /var/www/domain.me/public_html/bot/hook.php(85): Longman\TelegramBot\Telegram->handle()
#8 {main} [] []
Request limiter is turned on and your PHP timezone is different from database timezone.
Please set the same timezone for both.
Make sure you set the timezone on the beggining of the hook script with date_default_timezone_set().
@jacklul I changed timezone in PHP and MySql to same timezone and add date_default_timezone_set() in head of hook.php, but i have timeout error again; but when i disable limiter its work!
Pretty sure you will have to clean the request_limiter table as it may still contain records with wrong dates and times.
I remove all tables and recreate tables, but not working again!
You will have to execute a command and compare timestamp in database for requst_limiter table, it should be current one.
If it inserts future times it will be producing this issue.
Hi
I found my problem.
in Request.php -> method limitTelegramRequests -> line 1033
in line 1068 compare $chat_id with more then zero $chat_id > 0
but channelId is String and method go to break;
thanks guys
Most helpful comment
Request limiter is turned on and your PHP timezone is different from database timezone.
Please set the same timezone for both.
Make sure you set the timezone on the beggining of the hook script with
date_default_timezone_set().