chipslays / litegram

πŸƒ Simple, flexible library based on events for Telegram Bot Api.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸƒ Litegram

GitHub Workflow Status GitHub

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.

⭐ Features

  • 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);

πŸ”© Installation

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.

πŸ’‘ Examples

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 if storage driver set as file.

More examples you can see here.

πŸ“– Documentation

Documentation can be found here.

Install Litegram Snippets extension for VS Code to increase productivity.

πŸ”‘ License

Released under the MIT public license. See the enclosed LICENSE for details.

About

πŸƒ Simple, flexible library based on events for Telegram Bot Api.

License:MIT License


Languages

Language:PHP 100.0%