sinyor-ehsan / botkaplus
Botkaplus Library for rubika bots
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/sinyor-ehsan/botkaplus
Requires
- php: ^7.4|^8.0
- ext-curl: *
- ext-json: *
README
Botkaplus Library for rubika bots.
Botkaplus
Botkaplus Library for rubika bots.📦 نصب و راه اندازی
پیش نیاز
· PHP 7.4 or higher /// · curl enable /// · token rubika bot
نصب
نصب کردن فایلهای کتابخانه
composer require sinyor-ehsan/botkaplus
شروع
<?php require "vendor/autoload.php"; use Botkaplus\BotClient; use Botkaplus\Filters; use Botkaplus\Message; $token = "token_bot"; $bot = new BotClient($token); $bot->onMessage(null, function(BotClient $bot, Message $message) { $message->reply_Message("hello from Botkaplus!"); $bot->stopPropagation(); } ); $bot->runPolling(); ?>
شروع با webHook
<?php require "vendor/autoload.php"; use Botkaplus\BotClient; use Botkaplus\Filters; use Botkaplus\Message; $token = "token_bot"; $inData = file_get_contents('php://input'); $Data = json_decode($inData); $bot = new BotClient($token, $Data); $bot->onMessage(Filters::text("hello"), function(BotClient $bot, Message $message) { $message->reply_Message("hello from Botkaplus!"); $bot->stopPropagation(); } ); $bot->run(); ?>
ارسال اینلاین کیبورد
use Botkaplus\KeypadInline; $keypad = new KeypadInline(); // ردیف اول $keypad->addRow([ KeypadInline::simpleButton("100", "Botkaplus 1") ]); // ردیف دوم $keypad->addRow([ KeypadInline::simpleButton("101", "Botkaplus 2"), KeypadInline::simpleButton("101", "Botkaplus 2") ]); $inline_keypad = $keypad->build(); $message->reply_Message("send inline keypad!", $inline_keypad);
ارسال اینلاین Button
use Botkaplus\KeypadChat; $chat_keypad = new KeypadChat(); // ردیف اول $chat_keypad->addRow([ KeypadChat::simpleButton("100", "Botkaplus 1") ]); // ردیف دوم $chat_keypad->addRow([ KeypadChat::simpleButton("101", "Botkaplus 2"), KeypadChat::simpleButton("101", "Botkaplus 3") ]); $chat_keypad->setResizeKeyboard(true); $chat_keypad->setOnTimeKeyboard(true); $chat_keypad = $chat_keypad->build(); $message->reply_Message("send chat keypad!", chat_keypad:$chat_keypad);
ادامه ندادن به هندلرهای بعدی
$bot->stopPropagation()
فیلتر ترکیبی and
$bot->onMessage(Filters::and(Filters::private(), Filters::command("start")), function(BotClient $bot, Message $message){ $message->reply_Message("hello from Botkaplus to pv!"); });
انواع فیلترها
Filters::text("") Filters::command("") Filters::chatId("") Filters::senderId("") Filters::buttonId("") Filters::private() Filters::group() Filters::channel() Filters::or(...) Filters::and(...) Filters::not(...)
تنظیم کامندها
$bot->set_Commands([["command" => "start", "description" => "شروع ربات"], ["command" => "help", "description" => "راهنمای ربات"]]);