Giter Club home page Giter Club logo

instant-messenger's Introduction

Instant Messenger

License Build Status

Services Supported

  • HipChat
  • Slack
  • Hall
  • Jaconda
  • Sqwiggle
  • Gitter
  • FlowDock
  • Campfire
  • Grove
  • Telegram
  • Twillo (SMS)
  • IRC

Installation

Begin by installing this package through Composer. Edit your project's composer.json file to require nathanmac/instant-messenger.

"require": {
	"nathanmac/instant-messenger": "1.*"
}

Next, update Composer from the Terminal:

composer update

Laravel Users

If you are a Laravel user, then there is a service provider that you can make use of to automatically prepare the bindings and such.

// app/config/app.php

'providers' => [
    '...',
    'Nathanmac\InstantMessenger\MessengerServiceProvider'
];

Configuration

After installing, you can publish the package configuration file into your application by running the following command:

php artisan vendor:publish nathanmac/instant-messenger

Console Command

After installing and adding the service provider to the configuration file, you now have access to the messenger:send command which allows you to send a simple notification from the command line, the following demonstrates the sending of a simple message.

$ php artisan messenger:send "This is a test message to be sent using the configured service." --from "Auto Notifier"

Example

<?php

require 'vendor/autoload.php';

use Nathanmac\InstantMessenger\Messenger;
use Nathanmac\InstantMessenger\Services\HipChatService;
use Nathanmac\InstantMessenger\Services\SlackService;
use Nathanmac\InstantMessenger\Services\HallService;
use Nathanmac\InstantMessenger\Services\JacondaService;
use Nathanmac\InstantMessenger\Services\SqwiggleService;
use Nathanmac\InstantMessenger\Services\GitterService;
use Nathanmac\InstantMessenger\Services\FlowDockService;
use Nathanmac\InstantMessenger\Services\CampFireService;
use Nathanmac\InstantMessenger\Services\GroveService;
use Nathanmac\InstantMessenger\Services\TelegramService;
use Nathanmac\InstantMessenger\Services\TwilioService;

// Twilio
$transport = new TwilioService('TWILIO ACCOUNT SID', 'TWILIO AUTH TOKEN', 'FROM PHONE', 'TO PHONE');

$messenger = new Messenger($transport);
$messenger->send(function($message) {
    $message->body('Hello this is a simple notification.');
});

// Telegram
$transport = new TelegramService('TELEGRAM TOKEN', 'CHAT ID');

$messenger = new Messenger($transport);
$messenger->send(function($message) {
    $message->body('Hello this is a simple notification.');
});

// Grove
$transport = new GroveService('GROVE CHANNEL TOKEN');

$messenger = new Messenger($transport);
$messenger->send(function($message) {
    $message->from('Bot');
    $message->body('Hello this is a simple notification.');
});

// CampFire
$transport = new CampFireService('CAMPFIRE SUBDOMAIN', 'CAMPFIRE API TOKEN', 'CAMPFIRE ROOM ID');

$messenger = new Messenger($transport);
$messenger->send(function($message) {
    $message->body('Hello this is a simple notification.');
});

// FlowDock
$transport = new FlowDockService('FLOW API TOKEN', ['any', 'tags', 'for', 'the', 'message']);

$messenger = new Messenger($transport);
$messenger->send(function($message) {
    $message->body('Hello this is a simple notification.');
    $message->from('Bot');
    $message->tags('more', 'tags', 'as', 'required');
    $message->tag('OMG');
});

// Gitter
$transport = new GitterService('GITTER API TOKEN');

$messenger = new Messenger($transport);
$messenger->send(function($message) {
    $message->body('Hello this is a simple notification.');
});

// Hipchat
$transport = new HipChatService('HIPCHAT API TOKEN', 123456);

$messenger = new Messenger($transport);
$messenger->send(function($message) {
    $message->body('Hello this is a simple notification.');
});

// Sqwiggle
$transport = new SqwiggleService('SWIGGLE_TOKEN', 12345);

$messenger = new Messenger($transport);
$messenger->send(function($message) {
    $message->body('Hello this is a simple notification.');
});

// Slack
$transport = new SlackService('WEBHOOK TOKEN', '#channel');

$messenger = new Messenger($transport);
$messenger->send(function($message) {
    $message->body('Hello this is a simple notification.');
    $message->from('John Smith', '[email protected]');
});

// Hall
$transport = new HallService('API TOKEN');

$messenger = new Messenger($transport);
$messenger->send(function($message) {
    $message->body('Hello this is a simple notification.');
    $message->from('John Smith');
});

// Jaconda
$transport = new JacondaService('account', 'ROOM TOKEN', 'room');

$messenger = new Messenger($transport);
$messenger->send(function($message) {
  $message->body('Hello this is a simple notification.');
  $message->from('John Smith');
});

instant-messenger's People

Contributors

nathanmac avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.