blue_skies / telegram-bot-helper
Telegram bot integration with laravel
Requires
- php: >=8.1
Requires (Dev)
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.0
README
package blue skies telegram-bot-helper
Installation
You can install the package via composer:
composer require blue_skies/telegram-bot-helper
Quick start
open the .env
file and add the Telegram bot token to it
TELEGRAM_BOT_TOKEN = telegram bot token
php artisan make:controller TestController
use BlueSkies\TelegramBotHelper\Traits\TelegramBotHelper; class TestController extends Controller { use TelegramBotHelper; public function index() { return self::SendTelegramMessage('chat_id','Test'); } }
Route::post('/telegram/message',[\App\Http\Controllers\TestController::class,'index']);
#sendMessag
#forwardMessag
#forwardMessage
#copyMessag
#copyMessage
#sendPhot
#sendAudi
#sendDocumen
#sendVide
#sendAnimatio
#sendVoic
#sendVideoNot
#sendMediaGrou
#sendLocatio
#sendVenu
#sendContac
#sendPol
#sendDic
#sendChatActio
#setMessageReactio
#getUserProfilePhoto
#getFil
#banChatMembe
#unbanChatMembe
#restrictChatMembe
#promoteChatMembe
#setChatAdministratorCustomTitl
#banChatSenderCha
#unbanChatSenderCha
#setChatPermission
#exportChatInviteLin
#createChatInviteLin
#editChatInviteLin
#revokeChatInviteLin
#approveChatJoinReques
#declineChatJoinReques
#setChatPhot
#deleteChatPhot
#setChatTitl
#setChatDescriptio
#pinChatMessag
#unpinChatMessag
#unpinAllChatMessage
#leaveCha
#getCha
#getChatAdministrator
#getChatMemberCoun
#getChatMembe
#setChatStickerSe
#deleteChatStickerSe
#getForumTopicIconSticker
#createForumTopi
#editForumTopi
#closeForumTopi
#reopenForumTopi
#deleteForumTopi
#unpinAllForumTopicMessage
#editGeneralForumTopi
#closeGeneralForumTopi
#reopenGeneralForumTopi
#hideGeneralForumTopi
#unhideGeneralForumTopi
#unpinAllGeneralForumTopicMessage
#answerCallbackQuer
#getUserChatBoost
#setMyCommand
#deleteMyCommand
#getMyCommand
#setMyNam
#getMyNam
#setMyDescriptio
#getMyDescriptio
#setMyShortDescriptio
#getMyShortDescriptio
#setChatMenuButto
#getChatMenuButto
#setMyDefaultAdministratorRight
#getMyDefaultAdministratorRight
#editMessageText
#editMessageCaption
#editMessageMedia
#editMessageLiveLocation
#stopMessageLiveLocation
#editMessageReplyMarkup
#stopPoll
#deleteMessage
#deleteMessages
#Webhooks
https://core.telegram.org/bots/api#sendmessage sendMessage
SendTelegramMessage Parameters:
public static function SendTelegramMessage( int|string $chatId, string $text, ?string $messageThreadId = null, string $parseMode = 'HTML', ?array $entities = null, ?bool $disableNotification = null, ?bool $protectContent = null, $linkPreviewOptions = null, $replyParameters = null, $replyMarkup = null ): JsonResponse
https://core.telegram.org/bots/api#forwardmessage forwardMessage
SendTelegramMessage SendTelegramForwardMessage:
public static function SendTelegramForwardMessage( int|string $chatId, int $messageThreadId = null, int|string $fromChatId = null, ?bool $disableNotification = null, ?bool $protectContent = null, int $messageId ): JsonResponse
https://core.telegram.org/bots/api#forwardmessages forwardMessages
SendTelegramMessage SendTelegramForwardMessages:
public static function SendTelegramForwardMessages( int|string $chatId, int $messageThreadId, int|string $fromChatId, array|int $messageIds, bool $disable_notification = false, bool $protectContent = false ): JsonResponse
https://core.telegram.org/bots/api#copymessage copyMessage
SendTelegramMessage SendTelegramCopyMessage:
public static function SendTelegramCopyMessage( int|string $chatId, int $messageThreadId, int|string $fromChatId, array|int $messageIds, ?bool $disable_notification = null, ?bool $protectContent = null, ?bool $removeCaption = null ): JsonResponse
https://core.telegram.org/bots/api#copymessages copyMessages
SendTelegramMessage SendTelegramCopyMessages:
public static function SendTelegramCopyMessages( int|string $chatId, int $messageThreadId, int|string $fromChatId, array|int $messageIds, ?bool $disable_notification = null, ?bool $protectContent = null, ?bool $removeCaption = null ): JsonResponse
https://core.telegram.org/bots/api#sendphoto sendPhoto
SendTelegramMessage SendTelegramPhoto:
public function SendTelegramPhoto( int|string $chatId, ?int $messageThreadId = null, string $photo, ?string $caption = null, ?string $parseMode = 'HTML', ?array $captionEntities = null, bool $hasSpoiler = null, bool $disableNotification = null, ?bool $protectContent = null, $replyParameters = null, $replyMarkup = null ): JsonResponse
https://core.telegram.org/bots/api#sendaudio sendAudio
SendTelegramMessage SendTelegramAudio:
public static function SendTelegramAudio( int|string $chatId, ?int $messageThreadId = null, string $audio, ?string $caption = null, ?string $parseMode = 'HTML', ?array $captionEntities = null, ?int $duration = null, ?string $performer = null, ?string $title = null, ?string $thumbnail = null, ?bool $disableNotification = null, ?bool $protectContent = null, $replyParameters = null, $replyMarkup = null ): JsonResponse
https://core.telegram.org/bots/api#senddocument sendDocument
SendTelegramDocument Parameters:
public static function SendTelegramDocument( int|string $chatId, ?int $messageThreadId = null, string $document, ?string $thumbnail = null, ?string $caption = null, ?string $parseMode = 'HTML', ?array $captionEntities = null, ?bool $disableContentTypeDetection = null, ?bool $disableNotification = null, ?bool $protectContent = null, ?string $title = null, $replyParameters = null, $replyMarkup = null ): JsonResponse
https://core.telegram.org/bots/api#sendvideo sendVideo
SendTelegramVideo Parameters:
public static function SendTelegramVideo( int|string $chatId, ?int $messageThreadId = null, string $video, ?int $duration = null, ?int $width = null, ?int $height = null, ?string $thumbnail = null, ?string $caption = null, ?string $parseMode = 'HTML', ?array $captionEntities = null, ?bool $hasSpoiler = null, ?bool $supportsStreaming = null, ?bool $disableNotification = null, ?bool $protectContent = null, $replyParameters = null, $replyMarkup = null, ): JsonResponse
https://core.telegram.org/bots/api#sendanimation sendAnimation
SendTelegramAnimation Parameters:
public static function SendTelegramAnimation( int|string $chatId, ?int $messageThreadId = null, string $animation, ?int $duration = null, ?int $width = null, ?int $height = null, ?string $thumbnail = null, ?string $caption = null, ?string $parseMode = 'HTML', ?array $captionEntities = null, ?bool $hasSpoiler = null, ?bool $disableNotification = null, ?bool $protectContent = null, $replyParameters = null, $replyMarkup = null ): JsonResponse
https://core.telegram.org/bots/api#sendvoice sendVoice
SendTelegramVoice Parameters:
public static function SendTelegramVoice( int|string $chatId, ?int $messageThreadId = null, string $voice, ?string $caption = null, ?string $parseMode = 'HTML', ?array $captionEntities = null, ?int $duration = null, ?bool $disableNotification = null, ?bool $protectContent = null, $replyParameters = null, $replyMarkup = null ): JsonResponse
https://core.telegram.org/bots/api#sendvideoNote sendVideoNote
SendTelegramVideoNote Parameters:
public static function SendTelegramVideoNote( int|string $chatId, ?int $messageThreadId = null, string $videoNote, ?int $duration = null, ?int $length = null, ?int $thumbnail = null, ?bool $disableNotification = null, ?bool $protectContent = null, $replyParameters = null, $replyMarkup = null ): JsonResponse
https://core.telegram.org/bots/api#sendmediagroup sendMediaGroup
SendTelegramMediaGroup Parameters:
public static function SendTelegramMediaGroup( int|string $chatId, ?int $messageThreadId = null, array $media, ?bool $disableNotification = null, ?bool $protectContent = null, ?array $captionEntities = null, ?bool $supportsStreaming = null, $replyParameters = null, $replyMarkup = null, ): JsonResponse
https://core.telegram.org/bots/api#sendlocation sendLocation
SendTelegramLocation Parameters:
public static function SendTelegramLocation( int|string $chatId, ?int $messageThreadId = null, float $latitude, float $longitude, float $horizontalAccuracy = null, float $livePeriod = null, float $heading = null, float $proximityAlertRadius = null, ?bool $disableNotification = null, ?bool $protectContent = null, $replyParameters = null, $replyMarkup = null, ): JsonResponse
https://core.telegram.org/bots/api#sendvenue sendVenue
SendTelegramVenue Parameters:
public static function SendTelegramVenue( int|string $chatId, ?int $messageThreadId = null, float $latitude, float $longitude, string $title, string $address, ?string $foursquareId = null, ?string $foursquareType = null, ?string $googlePlaceId = null, ?string $googlePlaceType = null, ?bool $disableNotification = null, ?bool $protectContent = null, $replyParameters = null, $replyMarkup = null ): JsonResponse
https://core.telegram.org/bots/api#sendcontact sendContact
SendTelegramContact Parameters:
public static function SendTelegramContact( int|string $chatId, ?int $messageThreadId = null, string $phoneNumber, string $firstName, ?string $lastName = null, ?string $vcard = null, ?bool $disableNotification = null, ?bool $protectContent = null, $replyParameters = null, $replyMarkup = null ): JsonResponse
https://core.telegram.org/bots/api#sendpoll sendPoll
SendTelegramPoll Parameters:
public static function SendTelegramPoll( int|string $chatId, ?int $messageThreadId = null, string $question, array $options, ?bool $isAnonymous = null, ?string $type = null, ?bool $allowsMultipleAnswers = null, ?int $correctOptionId = null, ?string $explanation = null, ?string $explanationParseMode = null, ?array $explanationEntities = null, ?int $openPeriod = null, ?int $closeDate = null, ?bool $isClosed = null, ?bool $disableNotification = null, ?bool $protectContent = null, $replyParameters = null, $replyMarkup = null ): JsonResponse
https://core.telegram.org/bots/api#senddice sendDice
SendTelegramDice Parameters:
public static function SendTelegramDice( int|string $chatId, ?int $messageThreadId = null, string $emoji, ?bool $disableNotification = null, ?bool $protectContent = null, $replyParameters = null, $replyMarkup = null ): JsonResponse
https://core.telegram.org/bots/api#sendchataction sendChatAction
SendTelegramChatAction Parameters:
public static function SendTelegramChatAction( int|string $chatId, ?int $messageThreadId = null, string $action ): JsonResponse
https://core.telegram.org/bots/api#setmessagereaction setMessageReaction
SendTelegramMessageReaction Parameters:
public static function SendTelegramMessageReaction( int|string $chatId, int $messageId, ?array $reaction = null, ?bool $isBig = null, ): JsonResponse
https://core.telegram.org/bots/api#getuserprofilephotos getUserProfilePhotos
getTelegramUserProfilePhotos Parameters:
public static function getTelegramUserProfilePhotos( int $userId, ?int $offset = null, ?int $limit = null ): JsonResponse
https://core.telegram.org/bots/api#getfile getFile
getTelegramFile Parameters:
public static function getTelegramFile( string $fileId, ): JsonResponse
https://core.telegram.org/bots/api#banchatmember banChatMember
banTelegramChatMember Parameters:
public static function banTelegramChatMember( int|string $chatId, int $userId, ?int $untilDate = null, ?bool $revokeMessages = null ): JsonResponse
https://core.telegram.org/bots/api#unbanchatmember unbanChatMember
unbanTelegramChatMember Parameters:
public static function unbanTelegramChatMember( int|string $chatId, int $userId, ?bool $onlyIfBanned = null ): JsonResponse
https://core.telegram.org/bots/api#restrictchatmember restrictChatMember
restrictTelegramChatMember Parameters:
public static function restrictTelegramChatMember( int|string $chatId, int $userId, array $permissions, ?bool $useIndependentChatPermissions = null, ?int $untilDate = null ): JsonResponse
https://core.telegram.org/bots/api#promotechatmember promoteChatMember
promoteTelegramChatMember Parameters:
public static function promoteTelegramChatMember( int|string $chatId, int $userId, ?bool $isAnonymous = null, ?bool $canManageChat = null, ?bool $canPostMessages = null, ?bool $canEditMessages = null, ?bool $canDeleteMessages = null, ?bool $canManageVoiceChats = null, ?bool $canRestrictMembers = null, ?bool $canPromoteMembers = null, ?bool $canChangeInfo = null, ?bool $canInviteUsers = null, ?bool $canPinMessages = null, ?bool $canPostStories = null, ?bool $canEditStories = null, ?bool $canDeleteStories = null, ?bool $canManageTopics = null, ): JsonResponse
https://core.telegram.org/bots/api#setchatadministratorcustomtitle setChatAdministratorCustomTitle
setTelegramChatAdministratorCustomTitle Parameters:
public static function setTelegramChatAdministratorCustomTitle( int|string $chatId, int $userId, string $customTitle, ): JsonResponse
https://core.telegram.org/bots/api#banchatsenderchat banChatSenderChat
banTelegramChatSenderChat Parameters:
public static function banTelegramChatSenderChat( int|string $chatId, int $senderChatId, ): JsonResponse
https://core.telegram.org/bots/api#unbanchatsenderchat unbanChatSenderChat
unbanTelegramChatSenderChat Parameters:
public static function unbanTelegramChatSenderChat( int|string $chatId, int $senderChatId ): JsonResponse
https://core.telegram.org/bots/api#setchatpermissions setChatPermissions
setTelegramChatPermissions Parameters:
public static function setTelegramChatPermissions( int|string $chatId, array $permissions, ?bool $useIndependentChatPermissions = null ): JsonResponse
https://core.telegram.org/bots/api#exportchatinvitelink exportChatInviteLink
exportTelegramChatInviteLink Parameters:
public static function exportTelegramChatInviteLink( int|string $chatId, ): JsonResponse
https://core.telegram.org/bots/api#createchatinvitelink createChatInviteLink
createTelegramChatInviteLink Parameters:
public static function createTelegramChatInviteLink( int|string $chatId, ?string $name = null, ?int $expireDate = null, ?int $memberLimit = null, ?bool $createsJoinRequest = null ): JsonResponse
https://core.telegram.org/bots/api#editchatinvitelink editChatInviteLink
editTelegramChatInviteLink Parameters:
public static function editTelegramChatInviteLink( int|string $chatId, string $inviteLink, ?string $name = null, ?int $expireDate = null, ?int $memberLimit = null, ?bool $createsJoinRequest = null ): JsonResponse
https://core.telegram.org/bots/api#revokechatinvitelink revokeChatInviteLink
revokeTelegramChatInviteLink Parameters:
public static function revokeTelegramChatInviteLink( int|string $chatId, string $inviteLink ): JsonResponse
https://core.telegram.org/bots/api#approvechatjoinrequest approveChatJoinRequest
approveTelegramChatJoinRequest Parameters:
public static function approveTelegramChatJoinRequest( int|string $chatId, int $userId, ): JsonResponse
https://core.telegram.org/bots/api#declinechatjoinrequest declineChatJoinRequest
declineTelegramChatJoinRequest Parameters:
public static function declineTelegramChatJoinRequest( int|string $chatId, int $userId, ): JsonResponse
https://core.telegram.org/bots/api#setchatphoto setChatPhoto
setTelegramChatPhoto Parameters:
public static function setTelegramChatPhoto( int|string $chatId, string $photo, ): JsonResponse
https://core.telegram.org/bots/api#deletechatphoto deleteChatPhoto
deleteTelegramChatPhoto Parameters:
public static function deleteTelegramChatPhoto( int|string $chatId, ): JsonResponse
https://core.telegram.org/bots/api#setchattitle setChatTitle
setTelegramChatTitle Parameters:
public static function setTelegramChatTitle( int|string $chatId, string $title, ): JsonResponse
https://core.telegram.org/bots/api#setchatdescription setChatDescription
setTelegramChatDescription Parameters:
public static function setTelegramChatDescription( int|string $chatId, string $description, ): JsonResponse
https://core.telegram.org/bots/api#pinchatmessage pinChatMessage
pinTelegramChatMessage Parameters:
public static function pinTelegramChatMessage( int|string $chatId, int $messageId, ?bool $disableNotification = null, ): JsonResponse
https://core.telegram.org/bots/api#unpinchatmessage unpinChatMessage
unpinTelegramChatMessage Parameters:
public static function unpinTelegramChatMessage( int|string $chatId, ?int $messageId = null, ): JsonResponse
https://core.telegram.org/bots/api#unpinallchatmessages unpinAllChatMessages
unpinAllTelegramChatMessages Parameters:
public static function unpinAllTelegramChatMessages( int|string $chatId, ): JsonResponse
https://core.telegram.org/bots/api#leavechat leaveChat
leaveTelegramChat Parameters:
public static function leaveTelegramChat( int|string $chatId, ): JsonResponse
https://core.telegram.org/bots/api#getchat getChat
getTelegramChat Parameters:
public static function getTelegramChat( int|string $chatId, ): JsonResponse
https://core.telegram.org/bots/api#getchatadministrators getChatAdministrators
getTelegramChatAdministrators Parameters:
public static function getTelegramChatAdministrators( int|string $chatId, ): JsonResponse
https://core.telegram.org/bots/api#getchatmembercount getChatMemberCount
getTelegramChatMemberCount Parameters:
public static function getTelegramChatMemberCount( int|string $chatId, ): JsonResponse
https://core.telegram.org/bots/api#getchatmember getChatMember
getTelegramChatMember Parameters:
public static function getTelegramChatMember( int|string $chatId, int $userId ): JsonResponse
https://core.telegram.org/bots/api#setchatstickerset setChatStickerSet
setTelegramChatStickerSet Parameters:
public static function setTelegramChatStickerSet( int|string $chatId, string $stickerSetName ): JsonResponse
https://core.telegram.org/bots/api#deletechatstickerset deleteChatStickerSet
deleteTelegramChatStickerSet Parameters:
public static function deleteTelegramChatStickerSet( int|string $chatId, ): JsonResponse
https://core.telegram.org/bots/api#createforumtopic createForumTopic
createTelegramForumTopic Parameters:
public static function createTelegramForumTopic( int|string $chatId, string $name, ?int $iconColor = null, ?string $iconCustomEmojiId = null ): JsonResponse
https://core.telegram.org/bots/api#editforumtopic editForumTopic
editTelegramForumTopic Parameters:
public static function editTelegramForumTopic( int|string $chatId, string $name, int $messageThreadId, ?int $iconColor = null, ?string $iconCustomEmojiId = null ): JsonResponse
https://core.telegram.org/bots/api#closeforumtopic closeForumTopic
closeTelegramForumTopic Parameters:
public static function closeTelegramForumTopic( int|string $chatId, int $messageThreadId ): JsonResponse
https://core.telegram.org/bots/api#reopenforumtopic reopenForumTopic
reopenTelegramForumTopic Parameters:
public static function reopenTelegramForumTopic( int|string $chatId, int $messageThreadId ): JsonResponse
https://core.telegram.org/bots/api#deleteforumtopic deleteForumTopic
deleteTelegramForumTopic Parameters:
public static function deleteTelegramForumTopic( int|string $chatId, int $messageThreadId ): JsonResponse
https://core.telegram.org/bots/api#unpinallforumTopicmessages unpinAllForumTopicMessages
unpinAllTelegramForumTopicMessages Parameters:
public static function unpinAllTelegramForumTopicMessages( int|string $chatId, int $messageThreadId ): JsonResponse
https://core.telegram.org/bots/api#editgeneralforumtopic editGeneralForumTopic
editTelegramGeneralForumTopic Parameters:
public static function editTelegramGeneralForumTopic( int|string $chatId, int $name ): JsonResponse
https://core.telegram.org/bots/api#closegeneralforumtopic closeGeneralForumTopic
closeTelegramGeneralForumTopic Parameters:
public static function closeTelegramGeneralForumTopic( int|string $chatId, ): JsonResponse
https://core.telegram.org/bots/api#reopengeneralforumtopic reopenGeneralForumTopic
reopenTelegramGeneralForumTopic Parameters:
public static function reopenTelegramGeneralForumTopic( int|string $chatId, ): JsonResponse
https://core.telegram.org/bots/api#hidegeneralforumtopic hideGeneralForumTopic
hideTelegramGeneralForumTopic Parameters:
public static function hideTelegramGeneralForumTopic( int|string $chatId, ): JsonResponse
https://core.telegram.org/bots/api#unhidegeneralforumtopic unhideGeneralForumTopic
unhideTelegramGeneralForumTopic Parameters:
public static function unhideTelegramGeneralForumTopic( int|string $chatId, ): JsonResponse
https://core.telegram.org/bots/api#unpinallgeneralforumtopicmessages unpinAllGeneralForumTopicMessages
unpinAllTelegramGeneralForumTopicMessages Parameters:
public static function unpinAllTelegramGeneralForumTopicMessages( int|string $chatId, ): JsonResponse
https://core.telegram.org/bots/api#answercallbackquery answerCallbackQuery
answerTelegramCallbackQuery Parameters:
public static function answerTelegramCallbackQuery( string $callbackQueryId, ?string $text = null, ?bool $showAlert = null, ?string $urlTG = null, ?int $cacheTime = 0 ): JsonResponse
https://core.telegram.org/bots/api#getuserchatboosts getUserChatBoosts
getTelegramUserChatBoosts Parameters:
public static function getTelegramUserChatBoosts( int|string $chatId, int $userId ): JsonResponse
https://core.telegram.org/bots/api#setmycommands setMyCommands
setTelegramMyCommands Parameters:
public static function setTelegramMyCommands( int|string $chatId, array $commands, $scope = null, ?string $language_code = null ): JsonResponse
https://core.telegram.org/bots/api#deletemycommands deleteMyCommands
deleteTelegramMyCommands Parameters:
public static function deleteTelegramMyCommands( int|string $chatId, $scope = null, ?string $language_code = null ): JsonResponse
https://core.telegram.org/bots/api#getmycommands getMyCommands
getTelegramMyCommands Parameters:
public static function getTelegramMyCommands( int|string $chatId, $scope = null, ?string $language_code = null ): JsonResponse
https://core.telegram.org/bots/api#setmyname setMyName
setTelegramMyName Parameters:
public static function setTelegramMyName( int|string $chatId, ?string $name = null, ?string $language_code = null ): JsonResponse
https://core.telegram.org/bots/api#getmyname getMyName
getTelegramMyName Parameters:
public static function getTelegramMyName( int|string $chatId, ?string $language_code = null ): JsonResponse
https://core.telegram.org/bots/api#setmydescription setMyDescription
setTelegramMyDescription Parameters:
public static function setTelegramMyDescription( int|string $chatId, ?string $description = null, ?string $language_code = null ): JsonResponse
https://core.telegram.org/bots/api#getmydescription getMyDescription
getTelegramMyDescription Parameters:
public static function getTelegramMyDescription( int|string $chatId, ?string $language_code = null ): JsonResponse
https://core.telegram.org/bots/api#setmyshortdescription setMyShortDescription
setTelegramMyShortDescription Parameters:
public static function setTelegramMyShortDescription( int|string $chatId, ?string $short_description = null, ?string $language_code = null ): JsonResponse
https://core.telegram.org/bots/api#getmyshortdescription getMyShortDescription
getTelegramMyShortDescription Parameters:
public static function getTelegramMyShortDescription( int|string $chatId, ?string $language_code = null ): JsonResponse
https://core.telegram.org/bots/api#setchatmenubutton setChatMenuButton
setTelegramChatMenuButton Parameters:
public static function setTelegramChatMenuButton( int|string $chatId, ?array $menuButton = null, ?string $language_code = null ): JsonResponse
https://core.telegram.org/bots/api#setmydefaultadministratorrights setMyDefaultAdministratorRights
setTelegramMyDefaultAdministratorRights Parameters:
public static function setTelegramMyDefaultAdministratorRights( int|string $chatId, $rights = null, ?bool $for_channels = null ): JsonResponse
https://core.telegram.org/bots/api#getmydefaultadministratorrights getMyDefaultAdministratorRights
getTelegramMyDefaultAdministratorRights Parameters:
public static function getTelegramMyDefaultAdministratorRights( int|string $chatId, ?bool $for_channels = null ): JsonResponse
https://core.telegram.org/bots/api#editmessagetext editMessageText
editTelegramMessageText Parameters:
public static function editTelegramMessageText( int|string $chatId, ?int $messageId = null, ?string $inlineMessageId = null, string $text, ?string $parseMode = null, ?array $entities = null, $linkPreviewOptions = null, $replyMarkup = null ): JsonResponse
https://core.telegram.org/bots/api#editmessagecaption editMessageCaption
editTelegramMessageCaption Parameters:
public static function editTelegramMessageCaption( null|int|string $chatId = null, ?int $messageId = null, ?string $inlineMessageId = null, ?string $caption = null, ?string $parseMode = null, ?array $captionEntities = null, $replyMarkup = null ): JsonResponse
https://core.telegram.org/bots/api#editmessagemedia editMessageMedia
editTelegramMessageMedia Parameters:
public static function editTelegramMessageMedia( int|string $chatId = null, ?int $messageId = null, ?string $inlineMessageId = null, $media, $replyMarkup = null ): JsonResponse
https://core.telegram.org/bots/api#editmessagelivelocation editMessageLiveLocation
editTelegramMessageLiveLocation Parameters:
public static function editTelegramMessageLiveLocation( int|string $chatId = null, ?int $messageId = null, ?string $inlineMessageId = null, float $latitude, float $longitude, ?float $horizontalAccuracy = null, ?int $heading = null, ?int $proximityAlertRadius = null, $replyMarkup = null ): JsonResponse
https://core.telegram.org/bots/api#stopmessagelivelocation stopMessageLiveLocation
stopTelegramMessageLiveLocation Parameters:
public static function stopTelegramMessageLiveLocation( int|string $chatId = null, ?int $messageId = null, ?string $inlineMessageId = null, $replyMarkup = null ): JsonResponse
https://core.telegram.org/bots/api#editmessagereplymarkup editMessageReplyMarkup
editTelegramMessageReplyMarkup Parameters:
public static function editTelegramMessageReplyMarkup( int|string $chatId = null, ?int $messageId = null, ?string $inlineMessageId = null, $replyMarkup = null ): JsonResponse
https://core.telegram.org/bots/api#stoppoll stopPoll
stopTelegramPoll Parameters:
public static function stopTelegramPoll( int|string $chatId = null, ?int $messageId = null, $replyMarkup = null ): JsonResponse
https://core.telegram.org/bots/api#deletemessage deleteMessage
deleteTelegramMessage Parameters:
public static function deleteTelegramMessage( int|string $chatId, int $messageId ): JsonResponse
https://core.telegram.org/bots/api#deletemessages deleteMessages
deleteTelegramMessages Parameters:
public static function deleteTelegramMessages( int|string $chatId, array $messageIds ): JsonResponse
https://core.telegram.org/bots/api#sendmessage sendMessage
SendTelegramReply Parameters:
public static function SendTelegramReply( string $chatId, string $message, string $replyId, string $parseMode = 'HTML' ): JsonResponse
https://core.telegram.org/bots/api#deletemessage deleteMessage
SendDeleteTelegramMessage Parameters:
public static function SendDeleteTelegramMessage( string $chatId, string $messageId, ?int $seconds = 0 ): JsonResponse
https://core.telegram.org/bots/api#sendmessage sendMessage
SendTelegramMessageEntity Parameters:
public static function SendTelegramMessageEntity( string $chatId, string $messageText, array $entities ): JsonResponse
Webhooks
https://core.telegram.org/bots/webhooks Telegram Bot API supports webhook. If you set webhook for your bot, Telegram will send updates to the specified url
The fastest way
change it to yours bot_token
your_url
putting this in the search bar
https://api.telegram.org/bot_token/setwebhook?url=your_url
example
https://api.telegram.org/bot1310530208:AAHAKEpv_E9k3rWc09G7Z0rJVcKHGEBqo6c/setwebhook?url=https://example.com/api/telegram-bot/handle
get the answer
{"ok": true, "result" :true, "description": "Webhook is already set"}
create a controller
php artisan make:controller TelegramWebhookController
add to api.php
file
Route::controller(\App\Http\Controllers\TelegramWebhookController::class)->group(function () { Route::post('/telegram-bot/handle', 'handle'); });
write in controller
use BlueSkies\TelegramBotHelper\Traits\TelegramBotHelper; class TelegramWebhookController extends Controller { use TelegramBotHelper; public function handle(Request $request) { $bodyContent = $request->getContent(); return self::SendTelegramMessage('chat_id',"<pre>$bodyContent</pre>"); } }