Documentation
¶
Overview ¶
Package tgjson holds the flat JSON DTOs shared by the MCP server and the REST API, plus converters from the telegram domain types.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MediaFile ¶
MediaFile extracts the best downloadable file from a message: key, display name, size. Empty key when there is none.
func MessagePreview ¶
MessagePreview renders a short one-line preview of a message.
Types ¶
type ChatInfo ¶
type ChatInfo struct {
ID int64 `json:"id" jsonschema:"canonical chat ID (user ID, negative group ID, or -100channelID)"`
Type string `json:"type" jsonschema:"private, group, supergroup or channel"`
Title string `json:"title"`
Username string `json:"username,omitempty"`
UnreadCount int32 `json:"unread_count"`
Pinned bool `json:"pinned"`
LastMessage string `json:"last_message,omitempty" jsonschema:"preview of the last message"`
}
ChatInfo is the flat chat representation returned to clients.
func ToChatInfo ¶
ToChatInfo converts a domain chat to its JSON DTO.
type ContactInfo ¶
type ContactInfo struct {
ID int64 `json:"id"`
FirstName string `json:"first_name"`
LastName string `json:"last_name,omitempty"`
Username string `json:"username,omitempty"`
Phone string `json:"phone,omitempty"`
IsBot bool `json:"is_bot"`
}
ContactInfo is the flat user representation returned to clients.
func ToContactInfo ¶
func ToContactInfo(u *telegram.User) ContactInfo
ToContactInfo converts a domain user to its JSON DTO.
type MessageInfo ¶
type MessageInfo struct {
ID int64 `json:"id"`
ChatID int64 `json:"chat_id"`
Date int32 `json:"date" jsonschema:"unix timestamp"`
SenderUserID int64 `json:"sender_user_id,omitempty"`
SenderChatID int64 `json:"sender_chat_id,omitempty"`
IsOutgoing bool `json:"is_outgoing"`
ReplyToMessageID int64 `json:"reply_to_message_id,omitempty"`
Type string `` /* 148-byte string literal not displayed */
Text string `json:"text,omitempty" jsonschema:"message text or media caption"`
MediaFileKey string `json:"media_file_key,omitempty" jsonschema:"file registry key, usable with download_media"`
MediaFileName string `json:"media_file_name,omitempty"`
MediaSize int64 `json:"media_size,omitempty"`
}
MessageInfo is the flat message representation returned to clients.
func ToMessageInfo ¶
func ToMessageInfo(m *telegram.Message) MessageInfo
ToMessageInfo converts a domain message to its JSON DTO.