2017 © Pedro Peláez
 

library telegram-bot

Telegram Bot

image

stajor/telegram-bot

Telegram Bot

  • Sunday, July 29, 2018
  • by Stajor
  • Repository
  • 1 Watchers
  • 2 Stars
  • 243 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

PHP Telgram Bot API

PHP wrapper for Telegram's Bot API., (*1)

Minimal PHP version Build Status, (*2)

Installation

Add this line to your application's composer.json:, (*3)

{
    "require": {
        "stajor/telegram-bot": "^3.0"
    }
}

and run composer update, (*4)

Or run this command in your command line:, (*5)

$ composer require stajor/telegram-bot

Telegram API support

All types and methods of the Telegram Bot API 3.6 are supported., (*6)

Configuration

First of all you need create your own bot and obtain a token, (*7)

How do I create a bot?, (*8)

Usage

You can use Telegram::Bot::Api standalone, (*9)

<?php

$api = new \Telegram\Bot\Api('BOT TOKEN');
$user = $api->getMe();

Or by using CommandsHandler to receive updates from Telegram, (*10)

Create command class, (*11)

<?php

use Telegram\Bot\Command;

class StartCommand extends Command {
    /**
     * @var string Command Name
     */
    protected $name = "start";

    /**
     * @var string Command Description
     */
    protected $description = "Start Command to get you started";

    /**
     * @inheritdoc
     */
    public function handle() {
        // This will send a message using `sendMessage`
        $this->replyWithMessage(['text' => 'Welcome to my Bot']);

        // Trigger another command dynamically from within this command
        $this->triggerCommand('help');
    }
}

In your controller add, (*12)

<?php

$handler = new CommandsHandler('BOT TOKEN');
$handler->addCommand(StartCommand::class);
$handler->handle();

Send Photo

$api = new \Telegram\Bot\Api('BOT TOKEN');
$api->sendPhoto(['chat_id' => 123,'photo' => fopen('path_to_photo', 'rb')]);

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/Stajor/telegram-bot. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct., (*13)

License

The gem is available as open source under the terms of the MIT License., (*14)

The Versions

29/07 2018

dev-master

9999999-dev

Telegram Bot

  Sources   Download

MIT

The Requires

 

The Development Requires

29/07 2018

2.0.0

2.0.0.0

Telegram Bot

  Sources   Download

MIT

The Requires

 

The Development Requires

28/06 2018

1.0.5

1.0.5.0

Telegram Bot

  Sources   Download

MIT

The Requires

 

The Development Requires

20/06 2018

1.0.4

1.0.4.0

Telegram Bot

  Sources   Download

MIT

The Requires

 

The Development Requires

20/06 2018

1.0.3

1.0.3.0

Telegram Bot

  Sources   Download

MIT

The Requires

 

The Development Requires

19/06 2018

1.0.2

1.0.2.0

Telegram Bot

  Sources   Download

MIT

The Requires

 

The Development Requires

14/06 2018

1.0.1

1.0.1.0

Telegram Bot

  Sources   Download

MIT

The Requires

 

The Development Requires

14/06 2018

1.0.0

1.0.0.0

Telegram Bot

  Sources   Download

MIT

The Requires

 

The Development Requires