2017 © Pedro Peláez
 

library telegrambot

Telegram Notifications Driver

image

mavinoo/telegrambot

Telegram Notifications Driver

  • Monday, August 28, 2017
  • by mavinoo
  • Repository
  • 1 Watchers
  • 1 Stars
  • 12 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 9 % Grown

The README.md

Telegram Notifications Channel Plus for Laravel 5.3 [WIP]

Latest Version on Packagist Software License 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)

composer require mavinoo/telegrambot:dev-master

You must install the service provider:, (*4)

// config/app.php
'providers' => [
    ...
    NotificationChannelsPlus\Telegrambot\TelegrambotServiceProvider::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 sendMessage

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

``` php use NotificationChannelsPlus\Telegrambot\TelegramChannel; use NotificationChannelsPlus\Telegrambot\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);

    $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;
}

}, (*10)


## Usage sendPhoto You can now use the channel in your `via()` method inside the Notification class. ``` php 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., (*11)

License

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

The Versions

28/08 2017

dev-master

9999999-dev https://github.com/mavinoo/telegrambot

Telegram Notifications Driver

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel notification telegram telegram notification telegram notifications channel plus