Download the PHP package alish/telegram without Composer
On this page you can find all versions of the php package alish/telegram. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download alish/telegram
More information about alish/telegram
Files in alish/telegram
Informations about the package telegram
Laravel Telegram Bot
use this package for working with telegram api bot, this package develped to work well with laravel but with some minor change you can use this with raw php
INSTALLATION
Additional Setup for Laravel 5 to 5.4
you need to add service provider and facade manually to config/app.php
for laravel 5.5 and above you don't need do this
Config file
publish config file
then you see config file in config/telegram.php
config file is like below
Defaults
fill token_bot with token you get from bot father, and set webhook with your desire url (relative url)
Commands
if you want to handle commands receive from telegram api bot in specific class ypu can declare it here, first set 'active' to true, then in 'list' array list your command with related Class handlers. classes specified in this file should inheret from then put your logic in handler function Example
you have access to Message object with $this->message (See Message Class) NOTE *** if you active commands handler then you'll not get message in MessageHandler in your handlers section
Handlers
in this section we splited message type that receieve from telegram to seperate class handlers, then for handle each type you need to declare related class. class have been defined as handlers should inheret from TelegramUpdateHandler Example:
you have access to Update object with $this->update See Update Documentation
Loaders
if you want to do some actions before handle message you can define loader classes. this class receive update object recieve from telegram api class have been define as loaders should inheret from TelegramLoader Example:
this loaders don't prevent from your defioned handlers to receive update, then be careful to use these
Telegram Facade
with this facade you can do all actions defined in telegram api bot (See Available Methods)[https://core.telegram.org/bots/api#available-methods]
How to use this
you only need to use same methods in telegram api Example:
because chat_id is require for all action except 1 or 2, you can use
sending buttons
for sending buttons you need to json_encode button arrays Example
sending files
for sending files you need use getFile method from InputFile class Example:
getUser
you can get telegram user in recevied update with below command: to see which information is in user object see (User Object)[https://core.telegram.org/bots/api#user]
How this package works
all telegram object mapped to their classes, this means when an update receive from telegram api it maps to Update class, Update Class Contains:
you can't access directly to this properties because this should initiate from what receivedd from telegram api, if you want to access to each property use dynamic method with 'get' prefix for example for getting update_id use getUpdateId() method if you want manipulate received message use set method to change properties, $update->setUpdateId('whatever');
All versions of telegram with dependencies
illuminate/routing Version ~5.0
illuminate/database Version ~5.0
illuminate/support Version ~5.0
illuminate/http Version ~5.0