1. Go to this page and download the library: Download rubot/rubing 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/ */
rubot / rubing example snippets
composer
bing\BotClient;
use Rubing\Filters;
use Rubing\Message;
$token = "token_bot";
$bot = new BotClient($token);
// $bot->setWebhook('https://yourdomain.com/botfile.php');
$bot->onMessage(Filters::text("hello"), function(BotClient $bot, Message $message) {
$message->replyMessage("hello from Rubing!");
}
);
$bot->run();
bing\BotClient;
use Rubing\Filters;
use Rubing\Message;
echo "start\n";
$token = "token_bot";
$bot = new BotClient(token: $token);
// $bot->setWebhook('https://yourdomain.com/botfile.php');
$bot->onMessage(null, function(BotClient $bot, Message $message) {
$text = <<<'EOT'
Hi ##Welcome to our amazing Rubing! 🎉
Here is a [Quote example](https://github.com/EhsanGhorbany/Rubing) that spans multiple lines,
and inside it you can see:
- __**Bold text**__
- ~~__Italic text__~~
- __--Underlined text--__
- `Mono text`
- ~~Strikethrough~~
- ||Spoiler content||
##
Outside the quote, you can also highlight:
- **Important parts**
- __Emphasized words__
- Links like [Rubing](https://github.com/EhsanGhorbany/Rubing)
You can even show `inline code` or code blocks:
bing\BotClient;
use Rubing\Filters;
use Rubing\Message;
echo "start\n";
$token = "token_bot";
$bot = new BotClient(token: $token);
// $bot->setWebhook('https://yourdomain.com/botfile.php');
$bot->onMessage(null, function(BotClient $bot, Message $message) {
$html = <<<'HTML'
<b>Hi 👋</b><br><br>
Welcome to our amazing Rubing! 🎉<br>
Here you can see all HTML formatting features:<br><br>
<b>Bold text</b><br>
<i>Italic text</i><br>
<u>Underlined text</u><br>
<s>Strikethrough text</s><br>
<code>Mono text</code><br>
<code>Inline code example</code><br>
<pre><?php
bing\BotClient;
use Rubing\Utils;
use Rubing\Message;
echo "start\n";
$token = "token_bot";
$bot = new BotClient(token: $token);
// $bot->setWebhook('https://yourdomain.com/botfile.php');
$utils = new Utils();
$bot->onMessage(null, function(BotClient $bot, Message $message) use ($utils) {
$message->replyMessage($utils->Bold("hello " . $utils->Italic("from " . $utils->Strike($utils->Hyperlink("Rubing! ", "https://github.com/EhsanGhorbany/Rubing")))) . $utils->Quote("quote " . $utils->Mono("mono")));
});
$bot->run();
use Rubing\InlineKeypad;
$keypad = new InlineKeypad();
// ردیف اول
$keypad->addRow([
InlineKeypad::buttonSimple("Rubing_1", "Rubing 1")
]);
// ردیف دوم
$keypad->addRow([
InlineKeypad::buttonSimple("Rubing_2", "Rubing 2"),
InlineKeypad::buttonSimple("Rubing_3", "Rubing 3")
]);
$inline_keypad = $keypad->build();
$message->replyMessage("send inline keypad!", inline_keypad:$inline_keypad);
use Rubing\ChatKeypad;
$chat_keypad = new ChatKeypad();
// ردیف اول
$chat_keypad->addRow([
ChatKeypad::buttonSimple("100", "Rubing 1")
]);
// ردیف دوم
$chat_keypad->addRow([
ChatKeypad::buttonSimple("101", "Rubing 2"),
ChatKeypad::buttonSimple("102", "Rubing 3")
]);
$chat_keypad->setResizeKeyboard(true);
$chat_keypad->setOnTimeKeyboard(true);
$chat_keypad = $chat_keypad->build();
$message->replyMessage("send chat keypad!", chat_keypad:$chat_keypad);
use Rubing\InlineKeypad;
$keypad = new InlineKeypad();
// ردیف اول
$keypad->addRow([
InlineKeypad::buttonSimple("Rubing_1", "Rubing 1")
]);
// ردیف دوم
$keypad->addRow([
InlineKeypad::buttonSimple("Rubing_2", "Rubing 2"),
InlineKeypad::buttonSimple("Rubing_3", "Rubing 3")
]);
$linkBtn = InlineKeypad::buttonUrlLink(id: "link",title: "ورود به سایت", url: "https://example.com");
$join_button = InlineKeypad::buttonJoinChannelData(id: "join_button", text:"کانال ما", username:"Rubing");
$button_open_chat = InlineKeypad::buttonOpenChat(id:"open_chat", text:"باز کردن چت", object_guid:"u0aaaa", object_type:"User");
// $keypad->addRow($linkBtn);
$inline_keypad = $keypad->build();
// ارسال پیام همراه با کیبورد
$message->replyMessage("Inline keypad example", inline_keypad: $inline_keypad);
use Rubing\ChatKeypad;
$keypad = new ChatKeypad();
// آیتمهای انتخاب
$items = [
ChatKeypad::selectionItem("سیب", "https://upload.wikimedia.org/wikipedia/commons/1/15/Red_Apple.jpg"),
ChatKeypad::selectionItem("موز", "https://upload.wikimedia.org/wikipedia/commons/8/8a/Banana-Single.jpg")
];
// دکمه انتخاب
$button = ChatKeypad::buttonSelection(
id: "2",
text: "انتخاب میوه",
selection_id: "fruit_select_1",
title: "انتخاب میوه",
items: $items
);
$button_simple = InlineKeypad::buttonSimple("Rubing_1", "Rubing 1");
$keypad->addRow([$button, $button_simple]);
// ساخت نهایی
$keypad = $keypad->build();
// ارسال $keypad با متد sendMessage
use Rubing\ChatKeypad;
$keypad = new ChatKeypad();
// دکمه تقویم
$btn = ChatKeypad::buttonCalendar(
id: "cal1",
title: "انتخاب تاریخ",
type: "DatePersian",
default_value: "1402/01/01",
min_year: "1390",
max_year: "1410"
);
// دکمه انتخاب عدد
$btn_num = ChatKeypad::buttonNumberPicker(
id: "num1",
title: "انتخاب عدد",
min_value: "1",
max_value: "100",
default_value: "10"
);
$keypad->addRow([$btn, $btn_num]);
// ساخت نهایی
$keypad = $keypad->build();
// chat_id شناسه چت مقصد
// question متن سوال
// options array[string] گزینه های سوال
// type ["Regular", "Quiz"] = "Regular" نوع
// allows_multiple_answers .کاربرد دارد "regular" فقط برای نوع e انتخاب چند گزینه
// is_anonymous باشد، رأیدهی ناشناس است و نام رأیدهندگان نمایش داده نمیشود true اگر
// correct_option_index "Quiz" ایندکس گزینه درست در حالت
// hint توضیح نظرسنجی
$bot->sendPoll(chat_id:$bot->chat_id, question:"سوال", options:["one", "two"], type:"Quiz", is_anonymous:false, correct_option_index:"0", hint:"توضیحات")
Enjoy exploring all the Markdown features! ✨
EOT;
$message->replyMessage(text:$text, parse_mode:"Markdown");
});
$bot->run();
use Rubing\BotClient;
use Rubing\Filters;
use Rubing\Message;
$token = "token_bot";
$bot = new BotClient($token);
$bot->onMessage(Filters::text("hello"), function(BotClient $bot, Message $message) {
$message->replyMessage("hello from Rubing!");
}
);
$bot->run();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.