Download the PHP package andisiahaan/gramsea-telegram-bot without Composer
On this page you can find all versions of the php package andisiahaan/gramsea-telegram-bot. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download andisiahaan/gramsea-telegram-bot
More information about andisiahaan/gramsea-telegram-bot
Files in andisiahaan/gramsea-telegram-bot
Package gramsea-telegram-bot
Short Description A simple and powerful PHP library for Telegram Bot API
License MIT
Informations about the package gramsea-telegram-bot
Gramsea Telegram Bot PHP Library
Library PHP sederhana dan powerful untuk berinteraksi dengan Telegram Bot API tanpa dependensi framework.
โจ Fitur
- ๐ Zero Framework Dependencies - PHP murni, bisa digunakan di mana saja
- ๐ฏ Magic Method - Panggil method API Telegram langsung
- ๐ฆ Fluent Sender Classes - Method chaining untuk mengirim pesan
- ๐จ Update Wrapper - Object-oriented access ke webhook data
- ๐ผ๏ธ Media Helper - Deteksi otomatis tipe file
- โจ๏ธ Keyboard Builder - Fluent builder untuk inline & reply keyboard
- ๐ Callback Data - Encode/decode callback data dengan kompresi
- ๐ Deep Link - Generate & parse deep links dan referral codes
- โ๏ธ Text Formatter - Fluent builder untuk formatting HTML
- ๐ Limits Helper - Constants dan validasi untuk Telegram limits
- ๐ Emoji Constants - Collection emoji yang sering dipakai
- ๐ง Moderation Tools - Ban, mute, restrict, pin messages
- โ ๏ธ Exception Handling - Custom exception untuk error handling
๐ฆ Instalasi
๐ Quick Start
Penggunaan Dasar
Menggunakan Fluent Sender (Recommended)
๐ Dokumentasi
Class Gramsea
Class utama dengan magic method untuk semua Telegram Bot API.
Sender Factory Methods
Webhook Management
Chat Member Checks
Chat Actions
Moderation
Keyboard Builders
Bot Commands
File Operations
๐จ Sender Classes
Library menyediakan 5 sender class dengan fluent chaining API:
| Class | Kegunaan |
|---|---|
MessageSender |
General sender, auto-delegates ke sender yang tepat |
TextSender |
Khusus text message dengan link preview options |
MediaSender |
Khusus single media (photo, video, audio, document) |
MediaGroupSender |
Khusus media group/album (2-10 items) |
MassMessageSender |
Concurrent mass sending ke banyak target sekaligus |
MessageSender (Recommended)
Auto-detects dan delegates ke sender yang tepat:
- Text only โ
TextSender - 1 media โ
MediaSender - 2+ media โ
MediaGroupSender
TextSender
Untuk text message dengan kontrol penuh atas link preview.
Link Preview Methods:
noPreview()- Disable link previewpreviewUrl($url)- Set custom URL for previewsmallPreview()- Prefer small medialargePreview()- Prefer large mediapreviewAboveText()- Show preview above message text
MediaSender
Untuk single media dengan caption.
Media Methods:
photo($url),video($url),audio($url),document($url),animation($url),voice($url)media($url)- Auto-detect type dari extensioncaption($text)- Set caption (supports markdown)captionHtml($html)- Set caption tanpa konversi
MediaGroupSender
Untuk mengirim album (2-10 media items).
Media Group Rules:
- โ Photo + Video = OK
- โ Document + Document = OK
- โ Audio + Audio = OK
- โ Photo + Document = NOT OK
- โ Video + Audio = NOT OK
Common Chaining Methods
Semua sender class memiliki method berikut:
MassMessageSender
Untuk mengirim pesan secara concurrent ke banyak target sekaligus menggunakan Guzzle Pool. Setiap target memiliki konten sendiri (text, media, reply_markup).
Target Format:
chat_id(required) - Target chat IDtext(optional) - Text pesan (supports markdown)media(optional) - String atau array URL mediareply_markup(optional) - Keyboard (hasil dari ReplyMarkup class)
Result Methods (MassSendResult):
Global Options:
๐จ Update Wrapper
Object-oriented wrapper untuk mengakses data webhook.
Type Checks:
isMessage(),isEditedMessage(),isChannelPost(),isEditedChannelPost()isCallbackQuery(),isInlineQuery()isMyChatMember(),isChatMember(),isChatJoinRequest()hasMessage()- any message type
Message Object:
text(),caption(),textOrCaption()from(),chat(),chatId(),fromId()hasPhoto(),hasVideo(),hasDocument(),hasMedia()isCommand(),command(),commandArgs()isReply(),replyToMessage()
Chat Object:
id(),type(),name(),username()isPrivate(),isGroup(),isSupergroup(),isChannel()
User Object:
id(),fullName(),username(),languageCode()isPremium(),mentionHtml()
Support Classes
Support\DeepLink
Generate dan parse Telegram deep links.
Support\TextFormatter
Fluent builder untuk HTML formatting.
Support\ReplyMarkup
Format keyboard markup dengan auto row wrapping.
Support\Limit
Constants untuk Telegram API limits.
Support\Emoji
Emoji constants yang sering dipakai.
Support\MediaHelper
Deteksi tipe media dari file extension.
Support\InlineKeyboard
Fluent builder untuk inline keyboard dengan pattern umum.
Support\CallbackData
Encode/decode callback data dengan kompresi untuk ID besar.
Curl Configuration
Exception Handling
Library menyediakan exception classes yang spesifik untuk berbagai error dari Telegram API:
| Exception | Error Code | Keterangan |
|---|---|---|
BadRequestException |
400 | Parameter tidak valid |
UnauthorizedException |
401 | Bot token tidak valid |
ForbiddenException |
403 | Bot tidak punya akses (diblok, di-kick, dll) |
NotFoundException |
404 | Chat/user/message tidak ditemukan |
ConflictException |
409 | Conflict webhook/polling |
TooManyRequestsException |
429 | Rate limit tercapai |
TelegramServerException |
500+ | Server Telegram error |
ApiException |
- | Base class untuk semua API errors |
NetworkException |
- | Network/connection errors |
Basic Usage
Exception Methods
ApiException (Base Class)
ForbiddenException
NotFoundException
ConflictException
TooManyRequestsException
NetworkException
๐ Struktur Library
๐งช Testing
๐ License
MIT License - lihat LICENSE
๐ค Author
Andi Saputra Siahaan
- Website: andipedia.com
- Email: [email protected]
All versions of gramsea-telegram-bot with dependencies
ext-curl Version *
ext-json Version *
ext-mbstring Version *
guzzlehttp/guzzle Version ^7.0