types

package
v1.8.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2026 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PerSearchLimit = 12
)

Variables

View Source
var MessageTypeFromString = map[string]MessageType{
	"text":     MessageTypeText,
	"photo":    MessageTypePhoto,
	"video":    MessageTypeVideo,
	"document": MessageTypeDocument,
	"voice":    MessageTypeVoice,
	"audio":    MessageTypeAudio,
	"poll":     MessageTypePoll,
	"story":    MessageTypeStory,
}
View Source
var MessageTypeToDisplayString = map[MessageType]string{
	MessageTypeText:     "文本",
	MessageTypePhoto:    "图片",
	MessageTypeVideo:    "视频",
	MessageTypeDocument: "文件",
	MessageTypeVoice:    "语音",
	MessageTypeAudio:    "音频",
	MessageTypePoll:     "投票",
	MessageTypeStory:    "动态",
}
View Source
var MessageTypeToEmoji = map[MessageType]string{
	MessageTypeText:     "💬",
	MessageTypePhoto:    "🖼️",
	MessageTypeVideo:    "🎥",
	MessageTypeDocument: "📄",
	MessageTypeVoice:    "🎙️",
	MessageTypeAudio:    "🎵",
	MessageTypePoll:     "📊",
	MessageTypeStory:    "🪟",
}
View Source
var MessageTypeToString = map[MessageType]string{
	MessageTypeText:     "text",
	MessageTypePhoto:    "photo",
	MessageTypeVideo:    "video",
	MessageTypeDocument: "document",
	MessageTypeVoice:    "voice",
	MessageTypeAudio:    "audio",
	MessageTypePoll:     "poll",
	MessageTypeStory:    "story",
}
View Source
var (
	StickerFileNames = []string{"sticker.webp", "sticker.webm", "AnimatedSticker.tgs", "video.mp4", "animation.gif.mp4"}
)

Functions

This section is empty.

Types

type MessageDocument

type MessageDocument struct {
	// Telegram message ID
	ID   int64 `json:"id"`
	Type int   `json:"type"`
	// The original text of the message
	Message string `json:"message"`
	// The OCRed text of the message
	Ocred string `json:"ocred"`
	// [TODO] The AI generated text of the message(summarization, caption, tagging, etc.)
	AIGenerated string `json:"aigenerated"`
	// The ID of the user who sent the message
	UserID    int64 `json:"user_id"`
	ChatID    int64 `json:"chat_id"`
	Timestamp int64 `json:"timestamp"`
}

type MessageType

type MessageType int
const (
	MessageTypeText MessageType = iota
	MessageTypePhoto
	MessageTypeVideo
	MessageTypeDocument
	MessageTypeVoice
	MessageTypeAudio
	MessageTypePoll
	MessageTypeStory
)

type SearchHit

type SearchHit struct {
	MessageDocument
	Formatted SearchHitFormatted `json:"_formatted"`
}

func (SearchHit) FullFormattedText added in v1.0.0

func (s SearchHit) FullFormattedText() string

func (SearchHit) FullText added in v1.0.0

func (s SearchHit) FullText() string
func (s SearchHit) MessageLink() string

type SearchHitFormatted added in v1.0.0

type SearchHitFormatted struct {
	ID          string `json:"id"`
	Type        string `json:"type"`
	Message     string `json:"message"`
	Ocred       string `json:"ocred"`
	AIGenerated string `json:"aigenerated"`
	UserID      string `json:"user_id"`
	ChatID      string `json:"chat_id"`
	Timestamp   string `json:"timestamp"`
}

type SearchRequest

type SearchRequest struct {
	ChatID            int64         `json:"chat_id"`
	Query             string        `json:"query"`
	ChatIDs           []int64       `json:"chat_ids"`
	AllChats          bool          `json:"all_chats"`
	TypeFilters       []MessageType `json:"type_filters"`
	UserFilters       []int64       `json:"user_filters"`
	DisableOcred      bool          `json:"disable_ocred"`      // 不搜索 OCR 文字
	EnableAIGenerated bool          `json:"enable_aigenerated"` // [TODO] 搜索 AI 生成的内容(not implemented yet)
	Limit             int64         `json:"limit"`
	Offset            int64         `json:"offset"`
}

func (SearchRequest) FilterExpression added in v0.6.0

func (r SearchRequest) FilterExpression() (string, error)

type SearchResponse added in v1.0.0

type SearchResponse struct {
	Hits               []SearchHit `json:"hits,omitempty"`
	ProcessingTimeMs   int64       `json:"processingTimeMs,omitempty"`
	Offset             int64       `json:"offset,omitempty"`
	Limit              int64       `json:"limit,omitempty"`
	EstimatedTotalHits int64       `json:"estimatedTotalHits,omitempty"`
	SemanticHitCount   int64       `json:"semanticHitCount,omitempty"`
	Raw                any
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL