PHP code example of pembuatan / bot
1. Go to this page and download the library: Download pembuatan/bot 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/ */
pembuatan / bot example snippets
Bot::setToken(BOT_TOKEN, BOT_USERNAME); //init (run(); //launch (
Bot::chat('/help', function(){
$keyboard = Bot::keyboard('
[/info] [/admin]
[/help]
');
$options = ['reply_markup' => $keyboard];
return Bot::sendMessage("List of Commands:", $options);
});
Bot::chat('/inline_keyboard', function(){
$inline_keyboard = Bot::inline_keyboard('
[Google|https://www.google.com] [Facebook|https://www.facebook.com]
[More|more_data]
');
$options = ['reply_markup' => $inline_keyboard];
return Bot::sendMessage("Options:", $options);
});
Bot::chat('/send', function($file){
if (file_exists($file)) return Bot::sendDocument($file);
return Bot::sendMessage("$file not exists");
});
$help = function(){
return Bot::sendMessage("This is <b>bold</b> and <i>italic</i> text.", ['parse_mode' => 'html']);
};
$info = function() {
Bot::sendChatAction('typing');
Bot::sendDocument('composer.json', ['caption' => 'for composer']);
};
Bot::chat_array([
'/help' => $help,
'/info' => $info,
]);
Bot::regex('/^\/start (\d+)$/', function($m){
return Bot::sendMessage($m[1]);
});
Bot::start(function(){
return Bot::sendMessage('Press button bellow:',
[
'reply_markup' => Bot::inline_keyboard('
[BUTTON|https://t.me/Testing58384bot?start=1234567890]
')
]
);
});
echo Bot::getMe();
echo Bot::setWebhook(WEBHOOK_URL);
echo Bot::getWebhookInfo();
echo Bot::deleteWebhook(true); //default is `false` for `drop_pending_updates`, see: https://core.telegram.org/bots/api#deletewebhook