PHP code example of rasa / telekit

1. Go to this page and download the library: Download rasa/telekit library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rasa / telekit example snippets


php artisan serve

php artisan

php artisan send all

php artisan send --to=CHAT_ID
php artisan send -t CHAT_ID

php artisan send --to=CHAT_ID --message="hello world"
php artisan send -t CHAT_ID -m "hello world"

php artisan make:interaction MyInteraction

php artisan make:trigger myTrigger 

php artisan make:model User 

php artisan database

php artisan database:params

php artisan database:version

php artisan database:tables

php artisan database:table chats

php artisan database:table chats --desc

php artisan database:showTable chats --columns="chat_id"
php artisan database:showTable chats --columns="chat_id" --columns="username" --columns="attempts"

php artisan migrate

php artisan migrate --fresh

php artisan responses

class Hi extends Trigger {
    public function __construct($request)
    {
        $this->reply_message('Hi');
    }
}


namespace Triggers;

class Help extends Trigger {
    public function __construct($request)
    {
        $this->sendMessage()
            ->chat_id($request['message']['chat']['id'])
            ->text('Помощь')
            ->send();
    }
}

$this->photo()
    ->protect_content(true)
    ->caption('Подпись')
    ->photo("image1.png", "кот.jpg", "image/jpg")
    ->send()

$this->document()
    ->protect_content(true)
    ->caption('Sign')
    ->photo("image1.png", "cat.jpg", "image/jpg")
    ->send()

namespace Inlines;

use Core\Responses\Interaction;

class Example extends Interaction {
    public function __construct($request)
    {
        $result = [
            [
                "type" => "article",
                "id" => "0",
                "title" => "Do",
                "description" => "something",
                "input_message_content" => [
                    "message_text" => "result: <b> OK </b>",
                    "parse_mode" => "HTML"
                ]
            ],
            [
                "type" => "article",
                "id" => "1",
                "title" => "Do 2",
                "description" => "something 2",
                "input_message_content" => [
                    "message_text" => "result: <b> OK 2 </b>",
                    "parse_mode" => "HTML"
                ]
            ]
        ];

        $this->answerInlineQuery()
            ->inline_query_id($request['inline_query']['id'])
            ->results($result)
            ->cache_time(1)
            ->is_personal(true)
            ->send(false, false);
    }
}

$this->send_invoice()
    ->title('Subscription')
    ->description("Buy subscription for an month.")
    ->payload('Subscription: month')
    ->currency('USD')
    ->prices(['label' => 'Subscription for an month', 'amount' => 100000])
    ->send();