losthost / telle
There is no license information available for the latest version (v4.0.15a) of this package.
A simple template for extreme complex bot
v4.0.15a
2024-02-17 12:32 UTC
Requires
- php: >=8.1.1
- dragonmantank/cron-expression: v3.3.3
- losthost/db: ^3
- telegram-bot/api: 2.6.x-dev
- dev-master
- v4.0.15a
- v4.0.14a
- v4.0.13a
- v4.0.12a
- v4.0.11a
- v4.0.10a
- v4.0.9a
- v4.0.8a
- v4.0.7a
- v4.0.6a
- v4.0.5a
- v4.0.4a
- v4.0.3a
- v4.0.2a
- v4.0.1a
- v4.0.0
- v3.1.2
- v3.1.1
- v3.1.0
- v3.0.4
- v3.0.3
- v3.0.2
- v3.0.1
- v3.0.0
- v2.0.1
- v2.0.0
- v1.4.0
- v1.3.3
- v1.3.2
- v1.3.1
- v1.3.0
- v1.2.1
- v1.2.0
- v1.1.4
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.0
- dev-v4-dev
This package is auto-updated.
Last update: 2024-04-17 13:05:20 UTC
README
This is a skeleton bot which can deal in web-server and standalone (cli) modes. In cli mode it supports multiple worker-processes if it is needed for high-loaded sites. Also it has its own cron sheduler which allows to start AbstractBackgroundProcess descendants as a part of cron process or in background (recomended for time consuming tasks)
How to use
- Create etc/bot_config.php. (the path is relative to your project root):
$token = 'The_bot:token_received_from_BotFather';
$ca_cert = 'Path to cacert.pem';
$timezone = 'Default/Timezone'; // ex. Europe/Moscow
$db_host = 'your.database.host';
$db_user = 'db_username';
$db_pass = 'Db-PAssWorD';
$db_name = 'database_name';
$db_prefix = 'table_prefix_';
- Create your own handler(s)
use \losthost\telle\abst\AbstractHandlerMessage;
class HandlerDoNothing extends AbstractHandlerMessage {
public function isFinal() : bool {return false;}
protected function init() : void {}
protected function check(\TelegramBot\Api\Types\Message &$message) : bool {
if (!$message) {
return false;
}
return (bool)$message->getText();
}
protected function handle(\TelegramBot\Api\Types\Message &$message) : bool {
// Do nothing
return true;
}
}
- Create a starter file (ex. index.php) which contains:
use losthost\telle\Bot;
// Initialize bot
Bot::setup();
// Do your own initialization
// add some code here
// Add handler(s)
Bot::addHandler(HandlerDoNothing::class);
// Start processing updates
Bot::run();
(See src/samples folder for more examples. See src/abst for handler ancestors)
TODO
Now it seems nothing to do