2017 © Pedro Peláez
 

library telegram

Telegram Notifications Driver

image

serjoga/telegram

Telegram Notifications Driver

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 29 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Telegram Notifications Channel for Laravel 5.3 [WIP]

Latest Version on Packagist Software License Build Status StyleCI SensioLabsInsight Quality Score Code Coverage Total Downloads, (*1)

This package makes it easy to send Telegram notification using Telegram Bot API with Laravel 5.3., (*2)

Contents

Installation

You can install the package via composer:, (*3)

``` bash composer require laravel-notification-channels/telegram, (*4)


You must install the service provider: ```php // config/app.php 'providers' => [ ... NotificationChannels\Telegram\TelegramServiceProvider::class, ],

Setting up your Telegram Bot

Talk to @BotFather and generate a Bot API Token., (*5)

Then, configure your Telegram Bot API Token:, (*6)

// config/services.php
...
'telegram-bot-api' => [
    'token' => env('TELEGRAM_BOT_TOKEN', 'YOUR BOT TOKEN HERE')
],
...

Usage

You can now use the channel in your via() method inside the Notification class., (*7)

``` php use NotificationChannels\Telegram\TelegramChannel; use NotificationChannels\Telegram\TelegramMessage; use Illuminate\Notifications\Notification;, (*8)

class InvoicePaid extends Notification { public function via($notifiable) { return [TelegramChannel::class]; }, (*9)

public function toTelegram($notifiable)
{
    $url = url('/invoice/' . $this->invoice->id);

    return TelegramMessage::create()
        ->to($this->user->telegram_user_id) // Optional.
        ->content("*HELLO!* \n One of your invoices has been paid!") // Markdown supported.
        ->button('View Invoice', $url); // Inline Button
}

}, (*10)


Here's a screenshot preview of the above notification on Telegram Messenger: ![Laravel Telegram Notification Example](https://cloud.githubusercontent.com/assets/1915268/17590374/2e05e872-5ff7-11e6-992f-63d5f3df2db3.png) ### Routing a message You can either send the notification by providing with the chat id of the recipient to the `to($chatId)` method like shown in the above example or add a `routeNotificationForTelegram()` method in your notifiable model: ``` php ... /** * Route notifications for the Telegram channel. * * @return int */ public function routeNotificationForTelegram() { return $this->telegram_user_id; } ...

Available Message methods

  • to($chatId): (integer) Recipient's chat id.
  • content(''): (string) Notification message, supports markdown. For more information on supported markdown styles, check out these docs.
  • button($text, $url): (string) Adds an inline "Call to Action" button. You can add as many as you want and they'll be placed 2 in a row.
  • options([]): (array) Allows you to add additional or override sendMessage payload (A Telegram Bot API method used to send message internally). For more information on supported parameters, check out these docs.

Alternatives

For advance usage, please consider using telegram-bot-sdk instead., (*11)

Changelog

Please see CHANGELOG for more information what has changed recently., (*12)

Testing

bash $ composer test, (*13)

Security

If you discover any security related issues, please email syed@lukonet.com instead of using the issue tracker., (*14)

Contributing

Please see CONTRIBUTING for details., (*15)

Credits

License

The MIT License (MIT). Please see License File for more information., (*16)

The Versions

01/10 2017

dev-master

9999999-dev https://github.com/serjoga/telegram

Telegram Notifications Driver

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel notification telegram telegram notification telegram notifications channel

24/03 2017
13/08 2016

0.0.1

0.0.1.0 https://github.com/laravel-notification-channels/telegram

Telegram Notifications Driver

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel notification telegram telegram notification telegram notifications channel