1. Go to this page and download the library: Download askoldex/teletant 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/ */
askoldex / teletant example snippets
use Askoldex\Teletant\Bot;
use Askoldex\Teletant\Context;
use Askoldex\Teletant\Settings;
$settings = new Settings('token');
$settings->setHookOnFirstRequest(false);
$bot = new Bot($settings);
$bot->polling();
$bot->listen();
$bot->onCommand('start', function (Context $ctx) {
$ctx->reply('Hello world');
});
$bot->onMessage('sticker', function (Context $ctx) {
$ctx->reply('Nice sticker!');
});
$bot->onUpdate('message', function (Context $ctx) {
$ctx->reply('Answer on any message (text, sticker, photo, etc.)');
});
$bot->onAction('like', function (Context $ctx) {
$ctx->reply('You pressed the button with callaback_data=like');
});
$bot->onHears('fu*k', function (Context $ctx) {
$ctx->reply('Stop! If you continue, you will be banned');
});
$bot->onHears(['di*k', 'f**k'], function (Context $ctx) {
$ctx->reply('Stop! If you continue, you will be banned');
});