tekook/telegramlibrary

PHP Library for the new Telegram Bot API

1.0.3 2015-06-30 17:34 UTC

This package is auto-updated.

Last update: 2024-04-28 17:02:53 UTC


README

PHP Library for the new Telegram Bot API

  • Event based programming for the new bot api
  • Closures
  • Composer Ready
  • Fully OOP
  • All Methods and Types available
  • Documented

####Usage##### Initiate the TelegramBotApi object with your token. Register the wanted hook within the event handler Use the central "pushUpdate" Method to start the Handling

####Example####

use Tekook\TelegramLibrary;

$telegram = new TelegramLibrary\TelegramBotApi("<your token>");


$eventHandler = $telegram->getEventHandler();
$eventHandler->addHook(TelegramLibrary\Events::TEXT,
        function(\Tekook\TelegramLibrary\Types\Message $message) {
    if ($message->getText() == "A") {
        $message->reply("OK", ["reply_markup" => new TelegramLibrary\Markups\ReplyKeyboardHide()]);
    } else {
        $message->reply("Hello, " . $message->getFrom()->getFirstName() . " please answer A!",
                [
            "reply_markup" => new TelegramLibrary\Markups\ReplyKeyboardMarkup([
                ["A", "B"],
                ["C", "D"],
                ["E", "F"],
                    ])
        ]);
    }
});

$telegram->pushUpdate();

##Author## Julian Tekook