monarkhov/telebot

This package is abandoned and no longer maintained. The author suggests using the askoldex/teletant package instead.

Telebot Framework

2.0.4.2 2019-01-31 22:48 UTC

This package is auto-updated.

Last update: 2020-03-31 18:43:56 UTC


README

Examples

$settings = [
        'api_token'  => '',
        'base_url'   => 'https://api.telegram.org/',
        'username'   => '',
        'use_proxy'  => false,
        'run_type'   => 0, // 0 - Polling, 1 - Webhook
        'hook_reply' => true,
        'debug_mode' => false,
        'timing'     => false,
        'log_mode'   => false,
        'log_path'   => __DIR__ . DIRECTORY_SEPARATOR . 'tb_log',
        'proxy'      => [
            'authorization' => '',
            'server'        => '',
            'proxy_type'    => '',
        ]
];

use Telebot\Core\Bot,
    Telebot\Core\Context;
    
$bot = new Bot($settings);
$bot->cmd('start', function(Context $ctx){
    $ctx->reply('Hi! Send me a sticker');
});

$bot->onMessage('sticker', function (Context $ctx){
    $ctx->reply('Nice:)');
});

$bot->hears('bye', function (Context $ctx){
    $ctx->reply('bye bye...');
});

$bot->txt('say {text:str}', function (Context $ctx){
    $ctx->reply($ctx->params['text']);
});

$bot->run();