api

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2025 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetIndexInfo added in v0.8.0

func GetIndexInfo(c *fiber.Ctx) error

GetIndexInfo 获取指定聊天的索引信息 @Summary 获取指定聊天的索引信息 @Description 根据聊天ID获取该聊天的索引详细信息 @Tags Chat @Accept json @Produce json @Security ApiKeyAuth @Param chat_id path int true "聊天ID" @Success 200 {object} map[string]interface{} "成功响应" @Success 200 {object} object{status=string,index=database.IndexChat} "成功响应示例" @Failure 400 {object} map[string]string "聊天ID是必需的" @Failure 401 {object} map[string]string "未授权" @Failure 404 {object} map[string]string "未找到指定聊天的索引" @Failure 500 {object} map[string]string "服务器内部错误" @Router /index/{chat_id} [get]

func GetIndexed added in v0.8.0

func GetIndexed(c *fiber.Ctx) error

GetIndexed 获取所有已索引的聊天 @Summary 获取所有已索引的聊天 @Description 获取系统中所有已索引的聊天列表 @Tags Chat @Accept json @Produce json @Security ApiKeyAuth @Success 200 {object} map[string]interface{} "成功响应" @Success 200 {object} object{status=string,chats=[]database.IndexChat} "成功响应示例" @Failure 401 {object} map[string]string "未授权" @Failure 404 {object} map[string]string "未找到已索引的聊天" @Failure 500 {object} map[string]string "服务器内部错误" @Router /indexed [get]

func ReplyMessage added in v0.10.0

func ReplyMessage(c *fiber.Ctx) error

ReplyMessage 回复指定消息 @Summary 回复指定消息 @Description 向指定聊天中的指定消息发送回复 @Tags Client @Accept json @Produce json @Security ApiKeyAuth @Param request body ReplyMessageRequest true "回复消息请求参数" @Success 200 {object} map[string]interface{} "成功响应" @Success 200 {object} object{status=string,message=string,data=object} "成功响应示例" @Failure 400 {object} map[string]string "请求参数错误" @Failure 401 {object} map[string]string "未授权" @Failure 500 {object} map[string]string "服务器内部错误" @Router /client/reply [post]

func ResponseSearch added in v0.10.0

func ResponseSearch(c *fiber.Ctx, rawResp *types.MessageSearchResponse) error

func SearchOnChatByGet added in v0.8.0

func SearchOnChatByGet(c *fiber.Ctx) error

SearchOnChatByGet 使用GET方法在指定聊天中搜索消息 @Summary 在指定聊天中搜索消息 (GET方法) @Description 使用GET方法在指定聊天中搜索消息,支持分页和过滤 @Tags Search @Accept json @Produce json @Security ApiKeyAuth @Param chat_id path int true "聊天ID" @Param q query string true "搜索查询字符串" @Param offset query int false "偏移量,默认为0" default(0) @Param limit query int false "限制数量,默认为10" default(10) @Param users query string false "用户ID列表,逗号分隔" example("123456,789012") @Param types query string false "消息类型列表,逗号分隔" example("text,photo,video") Enums(text,photo,video,document,voice,audio,poll,story) @Success 200 {object} map[string]interface{} "成功响应" @Success 200 {object} object{status=string,results=SearchResponse} "成功响应示例" @Failure 400 {object} map[string]string "请求参数错误" @Failure 401 {object} map[string]string "未授权" @Failure 500 {object} map[string]string "服务器内部错误" @Router /index/{chat_id}/search [get]

func SearchOnChatByPost added in v0.8.0

func SearchOnChatByPost(c *fiber.Ctx) error

SearchOnChatByPost 使用POST方法在指定聊天中搜索消息 @Summary 在指定聊天中搜索消息 (POST方法) @Description 使用POST方法在指定聊天中搜索消息,支持更复杂的搜索参数 @Tags Search @Accept json @Produce json @Security ApiKeyAuth @Param chat_id path int true "聊天ID" @Param request body SearchOnChatByPostRequest true "搜索请求参数" @Success 200 {object} map[string]interface{} "成功响应" @Success 200 {object} object{status=string,results=SearchResponse} "成功响应示例" @Failure 400 {object} map[string]string "请求参数错误" @Failure 401 {object} map[string]string "未授权" @Failure 500 {object} map[string]string "服务器内部错误" @Router /index/{chat_id}/search [post]

func SearchOnMultiChatByPost added in v0.8.0

func SearchOnMultiChatByPost(c *fiber.Ctx) error

SearchOnMultiChatByPost 在多个聊天中搜索消息 @Summary 在多个聊天中搜索消息 @Description 在指定的多个聊天中搜索消息,如果未指定聊天ID则搜索所有聊天 @Tags Search @Accept json @Produce json @Security ApiKeyAuth @Param request body SearchOnMultiChatByPostRequest true "多聊天搜索请求参数" @Success 200 {object} map[string]interface{} "成功响应" @Success 200 {object} object{status=string,results=SearchResponse} "成功响应示例" @Failure 400 {object} map[string]string "请求参数错误" @Failure 401 {object} map[string]string "未授权" @Failure 500 {object} map[string]string "服务器内部错误" @Router /index/multi-search [post]

func Serve

func Serve(addr string)

@title BTTS API @version 1.0 @description Better Telegram Search API @BasePath /api @securityDefinitions.apikey ApiKeyAuth @in header @name Authorization @description Type "Bearer" followed by a space and JWT token.

Types

type ReplyMessageRequest added in v0.10.0

type ReplyMessageRequest struct {
	ChatID    int64  `json:"chat_id" validate:"required" example:"123456789"`            // 聊天ID
	MessageID int    `json:"message_id" validate:"required" example:"987654321"`         // 消息ID
	Text      string `json:"text" validate:"required" example:"This is a reply message"` // 回复内容
}

type SearchHit added in v0.10.0

type SearchHit struct {
	ID           int64  `json:"id"` // Telegram MessageID
	Type         string `json:"type"`
	Message      string `json:"message"`                  // The original text of the message
	UserID       int64  `json:"user_id"`                  // The ID of the user who sent the message
	ChatID       int64  `json:"chat_id"`                  // The ID of the chat where the message was sent
	UserFullName string `json:"user_full_name,omitempty"` // The full name of the user who sent the message, if available
	ChatTitle    string `json:"chat_title,omitempty"`     // The title of the chat, if available
	Timestamp    int64  `json:"timestamp"`
	Formatted    struct {
		ID        string `json:"id"`
		Type      string `json:"type"`
		Message   string `json:"message"`
		UserID    string `json:"user_id"`
		ChatID    string `json:"chat_id"`
		Timestamp string `json:"timestamp"`
	} `json:"_formatted"`
}

type SearchOnChatByPostRequest added in v0.8.0

type SearchOnChatByPostRequest struct {
	Query  string   `json:"query" validate:"required" example:"search text"` // 搜索查询字符串
	Offset int64    `json:"offset" default:"0" example:"0"`                  // 偏移量,用于分页
	Limit  int64    `json:"limit" default:"10" example:"10"`                 // 限制数量,用于分页
	Users  []int64  `json:"users,omitempty" example:"123456,789012"`         // 用户ID过滤列表,可选
	Types  []string `json:"types,omitempty" example:"text,photo"`            // 消息类型过滤列表,可选值:text,photo,video,document,voice,audio,poll,story
}

SearchOnChatByPostRequest 单聊天搜索请求

type SearchOnMultiChatByPostRequest added in v0.8.0

type SearchOnMultiChatByPostRequest struct {
	ChatIDs []int64  `json:"chat_ids" example:"777000,114514"`                // 聊天ID列表,如果为空则搜索所有聊天
	Query   string   `json:"query" validate:"required" example:"search text"` // 搜索查询字符串
	Offset  int64    `json:"offset" default:"0" example:"0"`                  // 偏移量,用于分页
	Limit   int64    `json:"limit" default:"10" example:"10"`                 // 限制数量,用于分页
	Users   []int64  `json:"users,omitempty" example:"123456,789012"`         // 用户ID过滤列表,可选
	Types   []string `json:"types,omitempty" example:"text,photo"`            // 消息类型过滤列表,可选值:text,photo,video,document,voice,audio,poll,story
}

SearchOnMultiChatByPostRequest 多聊天搜索请求

type SearchResponse added in v0.10.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"`
}

Directories

Path Synopsis
Package docs Code generated by swaggo/swag.
Package docs Code generated by swaggo/swag.

Jump to

Keyboard shortcuts

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