Skip to content

Latest commit

 

History

History
335 lines (300 loc) · 10.5 KB

README.md

File metadata and controls

335 lines (300 loc) · 10.5 KB

Laravel Telegram

Structure

Buy Me A Coffee

Getting started

Requirements

  • PHP >= 8
  • Laravel >= 10

Installation

composer require kolirt/laravel-telegram

Setup

php artisan telegram:install

php artisan migrate

php artisan telegram:bot-create {bot-name} {token}

Console commands

  • telegram:bot-create {bot_name} - Create a new bot
  • telegram:bot-delete-commands {bot_name} - Delete bot commands
  • telegram:bot-update-commands {bot_name} - Update bot commands
  • telegram:install - Installation the package
  • telegram:meta - Generate metadata
  • telegram:publish-commands - Publish example commands
  • telegram:publish-config - Publish the config file
  • telegram:publish-migrations - Publish migration files
  • telegram:publish-routes - Publish the route file
  • telegram:serve {bot_name} - Serve the bot without webhook

Define bot commands

You can configure bot commands in routes/telegram.php, which will be published after the installation, and then you can update the commands in bot using the php aritsan telegram:bot-update-commands {bot_name} command

$config->bot('test')
    ->commands(function (CommandBuilder $builder) {
        $builder->start(StartCommand::class, 'Start command description');
        $builder->command('info', InfoCommand::class, 'Info command description');
        $builder->command('test', [TestCommand::class, 'index'], 'Test command description');
    })

Define keyboard

$config->bot('tma')
    ->keyboard(function (KeyboardBuilder $keyboard) {
        $keyboard->defaultHandler(StartCommand::class);
        // OR
        $keyboard->defaultHandler(HomeController::class);
    });

Telegram API implementation status

Types

Methods

  • User - [source code]
  • Chat - [source code]
  • Message - [source code]
  • MessageId
  • InaccessibleMessage
  • MaybeInaccessibleMessage
  • MessageEntity
  • TextQuote
  • ExternalReplyInfo
  • ReplyParameters
  • MessageOrigin
  • MessageOriginUser
  • MessageOriginHiddenUser
  • MessageOriginChat
  • MessageOriginChannel
  • PhotoSize
  • Animation
  • Audio
  • Document
  • Story
  • Video
  • VideoNote
  • Voice
  • Contact
  • Dice
  • PollOption
  • PollAnswer
  • Poll
  • Location
  • Venue
  • WebAppData
  • ProximityAlertTriggered
  • MessageAutoDeleteTimerChanged
  • ChatBoostAdded
  • ForumTopicCreated
  • ForumTopicClosed
  • ForumTopicEdited
  • ForumTopicReopened
  • GeneralForumTopicHidden
  • GeneralForumTopicUnhidden
  • SharedUser
  • UsersShared
  • ChatShared
  • WriteAccessAllowed
  • VideoChatScheduled
  • VideoChatStarted
  • VideoChatEnded
  • VideoChatParticipantsInvited
  • GiveawayCreated
  • Giveaway
  • GiveawayWinners
  • GiveawayCompleted
  • LinkPreviewOptions
  • UserProfilePhotos
  • File
  • WebAppInfo
  • ReplyKeyboardMarkup
  • KeyboardButton
  • KeyboardButtonRequestUsers
  • KeyboardButtonRequestChat
  • KeyboardButtonPollType
  • ReplyKeyboardRemove
  • InlineKeyboardMarkup
  • InlineKeyboardButton
  • LoginUrl
  • SwitchInlineQueryChosenChat
  • CallbackQuery
  • ForceReply
  • ChatPhoto
  • ChatInviteLink
  • ChatAdministratorRights
  • ChatMemberUpdated
  • ChatMember - [source code]
  • ChatMemberOwner - [source code]
  • ChatMemberAdministrator - [source code]
  • ChatMemberMember - [source code]
  • ChatMemberRestricted - [source code]
  • ChatMemberLeft - [source code]
  • ChatMemberBanned - [source code]
  • ChatJoinRequest
  • ChatPermissions
  • Birthdate
  • BusinessIntro
  • BusinessLocation
  • BusinessOpeningHoursInterval
  • BusinessOpeningHours
  • ChatLocation
  • ReactionType
  • ReactionTypeEmoji
  • ReactionTypeCustomEmoji
  • ReactionCount
  • MessageReactionUpdated
  • MessageReactionCountUpdated
  • ForumTopic
  • BotCommand
  • BotCommandScope
  • Determining list of commands
  • BotCommandScopeDefault
  • BotCommandScopeAllPrivateChats
  • BotCommandScopeAllGroupChats
  • BotCommandScopeAllChatAdministrators
  • BotCommandScopeChat
  • BotCommandScopeChatAdministrators
  • BotCommandScopeChatMember
  • BotName
  • BotDescription
  • BotShortDescription
  • MenuButton
  • MenuButtonCommands
  • MenuButtonWebApp
  • MenuButtonDefault
  • ChatBoostSource
  • ChatBoostSourcePremium
  • ChatBoostSourceGiftCode
  • ChatBoostSourceGiveaway
  • ChatBoost
  • ChatBoostUpdated
  • ChatBoostRemoved
  • UserChatBoosts
  • BusinessConnection
  • BusinessMessagesDeleted
  • ResponseParameters
  • InputMedia
  • InputMediaPhoto
  • InputMediaVideo
  • InputMediaAnimation
  • InputMediaAudio
  • InputMediaDocument
  • InputFile
  • Sending files
  • Accent colors
  • Profile accent colors
  • Inline mode objects
  • getMe [source code]
  • logOut
  • close
  • sendMessage [source code]
  • Formatting options
  • forwardMessage
  • forwardMessages
  • copyMessage
  • copyMessages
  • sendPhoto [source code]
  • sendAudio
  • sendDocument
  • sendVideo
  • sendAnimation
  • sendVoice
  • sendVideoNote
  • sendMediaGroup
  • sendLocation
  • sendVenue
  • sendContact
  • sendPoll
  • sendDice
  • sendChatAction
  • setMessageReaction
  • getUserProfilePhotos
  • getFile
  • banChatMember
  • unbanChatMember
  • restrictChatMember
  • promoteChatMember
  • setChatAdministratorCustomTitle
  • banChatSenderChat
  • unbanChatSenderChat
  • setChatPermissions
  • exportChatInviteLink
  • createChatInviteLink
  • editChatInviteLink
  • revokeChatInviteLink
  • approveChatJoinRequest
  • declineChatJoinRequest
  • setChatPhoto
  • deleteChatPhoto
  • setChatTitle
  • setChatDescription
  • pinChatMessage
  • unpinChatMessage
  • unpinAllChatMessages
  • leaveChat
  • getChat
  • getChatAdministrators
  • getChatMemberCount
  • getChatMember - [source code]
  • setChatStickerSet
  • deleteChatStickerSet
  • getForumTopicIconStickers
  • createForumTopic
  • editForumTopic
  • closeForumTopic
  • reopenForumTopic
  • deleteForumTopic
  • unpinAllForumTopicMessages
  • editGeneralForumTopic
  • closeGeneralForumTopic
  • reopenGeneralForumTopic
  • hideGeneralForumTopic
  • unhideGeneralForumTopic
  • unpinAllGeneralForumTopicMessages
  • answerCallbackQuery
  • getUserChatBoosts
  • getBusinessConnection
  • setMyCommands [source code]
  • deleteMyCommands [source code]
  • getMyCommands [source code]
  • setMyName
  • getMyName
  • setMyDescription
  • getMyDescription
  • setMyShortDescription
  • getMyShortDescription
  • setChatMenuButton
  • getChatMenuButton
  • setMyDefaultAdministratorRights
  • getMyDefaultAdministratorRights
  • Inline mode methods

FAQ

Check closed issues to get answers for most asked questions

License

MIT

Other packages

Check out my other packages on my GitHub profile