All Projects → tg-bot-api → Bot Api Base

tg-bot-api / Bot Api Base

Licence: mit
Clear and simple Telegram bot API

Projects that are alternatives of or similar to Bot Api Base

Integram
Integrate Telegram into your workflow – Trello, Gitlab, Bitbucket and other bots
Stars: ✭ 1,365 (+1018.85%)
Mutual labels:  telegram-bot-api, telegram-bot, telegram
Vk To Telegram Bot
Bot for auto-reposting posts from VK to Telegram channel
Stars: ✭ 103 (-15.57%)
Mutual labels:  telegram-bot-api, telegram-bot, telegram
Pytelegrambotapi
Python Telegram bot api.
Stars: ✭ 4,986 (+3986.89%)
Mutual labels:  telegram-bot-api, telegram-bot, telegram
Telegram
Telegram Bot API Wrapper for Scala
Stars: ✭ 310 (+154.1%)
Mutual labels:  telegram-bot-api, telegram-bot, telegram
Zanzara
Asynchronous PHP Telegram Bot Framework built on top of ReactPHP
Stars: ✭ 107 (-12.3%)
Mutual labels:  telegram-bot-api, telegram-bot, telegram
Kotlin Telegram Bot
🤖 A wrapper for the Telegram Bot API written in Kotlin
Stars: ✭ 337 (+176.23%)
Mutual labels:  telegram-bot-api, telegram-bot, telegram
Java Telegram Bot Api
Telegram Bot API for Java
Stars: ✭ 819 (+571.31%)
Mutual labels:  telegram-bot-api, telegram-bot, telegram
webhook-aiogram-heroku
A sample telegram bot made with aiogram, that fetches updates using the web-hook connection. Can be easily deployed to Heroku.
Stars: ✭ 36 (-70.49%)
Mutual labels:  telegram, telegram-bot, telegram-bot-api
Bot Telegram
Exemplo de como criar um BOT para o melhor app de mensagens do mundo: Telegram.
Stars: ✭ 53 (-56.56%)
Mutual labels:  telegram-bot-api, telegram-bot, telegram
Spytrojan keylogger
[Solo para programadores] Troyano espía | Keylogger solo para Windows, se replica en el sistema y se inicia automaticamente al iniciar sesión. | Envío de registro mediante [Base de Datos], [Gmail] o [BotTelegram].
Stars: ✭ 32 (-73.77%)
Mutual labels:  telegram-bot-api, telegram-bot, telegram
Telebot.nim
Async client for Telegram Bot API in pure Nim [Bot API 5.1]
Stars: ✭ 93 (-23.77%)
Mutual labels:  telegram-bot-api, telegram-bot, telegram
Telebot
The easy way to write Telegram bots in Node.js
Stars: ✭ 1,096 (+798.36%)
Mutual labels:  telegram-bot-api, telegram-bot, telegram
Laravel Social Auto Posting
🌈Laravel social auto posting
Stars: ✭ 306 (+150.82%)
Mutual labels:  telegram-bot-api, telegram-bot, telegram
Libtelegram
Fast, efficient, header-only C++ Telegram bot API library using polling or FastCGI
Stars: ✭ 88 (-27.87%)
Mutual labels:  telegram-bot-api, telegram-bot, telegram
checkmk-telegram-notify
Get alerted by Check_MK via Telegram bash script
Stars: ✭ 28 (-77.05%)
Mutual labels:  telegram, telegram-bot, telegram-bot-api
Informer
A Telegram Mass Surveillance Bot in Python
Stars: ✭ 745 (+510.66%)
Mutual labels:  telegram-bot-api, telegram-bot, telegram
Python Telegram
Python client for the Telegram's tdlib
Stars: ✭ 246 (+101.64%)
Mutual labels:  telegram-bot-api, telegram-bot, telegram
Telegrammer
Telegram Bot - written with Swift 5.2 / NIO, supports Linux, macOS
Stars: ✭ 248 (+103.28%)
Mutual labels:  telegram-bot-api, telegram-bot, telegram
Mypackbot
🤖 Your own unlimited pack of Telegram-stickers
Stars: ✭ 18 (-85.25%)
Mutual labels:  telegram-bot-api, telegram-bot, telegram
University News Notifier
📚 University news notifier
Stars: ✭ 56 (-54.1%)
Mutual labels:  telegram-bot-api, telegram-bot, telegram

Telegram Bot Api Base

Telegram bot api Latest Version on Packagist Software License Coverage Status build Quality Score PHP Version >= 7.2 Symfony Recipe

Quality Gate Status Bugs Duplicated Lines (%) Security Rating

Supported Telegram Bot API 5.0 (November 4, 2020)

Installation

Via Composer

composer require tg-bot-api/bot-api-base --prefer-dist

Usage

We support all psr17 and psr18 implementations, but we will use guzzle6 for example

composer require php-http/guzzle6-adapter http-interop/http-factory-guzzle --prefer-dist
$botKey = '<bot key>';

$requestFactory = new Http\Factory\Guzzle\RequestFactory();
$streamFactory = new Http\Factory\Guzzle\StreamFactory();
$client = new Http\Adapter\Guzzle6\Client();

$apiClient = new \TgBotApi\BotApiBase\ApiClient($requestFactory, $streamFactory, $client);
$bot = new \TgBotApi\BotApiBase\BotApi($botKey, $apiClient, new \TgBotApi\BotApiBase\BotApiNormalizer());

$userId = '<user id>';

$bot->send(\TgBotApi\BotApiBase\Method\SendMessageMethod::create($userId, 'Hi'));

You can configure it to work in symfony, for example, in this way.

If you want to use your own api server - you can set url as 4th param in bot api

$bot = new \TgBotApi\BotApiBase\BotApi('<bot key>', $apiClient, new \TgBotApi\BotApiBase\BotApiNormalizer(), '<your-domain>');

Allowed methods:

Method Allowed type response
add AddStickerToSetMethod bool
answer AnswerCallbackQueryMethod, AnswerInlineQueryMethod, AnswerPreCheckoutQueryMethod, AnswerShippingQueryMethod bool
create CreateNewStickerSetMethod bool
delete DeleteChatPhotoMethod, DeleteChatStickerSetMethod, DeleteMessageMethod, DeleteStickerFromSetMethod, DeleteWebhookMethod bool
edit EditMessageCaptionMethod, EditMessageLiveLocationMethod, EditMessageMediaMethod, EditMessageReplyMarkupMethod, EditMessageTextMethod bool
forward ForwardMessageMethod MessageType
kick KickChatMemberMethod bool
leave LeaveChatMethod bool
pin PinChatMessageMethod bool
promote PromoteChatMemberMethod bool
restrict RestrictChatMemberMethod bool
send SendPhotoMethod, SendAudioMethod, SendDocumentMethod, SendVideoMethod, SendAnimationMethod, SendVoiceMethod, SendVideoNoteMethod, SendGameMethod, SendInvoiceMethod, SendLocationMethod, SendVenueMethod, SendContactMethod, SendStickerMethod, SendMessageMethod, SendPollMethod, SendDiceMethod MessageType
set SetChatDescriptionMethod, SetChatPhotoMethod, SetChatStickerSetMethod, SetChatTitleMethod, SetGameScoreMethod, SetStickerPositionInSetMethod, SetWebhookMethod, SetPassportDataErrorsMethod, SetChatPermissionsMethod, SetChatAdministratorCustomTitleMethod, SetMyCommandMethod, SetStickerSetThumbMethod bool
stop StopMessageLiveLocationMethod bool
stopPoll StopPollMethod Poll
unban UnbanChatMemberMethod bool
unpin UnpinChatMessageMethod, UnpinAllChatMessagesMethod bool
upload UploadStickerFileMethod FileType
exportChatInviteLink ExportChatInviteLinkMethod string
sendChatAction SendChatActionMethod bool
getUpdates GetUpdatesMethod UpdateType[]
getMe GetMeMethod UserType
getMyCommands GetMyCommandsMethod BotCommandType
getUserProfilePhotos GetUserProfilePhotosMethod UserProfilePhotosType
getWebhookInfo GetWebhookInfoMethod WebhookInfoType
getChatMembersCount GetChatMembersCountMethod int
getChat GetChatMethod ChatType
getChatAdministrators GetChatAdministratorsMethod ChatMemberType[]
getChatMember GetChatMemberMethod ChatMemberType
getGameHighScores GetGameHighScoresMethod GameHighScoreType[]
getStickerSet GetStickerSetMethod StickerSetType
getFile GetFileMethod FileType
sendMediaGroup SendMediaGroupMethod MessageType[]
getAbsoluteFilePath FileType string
logOut LogOutMethod bool
close CloseMethod bool
copyMessage CopyMessageMethod MessageIdType
call($method, [string $type]) any method class, [optional expected type] array or excepted type object

Implemented all methods and types referenced by official Api

You can use BotApiComplete instance as helper to call all methods from official Api like this:

$botKey = '<bot key>';

$requestFactory = new Http\Factory\Guzzle\RequestFactory()
$streamFactory = new Http\Factory\Guzzle\StreamFactory();
$client = new Http\Adapter\Guzzle6\Client();

$apiClient = new \TgBotApi\BotApiBase\ApiClient($requestFactory, $streamFactory, $client);
$bot = new \TgBotApi\BotApiBase\BotApiComplete($botKey, $apiClient, new \TgBotApi\BotApiBase\BotApi\BotApiNormalizer());

$userId = '<user id>';

$bot->sendMessage(\TgBotApi\BotApiBase\Method\SendMessageMethod::create($userId, 'Hi'));

Learn api

Fetching webhooks

Method fetch() of WebhookFetcher handling Psr\Http\Message\RequestInterface or string and always returns instance of UpdateType or throwing BadRequestException.

$fetcher = new \TgBotApi\BotApiBase\WebhookFetcher(new \TgBotApi\BotApiBase\BotApiNormalizer());
$update = $fetcher->fetch($request);

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

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].