v3.x under wip, but can usable.
Simple, flexible, modular library based on events for Telegram Bot Api.
Litegram can be used as a regular lightweight library or as a framework with added of plugins.
- Events based (Routing);
- Cache (Redis, Memcached);
- Database (based on Laravel Database + Eloquent);
- Middlewares;
- Localization (based on Phrase);
- Sessions (based on Storage plugin);
- Storage (Flat files, Database drivers);
- Talk (Chain Conversation);
- Validation (based on Respect/Validation);
- Stemming;
- Plugins and Components;
- Supports Webhooks & Simple Long-polling (not async);
Install via Composer:
$ composer require chipslays/litegram
You can use a ready-made and configured project for a quick start.
See more information here.
1οΈβ£ Create project:
composer create-project chipslays/litegram-project SuperDuperBot
2οΈβ£ Change the parameters of the configs and finally type in Terminal:
php lite webhook:set
php lite migration:up
π Congratulation, bot project was set up.
require 'vendor/autoload.php';
$bot = bot($config)->webhook();
$bot->command('start', function () use ($bot) {
$bot->ask('What is your name?', function () use ($bot) {
$name = $bot->payload('message.text');
$bot->reply("π Nice to meet you, {$name}!");
});
});
// or
$bot->command('start', 'BotController@startConversation');
$bot->run();
Note: Method
ask
work correctly only ifstorage
driver set asfile
.
More examples you can see here
.
Documentation can be found here
.
Install Litegram Snippets extension for VS Code to increase productivity.
Released under the MIT public license. See the enclosed LICENSE
for details.