Core: Background worker

Created on 23 Jun 2019  路  2Comments  路  Source: php-telegram-bot/core

Is the robot capable of working on the ground?
For example, send message to channel every 5 min without any /command.

Most helpful comment

Hi @IranDeveloper, excuse the late reply!

You can make a script that gets executed every 5 minutes via cron, yes.

If it's just to send a simple message, you can create a new script something like this:

#!/usr/bin/env php
<?php

use Longman\TelegramBot\Request;
use Longman\TelegramBot\Telegram;

require_once __DIR__ . '/vendor/autoload.php';

new Telegram('<your_api_key>');
Request::sendMessage([
    'chat_id' => '<your_channel_id_or_@username>',
    'text'    => 'Your message',
]);

Then execute that via cron :+1:

All 2 comments

Please help me

Hi @IranDeveloper, excuse the late reply!

You can make a script that gets executed every 5 minutes via cron, yes.

If it's just to send a simple message, you can create a new script something like this:

#!/usr/bin/env php
<?php

use Longman\TelegramBot\Request;
use Longman\TelegramBot\Telegram;

require_once __DIR__ . '/vendor/autoload.php';

new Telegram('<your_api_key>');
Request::sendMessage([
    'chat_id' => '<your_channel_id_or_@username>',
    'text'    => 'Your message',
]);

Then execute that via cron :+1:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tchibomann picture tchibomann  路  3Comments

sineverba picture sineverba  路  3Comments

nesttle picture nesttle  路  4Comments

NabiKAZ picture NabiKAZ  路  4Comments

marcolino7 picture marcolino7  路  3Comments