mavinoo/telegrambot
Telegram Notifications Channel Plus for Laravel 5.3 [WIP]
This package makes it easy to send Telegram notification using Telegram Bot API with Laravel 5.3.
Contents
Installation
You can install the package via composer:
composer require mavinoo/telegrambot:dev-master
You must install the service provider:
// config/app.php
'providers' => [
...
NotificationChannelsPlus\Telegrambot\TelegrambotServiceProvider::class,
],
Setting up your Telegram Bot
Talk to @BotFather and generate a Bot API Token.
Then, configure your Telegram Bot API Token:
// config/services.php
...
'telegram-bot-api' => [
'token' => env('TELEGRAM_BOT_TOKEN', 'YOUR BOT TOKEN HERE')
],
...
Usage sendMessage
You can now use the channel in your via() method inside the Notification class.
use NotificationChannelsPlus\Telegrambot\TelegramChannel;
use NotificationChannelsPlus\Telegrambot\TelegramMessage;
use Illuminate\Notifications\Notification;
class InvoicePaid extends Notification
{
public function via($notifiable)
{
return [TelegramChannel::class];
}
public function toTelegram($notifiable)
{
$url = url('/invoice/' . $this->invoice->id);
$tg = TelegramMessage::create()
->to($this->user->telegram_user_id)
->content("*HELLO!* \n One of your invoices has been paid!")
->button('View Invoice', $url)
->getResult();
return $tg;
}
}
Usage sendPhoto
You can now use the channel in your via() method inside the Notification class.
use NotificationChannelsPlus\Telegrambot\TelegramChannel;
use NotificationChannelsPlus\Telegrambot\TelegramMessage;
use Illuminate\Notifications\Notification;
class InvoicePaid extends Notification
{
public function via($notifiable)
{
return [TelegramChannel::class];
}
public function toTelegram($notifiable)
{
$url = url('/invoice/' . $this->invoice->id);
$tg = TelegramMessage::create()
->to($this->user->telegram_user_id)
->sendPhoto([
'caption' => 'Hello Mohammad',
'photo' => 'http://www.ilovegenerator.com/large/i-love-mohamed-132309992962.png',
])
->button('View Invoice', $url)
->getResult();
return $tg;
}
}
Alternatives
For advance usage, please consider using telegram-bot-sdk instead.
License
The MIT License (MIT). Please see License File for more information.
Related Packages
guanguans/laravel-exception-notify
Monitor exception and report to the notification channels(Log、Mail、AnPush、Bar...
48,882
149
anpush
bark
bot
chanify
dingtalk
discord
email
error
exception
gitter
googlechat
igot
laravel
lark
log
logger
mail
mattermost
microsoftteams
monitor
notification
notifier
notify
nowpush
ntfy
push
pushback
pushbullet
pushdeer
pushme
pushover
pushplus
qq
qq 频道机器人
rocketchat
sdk
serverchan
server酱
showdocpush
simplepush
slack
telegram
wework
wpush
xizhi
yifengchuanhua
zohocliq
zohocliqwebhook
zulip
一封传话
企业微信
企业微信群机器人
微信
息知
钉钉
钉钉群机器人
飞书
飞书群机器人
narutimateum/toastr-5.2-laravel
toastr.js for Laravel 5.2 easy notification like growl for example
37,567
13