api

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2026 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CallClientExtension added in v0.14.0

func CallClientExtension(c fiber.Ctx) error

CallClientExtension 调用用户客户端扩展API

@Summary		调用用户客户端扩展API
@Description	调用用户客户端扩展API
@Tags			Client
@Accept			json
@Produce		json
@Security		ApiKeyAuth
@Param			exten		path	string	true	"扩展名"
@Param			input		body	map[string]any	true	"扩展API请求参数"
@Success		200			{object}	map[string]any	"成功响应"
@Failure		400			{object}	map[string]string	"请求参数错误"
@Failure		401			{object}	map[string]string	"未授权"
@Failure		500			{object}	map[string]string	"服务器内部错误"
@Router			/client/callexten/{exten} [post]

func FetchMessages added in v0.14.0

func FetchMessages(c fiber.Ctx) error

FetchMessages 从索引中获取指定消息

@Summary		从索引中获取指定消息
@Description	根据消息ID列表从索引中获取消息内容
@Tags			Chat
@Accept			json
@Produce		json
@Security		ApiKeyAuth
@Param			chat_id	path		int												true	"聊天ID"
@Param			request	body		FetchMessagesRequest								true	"请求参数"
@Success		200		{object}	map[string]interface{}							"成功响应"
@Success		200		{object}	object{status=string,messages=[]types.SearchHit}	"成功响应示例"
@Failure		400		{object}	map[string]string								"请求参数错误"
@Failure		401		{object}	map[string]string								"未授权"
@Failure		404		{object}	map[string]string								"未找到指定聊天的索引"
@Failure		500		{object}	map[string]string								"服务器内部错误"
@Router			/index/{chat_id}/msgs/fetch [post]

func ForwardMessages added in v0.11.0

func ForwardMessages(c fiber.Ctx) error

ForwardMessages 转发消息

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

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 ResponseDocuments added in v0.18.0

func ResponseDocuments(c fiber.Ctx, docs []*types.MessageDocument) error

func ResponseSearch added in v0.10.0

func ResponseSearch(c fiber.Ctx, rawResp *types.SearchResponse) 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.

func StreamFile added in v0.12.0

func StreamFile(c fiber.Ctx) error

StreamFile 获取文件流

@Description	获取指定聊天中指定消息的文件流
@Tags			Client
@Accept			json
@Produce		json
@Security		ApiKeyAuth
@Param			chat_id		query	int64	true	"聊天ID"
@Param			message_id	query	int	true	"消息ID"
@Success		200			{file}	file	"文件流"
@Failure		400			{object}	map[string]string	"请求参数错误"
@Failure		401			{object}	map[string]string	"未授权"
@Failure		500			{object}	map[string]string	"服务器内部错误"
@Router			/client/filestream [get]

Types

type FetchMessagesRequest added in v0.14.0

type FetchMessagesRequest struct {
	IDs []int `json:"ids" validate:"required" example:"123456789,987654321"` // 消息ID列表
}

type ForwardMessagesRequest added in v0.11.0

type ForwardMessagesRequest struct {
	FromChatID int64 `json:"from_chat_id" validate:"required" example:"123456789"`  // 来源聊天ID
	ToChatID   int64 `json:"to_chat_id" validate:"required" example:"987654321"`    // 目标聊天ID
	MessageIDs []int `json:"message_ids" validate:"required" example:"123,456,789"` // 消息ID列表
}

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 SearchHitResponse added in v1.0.0

type SearchHitResponse struct {
	ID                int64                    `json:"id"` // Telegram MessageID
	Type              string                   `json:"type"`
	FullText          string                   `json:"full_text"`
	FullFormattedText string                   `json:"full_formatted_text,omitempty"`
	Message           string                   `json:"message"`                  // The original text of the message
	Ocred             string                   `json:"ocred"`                    // The OCRed text of the message
	AIGenerated       string                   `json:"aigenerated"`              // The AI generated 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         types.SearchHitFormatted `json:"_formatted"`
}

type SearchOnChatByPostRequest added in v0.8.0

type SearchOnChatByPostRequest struct {
	Query             string   `json:"query" 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
	DisableOcred      bool     `json:"disable_ocred,omitempty" example:"false"`      // 是否禁用OCR文本
	EnableAIGenerated bool     `json:"enable_aigenerated,omitempty" example:"false"` // 是否启用AI生成的文本
}

SearchOnChatByPostRequest 单聊天搜索请求

type SearchOnMultiChatByPostRequest added in v0.8.0

type SearchOnMultiChatByPostRequest struct {
	AllChats          bool     `json:"all_chats,omitempty" example:"false"`          // 是否搜索所有聊天
	ChatIDs           []int64  `json:"chat_ids" example:"777000,114514"`             // 聊天ID列表
	Query             string   `json:"query" 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
	DisableOcred      bool     `json:"disable_ocred,omitempty" example:"false"`      // 是否禁用OCR文本
	EnableAIGenerated bool     `json:"enable_aigenerated,omitempty" example:"false"` // 是否启用AI生成的文本
}

SearchOnMultiChatByPostRequest 多聊天搜索请求

type SearchResponse added in v0.10.0

type SearchResponse struct {
	Hits               []SearchHitResponse `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"`
}

type StreamFileRequest added in v0.12.0

type StreamFileRequest struct {
	ChatID    int64 `json:"chat_id" validate:"required" example:"123456789"`    // 聊天ID
	MessageID int   `json:"message_id" validate:"required" example:"987654321"` // 消息ID
}

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