1. Go to this page and download the library: Download icekristal/laravel-telegram 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/ */
class TextTelegramHandle extends MainTelegramHandle
{
public function __construct($data, $botInfo)
{
parent::__construct($data, $botInfo);
$text = $data['text'] ?? '';
if (Str::startsWith($text, '/start')) {
$this->returnTextStart();
} elseif (Str::startsWith($text, '/menu')) {
$this->returnMenu();
} else {
$this->parseOtherText();
}
$this->onlyMessage = "send only message";
$this->message = "send message";
$this->keyboard = [
"inline_keyboard" => [
[
["text" => __('text_line_1') . " ✌️", "callback_data" => "callback_line_1"],
],
[
["text" => __('text_line_2') . " ✌️", "callback_data" => "callback_line_2"],
]
]
];
$this->image = "URL image";
$this->file = "URL file";
}
}
class MainTelegramHandle
{
public $onlyMessage = null;
public $message = null;
public $keyboard = null;
public $image = null;
public $file = null;
public function __construct($data, $botInfo)
{
}
public function getResult(): array
{
return [
'only_message' => $this->onlyMessage,
'callback_message' => $this->messageCallback,
'message' => $this->message,
'keyboard' => $this->keyboard,
'image' => $this->image,
'file' => $this->file,
'show_alert' => $this->showAlert,
'cache_time' => $this->cacheTime,
'url' => $this->url,
];
}
}
public function via($notifiable): array
{
return [\Icekristal\LaravelTelegram\Channels\TelegramChannel::class];
}
public function toTelegram($notifiable): TelegramMessage
{
return (new \Icekristal\LaravelTelegram\Channels\Messages\TelegramMessage())->content("Text");
}