blue_skies/telegram-bot-helper

Telegram bot集成到Laravel中

1.5 2024-02-07 04:52 UTC

This package is auto-updated.

Last update: 2024-09-07 14:05:08 UTC


README

package blue skies telegram-bot-helper

Static Badge License Загрузки Latest Stable Version

安装

您可以通过composer安装此包

composer require blue_skies/telegram-bot-helper

快速开始

打开.env文件,并将Telegram bot令牌添加到其中

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
发送Telegram消息参数

   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
发送Telegram消息发送TelegramForwardMessage

 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
发送Telegram消息发送TelegramForwardMessages

    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
发送Telegram消息发送TelegramCopyMessage

      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
发送Telegram消息发送TelegramCopyMessages

      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
发送Telegram消息发送TelegramPhoto

   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
发送Telegram消息发送TelegramAudio

      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
发送Telegram文档参数

      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
发送Telegram视频参数

    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
发送Telegram动画参数

    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
发送Telegram语音参数

    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
发送Telegram视频笔记参数

    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
发送Telegram媒体组参数

    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
发送Telegram位置参数

    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
发送Telegram地点参数

    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
发送Telegram联系人参数

    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
发送Telegram投票参数

    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
发送Telegram骰子参数

    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
发送Telegram聊天动作参数

    public static function SendTelegramChatAction(
        int|string $chatId,
        ?int       $messageThreadId = null,
        string     $action
    ): JsonResponse

https://core.telegram.org/bots/api#setmessagereaction setMessageReaction
发送Telegram消息反应参数

    public static function SendTelegramMessageReaction(
        int|string $chatId,
        int        $messageId,
        ?array     $reaction = null,
        ?bool      $isBig = null,

    ): JsonResponse

https://core.telegram.org/bots/api#getuserprofilephotos getUserProfilePhotos
获取Telegram用户个人照片参数

    public static function getTelegramUserProfilePhotos(
        int  $userId,
        ?int $offset = null,
        ?int $limit = null
    ): JsonResponse

https://core.telegram.org/bots/api#getfile getFile
获取Telegram文件参数

    public static function getTelegramFile(
        string $fileId,
    ): JsonResponse

https://core.telegram.org/bots/api#banchatmember banChatMember
禁止Telegram聊天成员参数

    public static function banTelegramChatMember(
        int|string $chatId,
        int        $userId,
        ?int       $untilDate = null,
        ?bool      $revokeMessages = null
    ): JsonResponse

https://core.telegram.org/bots/api#unbanchatmember unbanChatMember
解除禁止Telegram聊天成员参数

    public static function unbanTelegramChatMember(
        int|string $chatId,
        int        $userId,
        ?bool      $onlyIfBanned = null
    ): JsonResponse

https://core.telegram.org/bots/api#restrictchatmember restrictChatMember
限制Telegram聊天成员参数

    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
提升Telegram聊天成员参数

    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
设置Telegram聊天管理员自定义标题参数

    public static function setTelegramChatAdministratorCustomTitle(
        int|string $chatId,
        int        $userId,
        string     $customTitle,
    ): JsonResponse

https://core.telegram.org/bots/api#banchatsenderchat banChatSenderChat
禁止Telegram聊天发送者聊天参数

    public static function banTelegramChatSenderChat(
        int|string $chatId,
        int        $senderChatId,
    ): JsonResponse

https://core.telegram.org/bots/api#unbanchatsenderchat unbanChatSenderChat
解除禁止Telegram聊天发送者聊天参数

    public static function unbanTelegramChatSenderChat(
        int|string $chatId,
        int        $senderChatId
    ): JsonResponse

https://core.telegram.org/bots/api#setchatpermissions setChatPermissions
设置Telegram聊天权限参数

    public static function setTelegramChatPermissions(
        int|string $chatId,
        array      $permissions,
        ?bool      $useIndependentChatPermissions = null
    ): JsonResponse

https://core.telegram.org/bots/api#exportchatinvitelink exportChatInviteLink
exportTelegramChatInviteLink 参数

    public static function exportTelegramChatInviteLink(
        int|string $chatId,
    ): JsonResponse

https://core.telegram.org/bots/api#createchatinvitelink createChatInviteLink
createTelegramChatInviteLink 参数

    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 参数

    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 参数

    public static function revokeTelegramChatInviteLink(
        int|string $chatId,
        string     $inviteLink
    ): JsonResponse

https://core.telegram.org/bots/api#approvechatjoinrequest approveChatJoinRequest
approveTelegramChatJoinRequest 参数

    public static function approveTelegramChatJoinRequest(
        int|string $chatId,
        int        $userId,
    ): JsonResponse

https://core.telegram.org/bots/api#declinechatjoinrequest declineChatJoinRequest
declineTelegramChatJoinRequest 参数

    public static function declineTelegramChatJoinRequest(
        int|string $chatId,
        int        $userId,
    ): JsonResponse

https://core.telegram.org/bots/api#setchatphoto setChatPhoto
setTelegramChatPhoto 参数

    public static function setTelegramChatPhoto(
        int|string $chatId,
        string     $photo,
    ): JsonResponse

https://core.telegram.org/bots/api#deletechatphoto deleteChatPhoto
deleteTelegramChatPhoto 参数

    public static function deleteTelegramChatPhoto(
        int|string $chatId,
    ): JsonResponse

https://core.telegram.org/bots/api#setchattitle setChatTitle
setTelegramChatTitle 参数

    public static function setTelegramChatTitle(
        int|string $chatId,
        string     $title,
    ): JsonResponse

https://core.telegram.org/bots/api#setchatdescription setChatDescription
setTelegramChatDescription 参数

    public static function setTelegramChatDescription(
        int|string $chatId,
        string     $description,
    ): JsonResponse

https://core.telegram.org/bots/api#pinchatmessage pinChatMessage
pinTelegramChatMessage 参数

    public static function pinTelegramChatMessage(
        int|string $chatId,
        int        $messageId,
        ?bool      $disableNotification = null,
    ): JsonResponse

https://core.telegram.org/bots/api#unpinchatmessage unpinChatMessage
unpinTelegramChatMessage 参数

    public static function unpinTelegramChatMessage(
        int|string $chatId,
        ?int       $messageId = null,
    ): JsonResponse

https://core.telegram.org/bots/api#unpinallchatmessages unpinAllChatMessages
unpinAllTelegramChatMessages 参数

    public static function unpinAllTelegramChatMessages(
        int|string $chatId,

    ): JsonResponse

https://core.telegram.org/bots/api#leavechat leaveChat
leaveTelegramChat 参数

    public static function leaveTelegramChat(
        int|string $chatId,

    ): JsonResponse

https://core.telegram.org/bots/api#getchat getChat
getTelegramChat 参数

    public static function getTelegramChat(
        int|string $chatId,

    ): JsonResponse

https://core.telegram.org/bots/api#getchatadministrators getChatAdministrators
getTelegramChatAdministrators 参数

    public static function getTelegramChatAdministrators(
        int|string $chatId,

    ): JsonResponse

https://core.telegram.org/bots/api#getchatmembercount getChatMemberCount
getTelegramChatMemberCount 参数

    public static function getTelegramChatMemberCount(
        int|string $chatId,

    ): JsonResponse

https://core.telegram.org/bots/api#getchatmember getChatMember
getTelegramChatMember 参数

    public static function getTelegramChatMember(
        int|string $chatId,
        int        $userId

    ): JsonResponse

https://core.telegram.org/bots/api#setchatstickerset setChatStickerSet
setTelegramChatStickerSet 参数

    public static function setTelegramChatStickerSet(
        int|string $chatId,
        string     $stickerSetName

    ): JsonResponse

https://core.telegram.org/bots/api#deletechatstickerset deleteChatStickerSet
deleteTelegramChatStickerSet 参数

    public static function deleteTelegramChatStickerSet(
        int|string $chatId,

    ): JsonResponse

https://core.telegram.org/bots/api#createforumtopic createForumTopic
createTelegramForumTopic 参数

    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 参数

    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 参数

    public static function closeTelegramForumTopic(
        int|string $chatId,
        int        $messageThreadId
    ): JsonResponse

https://core.telegram.org/bots/api#reopenforumtopic reopenForumTopic
reopenTelegramForumTopic 参数

    public static function reopenTelegramForumTopic(
        int|string $chatId,
        int        $messageThreadId
    ): JsonResponse

https://core.telegram.org/bots/api#deleteforumtopic deleteForumTopic
deleteTelegramForumTopic 参数

    public static function deleteTelegramForumTopic(
        int|string $chatId,
        int        $messageThreadId
    ): JsonResponse

https://core.telegram.org/bots/api#unpinallforumTopicmessages unpinAllForumTopicMessages
unpinAllTelegramForumTopicMessages 参数

    public static function unpinAllTelegramForumTopicMessages(
        int|string $chatId,
        int        $messageThreadId
    ): JsonResponse

https://core.telegram.org/bots/api#editgeneralforumtopic editGeneralForumTopic
editTelegramGeneralForumTopic 参数

    public static function editTelegramGeneralForumTopic(
        int|string $chatId,
        int        $name
    ): JsonResponse

https://core.telegram.org/bots/api#closegeneralforumtopic closeGeneralForumTopic
closeTelegramGeneralForumTopic 参数

    public static function closeTelegramGeneralForumTopic(
        int|string $chatId,
    ): JsonResponse

https://core.telegram.org/bots/api#reopengeneralforumtopic reopenGeneralForumTopic
reopenTelegramGeneralForumTopic 参数

    public static function reopenTelegramGeneralForumTopic(
        int|string $chatId,
    ): JsonResponse

https://core.telegram.org/bots/api#hidegeneralforumtopic hideGeneralForumTopic
hideTelegramGeneralForumTopic 参数

    public static function hideTelegramGeneralForumTopic(
        int|string $chatId,
    ): JsonResponse

https://core.telegram.org/bots/api#unhidegeneralforumtopic unhideGeneralForumTopic
unhideTelegramGeneralForumTopic 参数

    public static function unhideTelegramGeneralForumTopic(
        int|string $chatId,
    ): JsonResponse

https://core.telegram.org/bots/api#unpinallgeneralforumtopicmessages unpinAllGeneralForumTopicMessages
unpinAllTelegramGeneralForumTopicMessages 参数

    public static function unpinAllTelegramGeneralForumTopicMessages(
        int|string $chatId,
    ): JsonResponse

https://core.telegram.org/bots/api#answercallbackquery answerCallbackQuery
answerTelegramCallbackQuery 参数

    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 参数

    public static function getTelegramUserChatBoosts(
        int|string $chatId,
        int        $userId
    ): JsonResponse

https://core.telegram.org/bots/api#setmycommands setMyCommands
setTelegramMyCommands 参数

    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 参数

    public static function deleteTelegramMyCommands(
        int|string $chatId,
                   $scope = null,
        ?string    $language_code = null
    ): JsonResponse

https://core.telegram.org/bots/api#getmycommands getMyCommands
getTelegramMyCommands 参数

    public static function getTelegramMyCommands(
        int|string $chatId,
                   $scope = null,
        ?string    $language_code = null
    ): JsonResponse

https://core.telegram.org/bots/api#setmyname setMyName
setTelegramMyName 参数

    public static function setTelegramMyName(
        int|string $chatId,
        ?string    $name = null,
        ?string    $language_code = null
    ): JsonResponse

https://core.telegram.org/bots/api#getmyname getMyName
getTelegramMyName 参数

    public static function getTelegramMyName(
        int|string $chatId,
        ?string    $language_code = null
    ): JsonResponse

https://core.telegram.org/bots/api#setmydescription setMyDescription
setTelegramMyDescription 参数

    public static function setTelegramMyDescription(
        int|string $chatId,
        ?string    $description = null,
        ?string    $language_code = null
    ): JsonResponse

https://core.telegram.org/bots/api#getmydescription getMyDescription
getTelegramMyDescription 参数

    public static function getTelegramMyDescription(
        int|string $chatId,
        ?string    $language_code = null
    ): JsonResponse

https://core.telegram.org/bots/api#setmyshortdescription setMyShortDescription
setTelegramMyShortDescription 参数

    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 参数

    public static function getTelegramMyShortDescription(
        int|string $chatId,
        ?string    $language_code = null
    ): JsonResponse

https://core.telegram.org/bots/api#setchatmenubutton setChatMenuButton
setTelegramChatMenuButton 参数

    public static function setTelegramChatMenuButton(
        int|string $chatId,
        ?array     $menuButton = null,
        ?string    $language_code = null
    ): JsonResponse

https://core.telegram.org/bots/api#setmydefaultadministratorrights setMyDefaultAdministratorRights
setTelegramMyDefaultAdministratorRights 参数

    public static function setTelegramMyDefaultAdministratorRights(
        int|string $chatId,
                   $rights = null,
        ?bool      $for_channels = null
    ): JsonResponse

https://core.telegram.org/bots/api#getmydefaultadministratorrights getMyDefaultAdministratorRights
获取Telegram默认管理员权限参数

    public static function getTelegramMyDefaultAdministratorRights(
        int|string $chatId,
        ?bool      $for_channels = null
    ): JsonResponse

https://core.telegram.org/bots/api#editmessagetext editMessageText
编辑Telegram消息文本参数

    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
编辑Telegram消息标题参数

    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
编辑Telegram消息媒体参数

    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
编辑Telegram直播位置参数

    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
停止Telegram直播位置参数

    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
编辑Telegram回复标记参数

    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
停止Telegram投票参数

    public static function stopTelegramPoll(
        int|string $chatId = null,
        ?int       $messageId = null,
                   $replyMarkup = null
    ): JsonResponse

https://core.telegram.org/bots/api#deletemessage deleteMessage
删除Telegram消息参数

    public static function deleteTelegramMessage(
        int|string $chatId,
        int        $messageId
    ): JsonResponse

https://core.telegram.org/bots/api#deletemessages deleteMessages
删除Telegram消息列表参数

    public static function deleteTelegramMessages(
        int|string $chatId,
        array      $messageIds
    ): JsonResponse

https://core.telegram.org/bots/api#sendmessage sendMessage
发送Telegram回复参数

    public static function SendTelegramReply(
    string $chatId, 
    string $message, 
    string $replyId, 
    string $parseMode = 'HTML'
    ): JsonResponse

https://core.telegram.org/bots/api#deletemessage deleteMessage
发送删除Telegram消息参数

    public static function SendDeleteTelegramMessage(
    string $chatId, 
    string $messageId, 
    ?int $seconds = 0
    ): JsonResponse

https://core.telegram.org/bots/api#sendmessage sendMessage
发送Telegram消息实体参数

    public static function SendTelegramMessageEntity(
    string $chatId, 
    string $messageText, 
    array $entities
    ): JsonResponse

Webhooks

https://core.telegram.org/bots/webhooks Telegram Bot API支持webhook。如果您为您的机器人设置了webhook,Telegram将向指定的url发送更新

最快的方式

将其更改为您的 bot_token your_url

在搜索栏中放入此内容

https://api.telegram.org/bot_token/setwebhook?url=your_url

示例

https://api.telegram.org/bot1310530208:AAHAKEpv_E9k3rWc09G7Z0rJVcKHGEBqo6c/setwebhook?url=https://example.com/api/telegram-bot/handle

获取答案

{"ok": true, "result" :true, "description": "Webhook is already set"}

创建控制器

   php artisan make:controller TelegramWebhookController

添加到 api.php 文件

Route::controller(\App\Http\Controllers\TelegramWebhookController::class)->group(function () {
    Route::post('/telegram-bot/handle', 'handle');
});

在控制器中编写

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>");
    }
}

编写一些聊天内容