All Projects → formapro → Telegram Bot Php

formapro / Telegram Bot Php

Licence: mit
PHP Telegram Bot.

Projects that are alternatives of or similar to Telegram Bot Php

Transmission Telegram
Control your Transmission through a Telegram bot
Stars: ✭ 144 (-31.43%)
Mutual labels:  telegram-bot, telegram
Sentry Telegram
Plugin for Sentry which allows sending notification via Telegram messenger.
Stars: ✭ 168 (-20%)
Mutual labels:  telegram-bot, telegram
Hubot Telegram
Hubot adapter for Telegram
Stars: ✭ 152 (-27.62%)
Mutual labels:  telegram-bot, telegram
Telegram Rat
Windows Remote Administration Tool via Telegram. Written in Python
Stars: ✭ 201 (-4.29%)
Mutual labels:  telegram-bot, telegram
Telegram Bot Api
First Telegram Bot API node.js library
Stars: ✭ 205 (-2.38%)
Mutual labels:  telegram-bot, telegram
Teledart
A Dart library interfacing with the latest Telegram Bot API.
Stars: ✭ 142 (-32.38%)
Mutual labels:  telegram-bot, telegram
Java Telegram Bot Tutorial
Java Telegram Bot Tutorial. Feel free to submit issue if you found a mistake.
Stars: ✭ 165 (-21.43%)
Mutual labels:  telegram-bot, telegram
Efb Telegram Master
EFB Telegram Master Channel, a channel for EH Forwarder Bot.
Stars: ✭ 128 (-39.05%)
Mutual labels:  telegram-bot, telegram
Stormkitty
🔑 Open source stealer written on C#, all logs will be sent to Telegram bot.
Stars: ✭ 198 (-5.71%)
Mutual labels:  telegram-bot, telegram
Telebot
Write Telegram bots in Rust with Tokio and Futures
Stars: ✭ 179 (-14.76%)
Mutual labels:  telegram-bot, telegram
Expressbot
一个可以帮你订阅、查询快递物流、跟你闲聊Telegram机器人
Stars: ✭ 137 (-34.76%)
Mutual labels:  telegram-bot, telegram
Rastreiobot
Telegram Bot @RastreioBot
Stars: ✭ 196 (-6.67%)
Mutual labels:  telegram-bot, telegram
Telegram.bot
.NET Client for Telegram Bot API
Stars: ✭ 1,964 (+835.24%)
Mutual labels:  telegram-bot, telegram
Vk To Telegram Transfer Bot
Бот, пересылающий сообщения из чатов ВК в Telegram и обратно
Stars: ✭ 143 (-31.9%)
Mutual labels:  telegram-bot, telegram
Heroku Node Telegram Bot
Starter pack for running telegram bot on the Heroku using Node.js
Stars: ✭ 128 (-39.05%)
Mutual labels:  telegram-bot, telegram
Telegram Bot Sdk
🤖 Telegram Bot API PHP SDK. Lets you build Telegram Bots easily! Supports Laravel out of the box.
Stars: ✭ 2,212 (+953.33%)
Mutual labels:  telegram-bot, telegram
Bot Api Base
Clear and simple Telegram bot API
Stars: ✭ 122 (-41.9%)
Mutual labels:  telegram-bot, telegram
Botserver
http://telegram.org Bot API Webhooks Framework, for Rubyists
Stars: ✭ 125 (-40.48%)
Mutual labels:  telegram-bot, telegram
Micro Bot
🤖 Zero-configuration Telegram bot runner
Stars: ✭ 173 (-17.62%)
Mutual labels:  telegram-bot, telegram
Icopy
fclone telegram interface.Send commands to Telegram BOT for get a convience way to control fclone resources copy missions.
Stars: ✭ 188 (-10.48%)
Mutual labels:  telegram-bot, telegram

PHP Telegram Bot

Telegram bot as it should be.

Examples

SetWebhook

<?php
use Formapro\TelegramBot\Bot;
use Formapro\TelegramBot\SetWebhook;
use function GuzzleHttp\Psr7\str;

$bot = new Bot('telegramToken');

$setWebhook = new SetWebhook('https://your.app/telegram-updates-hook');

// uncomment if use use self-signed certificate
// $setWebhook->setCertificate(file_get_contents('/path/to/self-signed-certifcate.pem'));

$response = $bot->setWebhook($setWebhook);

echo str($response);

GetWebhookInfo

<?php
use Formapro\TelegramBot\Bot;
use function GuzzleHttp\Psr7\str;

$bot = new Bot('telegramToken');

$response = $bot->getWebhookInfo();

echo str($response);

SendMessage

<?php
use Formapro\TelegramBot\Bot;
use Formapro\TelegramBot\Update;
use Formapro\TelegramBot\SendMessage;

$requestBody = file_get_contents('php://input'); 
$data = json_decode($requestBody, true);

$update = Update::create($data);

$bot = new Bot('telegramToken');
$bot->sendMessage(new SendMessage(
    $update->getMessage()->getChat()->getId(),
    'Hi there! What can I do?'
));

SendPhoto

Note: if you want to send gif with many pictures inside - use sendDocument

<?php
use Formapro\TelegramBot\Bot;
use Formapro\TelegramBot\Update;
use Formapro\TelegramBot\SendMessage;

$requestBody = file_get_contents('php://input');
$data = json_decode($requestBody, true);

$update = Update::create($data);

// You can pass URI of image or a path to file
$picture = '/path/to/picture'; // OR https://some-server.com/some.jpg
 
$sendPhoto = new SendPhoto(
    $update->getMessage()->getChat()->getId(),
    file_get_contents($picture) // or just $picture if it's url
);

// also you can set `caption` to image
$sendPhoto->setCaption('Some caption under the picture');

$bot = new Bot('telegramToken');
$bot->sendPhoto($sendPhoto);

SendDocument

Note: sending by URL will currently only work for gif, pdf and zip files. (from documentation)

<?php
use Formapro\TelegramBot\Bot;
use Formapro\TelegramBot\Update;
use Formapro\TelegramBot\SendDocument;
use Formapro\TelegramBot\FileUrl;
use Formapro\TelegramBot\FileId;
use Formapro\TelegramBot\InputFile;

$requestBody = file_get_contents('php://input');
$data = json_decode($requestBody, true);

$update = Update::create($data);

// You can pass URI of image or a path to file
//$document = new FileUrl('https://some-server.com/some.pdf');

// You can pass an ID of already stored file on Telegram side.
//$document = new FileId('123');

// You can pass local file.
$document = new InputFile('test.txt', 'Hi there!');

$sendDocument = SendDocument::withInputFile(
    $update->getMessage()->getChat()->getId(),
    $document
);

// also you can set `caption` to image
$sendDocument->setCaption('Some caption under the document');

$bot = new Bot('telegramToken');
$bot->sendDocument($sendDocument);

SendInvoice

<?php
use Formapro\TelegramBot\Bot;
use Formapro\TelegramBot\Update;
use Formapro\TelegramBot\SendInvoice;

$requestBody = file_get_contents('php://input');
$data = json_decode($requestBody, true);

$update = Update::create($data);
$payload = []; // any params which you need to proccess in the transaction
$providerToken = 'something:like:this'; // Token have to be taken from botFather

$sendInvoice = new SendInvoice(
    $update->getMessage()->getChat()->getId(),
    'Your title',
    'Your description of invoice',
    json_encode($payload), 
    $providerToken,
    '12314czasdq', // unique id
    'UAH',
    [new LabeledPrice('PriceLabel_1', 3001)] // amount; here 30.01 UAH
);

$bot = new Bot('telegramToken');
$bot->sendInvoice($sendInvoice);

ReplyKeyboardMarkup

<?php
use Formapro\TelegramBot\Bot;
use Formapro\TelegramBot\Update;
use Formapro\TelegramBot\SendMessage;
use Formapro\TelegramBot\KeyboardButton;
use Formapro\TelegramBot\ReplyKeyboardMarkup;

$requestBody = file_get_contents('php://input'); 
$data = json_decode($requestBody, true);

$update = Update::create($data);

$fooButton = new KeyboardButton('foo');
$barButton = new KeyboardButton('bar');
$bazButton = new KeyboardButton('bar');
$keyboard = new ReplyKeyboardMarkup([[$fooButton], [$barButton, $bazButton]]);

$sendMessage = new SendMessage($update->getMessage()->getChat()->getId(), 'Choose an option.');
$sendMessage->setReplyMarkup($keyboard);

$bot = new Bot('telegramToken');
$bot->sendMessage($sendMessage);

Request Contacts:

<?php
use Formapro\TelegramBot\Bot;
use Formapro\TelegramBot\Update;
use Formapro\TelegramBot\SendMessage;
use Formapro\TelegramBot\KeyboardButton;
use Formapro\TelegramBot\ReplyKeyboardMarkup;

$requestBody = file_get_contents('php://input'); 
$data = json_decode($requestBody, true);

$update = Update::create($data);

$button = new KeyboardButton('Share my contacts');
$button->setRequestContact(true);
$keyboard = new ReplyKeyboardMarkup([[$button]]);
$keyboard->setOneTimeKeyboard(true);

$sendMessage = new SendMessage($update->getMessage()->getChat()->getId(), 'Please, share your contact info with us.');
$sendMessage->setReplyMarkup($keyboard);

$bot = new Bot('telegramToken');
$bot->sendMessage($sendMessage);

InlineKeyboardButton

Url:

<?php
use Formapro\TelegramBot\InlineKeyboardButton;
use Formapro\TelegramBot\InlineKeyboardMarkup;
use Formapro\TelegramBot\SendMessage;
use Formapro\TelegramBot\Bot;
use Formapro\TelegramBot\Update;

$requestBody = file_get_contents('php://input'); 
$data = json_decode($requestBody, true);

$update = Update::create($data);

$button = InlineKeyboardButton::withUrl('inline button', 'https://your.app/link');
$keyboard = new InlineKeyboardMarkup([[$button]]);
        
$sendMessage = new SendMessage($update->getMessage()->getChat()->getId(), 'Click on inline button.');
$sendMessage->setReplyMarkup($keyboard);
                
$bot = new Bot('telegramToken');
$bot->sendMessage($sendMessage);

CallbackQuery:

<?php
use Formapro\TelegramBot\InlineKeyboardButton;
use Formapro\TelegramBot\InlineKeyboardMarkup;
use Formapro\TelegramBot\SendMessage;
use Formapro\TelegramBot\Bot;
use Formapro\TelegramBot\Update;

$requestBody = file_get_contents('php://input'); 
$data = json_decode($requestBody, true);

$update = Update::create($data);

$button = InlineKeyboardButton::withCallbackData('inline button', 'some_data');
$keyboard = new InlineKeyboardMarkup([[$button]]);
        
$sendMessage = new SendMessage($update->getMessage()->getChat()->getId(), 'Click on inline button.');
$sendMessage->setReplyMarkup($keyboard);
                
$bot = new Bot('telegramToken');
$bot->sendMessage($sendMessage);

AnswerCallbackQuery

<?php
use Formapro\TelegramBot\AnswerCallbackQuery;
use Formapro\TelegramBot\Bot;
use Formapro\TelegramBot\Update;

$requestBody = file_get_contents('php://input'); 
$data = json_decode($requestBody, true);

$update = Update::create($data);

if ($callbackQuery = $update->getCallbackQuery()) {
    $bot = new Bot('telegramToken');
    $bot->answerCallbackQuery(new AnswerCallbackQuery($callbackQuery->getId()));
}

Developed by Forma-Pro

Forma-Pro is a full stack development company which interests also spread to open source development. Being a team of strong professionals we have an aim an ability to help community by developing cutting edge solutions in the areas of e-commerce, docker & microservice oriented architecture where we have accumulated a huge many-years experience. Our main specialization is Symfony framework based solution, but we are always looking to the technologies that allow us to do our job the best way. We are committed to creating solutions that revolutionize the way how things are developed in aspects of architecture & scalability.

If you have any questions and inquires about our open source development, this product particularly or any other matter feel free to contact at [email protected]

License

It is released under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].