icekristal / laravel-telegram
Laravel Telegram Handle
v5.2.2
2024-10-12 09:40 UTC
Requires
- php: ^8.2
- laravel/framework: ^9|^10|^11
- dev-master
- v5.2.2
- v5.2.1
- v5.2.0
- v5.1.3
- v5.1.2
- v5.1.1
- v5.1.0
- v5.0.6
- v5.0.5
- v5.0.4
- v5.0.3
- v5.0.2
- v5.0.1
- v5.0.0
- v4.0.12
- v4.0.11
- v4.0.10
- v4.0.9
- v4.0.8
- v4.0.7
- v4.0.6
- v4.0.5
- v4.0.4
- v4.0.3
- v4.0.2
- v4.0.1
- v4.0.0
- v3.2.4
- v3.2.3
- v3.2.2
- v3.2.1
- v3.2.0
- v3.1.1
- v3.1.0
- v3.0.8
- v3.0.7
- v3.0.6
- v3.0.5
- v3.0.4
- v3.0.3
- v3.0.2
- v3.0.1
- v3.0.0
- v2.0.2
- v2.0.1
- v2.0
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
This package is auto-updated.
Last update: 2024-11-12 09:53:57 UTC
README
install:
composer require icekristal/laravel-telegram
migration:
php artisan vendor:publish --provider="Icekristal\LaravelTelegram\TelegramServiceProvider" --tag="migrations"
config:
php artisan vendor:publish --provider="Icekristal\LaravelTelegram\TelegramServiceProvider" --tag="config"
default handle:
php artisan vendor:publish --provider="Icekristal\LaravelTelegram\TelegramServiceProvider" --tag="translations"
lang:
php artisan vendor:publish --provider="Icekristal\LaravelTelegram\TelegramServiceProvider" --tag="ice_telegram_default_handlers"
use:
use Icekristal\LaravelTelegram\InteractsTelegramService; class User extends Model { use InteractsTelegramService; } $modelUser->telegram->chat_id;
send message, if chat telegram have owner
$modelUser->sendTelegramMessage('text message');
in config:
'method_messages' => [ 'text' => App\Services\DefaultBotTelegramHandle\TextTelegramHandle::class, ],
example handle text:
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, ]; } }
v3 >
Notification
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"); }
Facade Telegram:
IceTelegram::setInfoBot(array $infoBot); IceTelegram::setChatId(mixed $chatId); IceTelegram::setParams(array $params); IceTelegram::setOwner(array $owner); IceTelegram::sendMessage(); IceTelegram::deleteMessage(); IceTelegram::sendCallback(); IceTelegram::sendPhoto(); IceTelegram::sendDocument(); IceTelegram::sendLocation(); IceTelegram::sendQR();
v5.1 >
set config param: 'main_telegram_server_url' => env('TELEGRAM_SERVER_URL', 'https://api.telegram.org'),