PHP code example of dark-people / telegram-bot-plus-sdk
1. Go to this page and download the library: Download dark-people/telegram-bot-plus-sdk 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/ */
dark-people / telegram-bot-plus-sdk example snippets
'prompt' => [
'default' => "Masukkan nilai untuk {type} *`{text}`*:",
],
'hint' => [
'cancel' => "_Ketik `cancel` untuk membatalkan._",
],
$promptValue = [
'mother' => 'Nama ibu untuk {vname} siapa ?',
'where' => '{vname} tinggal dimana ?',
];
$promptVarible = [
'vname' => 'kamu',
];
final class StartCommand extends Command implements PlusCommandMeta
{
use HasPlusCommandMeta;
protected string $name = 'start';
public bool $autoRegister = false;
public string|array|null $forBot = null;
public ?array $groups = null;
public ?string $sharedAs = null;
public function handle(): void
{
// logic command
}
}
final class AuthMiddleware implements TelegramMiddleware, PlusMiddlewareMeta
{
use HasPlusMiddlewareMeta;
public array $events = ['message'];
public ?string $forBot = null;
public ?array $commands = null;
public function handle(TelegramContext $context): bool
{
// return false untuk menghentikan proses
return true;
}
}
use DarkPeople\TelegramBot\Support\TelegramContext;
use DarkPeople\TelegramBot\Support\UpdateMeta\TelegramUpdateMeta;
class MyCommand extends Command
{
public function __construct(
protected TelegramContext $context,
protected TelegramUpdateMeta $meta,
) {}
public function handle()
{
$action = $this->meta->action();
$roomType = $this->meta->room()->roomType;
$isAdmin = $this->meta->actor()->isAdmin();
if (! $this->meta->permissions()->can('can_send_messages')) {
// user tidak diizinkan mengirim pesan
}
}
}