handlers

package
v0.0.0-...-c7e21b0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: GPL-3.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AppID string
View Source
var BotID string

Functions

func BuildQQBotShareLink(uin string, appid string) string

构建QQ群机器人分享链接的函数

func BuildQQBotShareLinkGuild

func BuildQQBotShareLinkGuild(uin string, appid string) string

构建QQ群机器人分享链接的函数

func ConvertMapToJSONString

func ConvertMapToJSONString(m map[string]interface{}) (string, error)

将map转化为json string

func ConvertToInt64

func ConvertToInt64(value interface{}) (int64, error)

ConvertToInt64 尝试将 interface{} 类型的值转换为 int64 类型

func ConvertToSegmentedMessage

func ConvertToSegmentedMessage(data interface{}) []map[string]interface{}

将收到的data.content转换为message segment todo,群场景不支持受图片,频道场景的图片可以拼一下

func CreateSendGroupMsgAction

func CreateSendGroupMsgAction(originalMsg callapi.ActionMessage) *callapi.ActionMessage

func DeleteMsg

func DeleteMsg(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.OpenAPI, message callapi.ActionMessage) (string, error)

func FetchSongDetail

func FetchSongDetail(songID string) (string, error)

FetchSongDetail 发送请求到QQ音乐API并获取歌曲详情

func FetchTrackInfo

func FetchTrackInfo(trackMid string) (string, error)

FetchTrackInfo 用于根据trackMid获取QQ音乐的track信息

func GenerateForumMessage

func GenerateForumMessage(foundItems map[string][]string, messageText string, apiv2 openapi.OpenAPI) (*dto.FourmToCreate, error)

GenerateForumMessage 生成帖子消息

func GenerateReplyMessage

func GenerateReplyMessage(id string, foundItems map[string][]string, messageText string, msgseq int) (*dto.MessageToCreate, bool)

组合发频道信息需要的MessageToCreate 支持base64

func GetGroupList

func GetGroupList(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.OpenAPI, message callapi.ActionMessage) (string, error)

func GetGroupMemberInfo

func GetGroupMemberInfo(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.OpenAPI, message callapi.ActionMessage) (string, error)

getGroupMemberInfo是处理获取群成员信息的函数

func GetGroupMemberList

func GetGroupMemberList(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.OpenAPI, message callapi.ActionMessage) (string, error)

func GetGuildChannelList

func GetGuildChannelList(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.OpenAPI, message callapi.ActionMessage) (string, error)

func GetGuildList

func GetGuildList(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.OpenAPI, message callapi.ActionMessage) (string, error)

func GetGuildServiceProfile

func GetGuildServiceProfile(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.OpenAPI, message callapi.ActionMessage) (string, error)

func GetLoginInfo

func GetLoginInfo(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.OpenAPI, message callapi.ActionMessage) (string, error)

func GetMessageIDByUseridAndGroupid

func GetMessageIDByUseridAndGroupid(appID string, userID interface{}, groupID interface{}) string

通过user_id获取messageID

func GetMessageIDByUseridOrGroupid

func GetMessageIDByUseridOrGroupid(appID string, userID interface{}) string

通过user_id获取messageID

func GetMessageTypeByGroupid

func GetMessageTypeByGroupid(appID string, GroupID interface{}) string

通过group_id获取类型

func GetMessageTypeByGroupidV2

func GetMessageTypeByGroupidV2(GroupID interface{}) string

通过group_id获取类型

func GetMessageTypeByUserid

func GetMessageTypeByUserid(appID string, userID interface{}) string

通过user_id获取类型

func GetMessageTypeByUseridV2

func GetMessageTypeByUseridV2(userID interface{}) string

通过user_id获取类型

func GetOnlineClients

func GetOnlineClients(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.OpenAPI, message callapi.ActionMessage) (string, error)

func GetRelatedID

func GetRelatedID(MessageID string) string

GetRelatedID 根据MessageID获取相关的ID

func GetStatus

func GetStatus(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.OpenAPI, message callapi.ActionMessage) (string, error)

func GetVersionInfo

func GetVersionInfo(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.OpenAPI, message callapi.ActionMessage) (string, error)

func HandleGetFriendList

func HandleGetFriendList(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.OpenAPI, message callapi.ActionMessage) (string, error)

func HandleGetGroupInfo

func HandleGetGroupInfo(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.OpenAPI, message callapi.ActionMessage) (string, error)

func HandlePutInteraction

func HandlePutInteraction(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.OpenAPI, message callapi.ActionMessage) (string, error)

func HandleSendGroupForwardMsg

func HandleSendGroupForwardMsg(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.OpenAPI, message callapi.ActionMessage) (string, error)

func HandleSendGroupMsg

func HandleSendGroupMsg(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.OpenAPI, message callapi.ActionMessage) (string, error)

func HandleSendGroupMsgRaw

func HandleSendGroupMsgRaw(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.OpenAPI, message callapi.ActionMessage) (string, error)

func HandleSendGuildChannelForum

func HandleSendGuildChannelForum(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.OpenAPI, message callapi.ActionMessage) (string, error)

func HandleSendGuildChannelMsg

func HandleSendGuildChannelMsg(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.OpenAPI, message callapi.ActionMessage) (string, error)

func HandleSendGuildChannelPrivateMsg

func HandleSendGuildChannelPrivateMsg(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.OpenAPI, message callapi.ActionMessage, optionalGuildID *string, optionalChannelID *string) (string, error)

处理频道私信 最后2个指针参数可空 代表使用userid倒推

func HandleSendMsg

func HandleSendMsg(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.OpenAPI, message callapi.ActionMessage) (string, error)

func HandleSendPrivateMsg

func HandleSendPrivateMsg(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.OpenAPI, message callapi.ActionMessage) (string, error)

func HandleSendPrivateMsgSSE

func HandleSendPrivateMsgSSE(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.OpenAPI, message callapi.ActionMessage) (string, error)

func Handle_quick_operation

func Handle_quick_operation(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.OpenAPI, message callapi.ActionMessage) (string, error)

func MarkThisMessageAsRead

func MarkThisMessageAsRead(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.OpenAPI, message callapi.ActionMessage) (string, error)

func ProcessGuildAndChannels

func ProcessGuildAndChannels(guild *dto.Guild, api openapi.OpenAPI, groupListData *[]Group)

ProcessGuildAndChannels 处理单个guild及其channels,并将结果添加到groupList.Data

func QQMusicSongInfo

func QQMusicSongInfo(id string) (gjson.Result, error)

QQMusicSongInfo 通过给定id在QQ音乐上查找曲目信息

func RevertTransformedText

func RevertTransformedText(data interface{}, msgtype string, api openapi.OpenAPI, apiv2 openapi.OpenAPI, vgid int64, vuid int64, whitenable bool) string

处理at和其他定形文到onebotv11格式(cq码)

func SendC2CResponse

func SendC2CResponse(client callapi.Client, err error, message *callapi.ActionMessage, resp *dto.C2CMessageResponse) (string, error)

发送成功回执 todo 返回可互转的messageid 实现C2C撤回api

func SendGuildPrivateResponse

func SendGuildPrivateResponse(client callapi.Client, err error, message *callapi.ActionMessage, resp *dto.Message, guildID string) (string, error)

会返回guildid的频道私信专用SendGuildPrivateResponse

func SendGuildResponse

func SendGuildResponse(client callapi.Client, err error, message *callapi.ActionMessage, resp *dto.Message) (string, error)

发送成功回执 todo 返回可互转的messageid 实现频道撤回api

func SendMessage

func SendMessage(messageText string, data interface{}, messageType string, api openapi.OpenAPI, apiv2 openapi.OpenAPI) error

SendMessage 发送消息根据不同的类型

func SendResponse

func SendResponse(client callapi.Client, err error, message *callapi.ActionMessage, resp *dto.GroupMessageResponse, api openapi.OpenAPI, apiv2 openapi.OpenAPI) (string, error)

发送成功回执 todo 返回可互转的messageid 实现群撤回api

func SendStackMessages

func SendStackMessages(apiv2 openapi.OpenAPI, messageid string, GroupID string)

发送栈中的消息

func SetGroupBan

func SetGroupBan(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.OpenAPI, message callapi.ActionMessage) (string, error)

func SetGroupWholeBan

func SetGroupWholeBan(client callapi.Client, api openapi.OpenAPI, apiv2 openapi.OpenAPI, message callapi.ActionMessage) (string, error)

func UpdateRelatedID

func UpdateRelatedID(MessageID, ID string)

UpdateRelatedID 更新MessageID到respID的映射关系

Types

type APIOutput

type APIOutput struct {
	Data    []structs.FriendData `json:"data"`
	Message string               `json:"message"`
	RetCode int                  `json:"retcode"`
	Status  string               `json:"status"`
	Echo    interface{}          `json:"echo"`
}

type GetStatusResponse

type GetStatusResponse struct {
	Data    StatusData  `json:"data"`
	Message string      `json:"message"`
	RetCode int         `json:"retcode"`
	Status  string      `json:"status"`
	Echo    interface{} `json:"echo"`
}

type Group

type Group struct {
	GroupCreateTime int32  `json:"group_create_time"`
	GroupID         int64  `json:"group_id"`
	GroupLevel      int32  `json:"group_level"`
	GroupMemo       string `json:"group_memo"`
	GroupName       string `json:"group_name"`
	MaxMemberCount  int32  `json:"max_member_count"`
	MemberCount     int32  `json:"member_count"`
}

type GroupInfo

type GroupInfo struct {
	GroupID         int64  `json:"group_id"`
	GroupName       string `json:"group_name"`
	GroupMemo       string `json:"group_memo"`
	GroupCreateTime int32  `json:"group_create_time"`
	GroupLevel      int32  `json:"group_level"`
	MemberCount     int32  `json:"member_count"`
	MaxMemberCount  int32  `json:"max_member_count"`
}

type GroupList

type GroupList struct {
	Data    []Group     `json:"data"`
	Message string      `json:"message"`
	RetCode int         `json:"retcode"`
	Status  string      `json:"status"`
	Echo    interface{} `json:"echo"`
}

type Guild

type Guild struct {
	JoinedAt    string `json:"joined_at"`
	ID          string `json:"id"`
	OwnerID     string `json:"owner_id"`
	Description string `json:"description"`
	Name        string `json:"name"`
	MaxMembers  string `json:"max_members"`
	MemberCount string `json:"member_count"`
}

type GuildChannelListResponse

type GuildChannelListResponse struct {
	Data    []interface{} `json:"data"`
	Message string        `json:"message"`
	RetCode int           `json:"retcode"`
	Status  string        `json:"status"`
	Echo    interface{}   `json:"echo"`
}

type GuildData

type GuildData struct {
	GuildID        string `json:"guild_id"`
	GuildName      string `json:"guild_name"`
	GuildDisplayID string `json:"guild_display_id"`
}

type GuildListResponse

type GuildListResponse struct {
	Data    []GuildData `json:"data"`
	Message string      `json:"message"`
	RetCode int         `json:"retcode"`
	Status  string      `json:"status"`
	Echo    interface{} `json:"echo"`
}

type GuildServiceProfileData

type GuildServiceProfileData struct {
	Nickname string `json:"nickname"`
	TinyID   int64  `json:"tiny_id"`
}

type GuildServiceProfileResponse

type GuildServiceProfileResponse struct {
	Data    GuildServiceProfileData `json:"data"`
	Message string                  `json:"message"`
	RetCode int                     `json:"retcode"`
	Status  string                  `json:"status"`
	Echo    interface{}             `json:"echo"`
}

type HttpAPIClient

type HttpAPIClient struct {
}

定义了一个符合 Client 接口的 HttpAPIClient 结构体

func (*HttpAPIClient) SendMessage

func (c *HttpAPIClient) SendMessage(message map[string]interface{}) error

实现 Client 接口的 SendMessage 方法 假client中不执行任何操作,只是返回 nil 来符合接口要求

type InteractionResponse

type InteractionResponse struct {
	Data    string      `json:"data"`
	Message string      `json:"message"`
	RetCode int         `json:"retcode"`
	Status  string      `json:"status"`
	Echo    interface{} `json:"echo"`
}

type InterfaceBody

type InterfaceBody struct {
	Content        string   `json:"content"`
	State          int      `json:"state"`
	PromptKeyboard []string `json:"prompt_keyboard,omitempty"`
	ActionButton   int      `json:"action_button,omitempty"`
	CallbackData   string   `json:"callback_data,omitempty"`
}

type LoginInfoData

type LoginInfoData struct {
	Nickname string `json:"nickname"`
	UserID   string `json:"user_id"` // Assuming UserID is a string type based on the pseudocode
}

type LoginInfoResponse

type LoginInfoResponse struct {
	Data    LoginInfoData `json:"data"`
	Message string        `json:"message"`
	RetCode int           `json:"retcode"`
	Status  string        `json:"status"`
	Echo    interface{}   `json:"echo"`
}

type MarkThisMessageAsReadAPIResponse

type MarkThisMessageAsReadAPIResponse struct {
	Status  string       `json:"status"`
	Data    gjson.Result `json:"data"`
	Msg     string       `json:"msg"`
	Wording string       `json:"wording"`
	RetCode int64        `json:"retcode"`
	Echo    interface{}  `json:"echo"`
}

type MemberInfo

type MemberInfo struct {
	UserID          int64  `json:"user_id"`
	GroupID         int64  `json:"group_id"`
	Nickname        string `json:"nickname"`
	Card            string `json:"card"`
	Sex             string `json:"sex"`
	Age             int32  `json:"age"`
	Area            string `json:"area"`
	JoinTime        int32  `json:"join_time"`
	LastSentTime    int32  `json:"last_sent_time"`
	Level           string `json:"level"`
	Role            string `json:"role"`
	Unfriendly      bool   `json:"unfriendly"`
	Title           string `json:"title"`
	TitleExpireTime int64  `json:"title_expire_time"`
	CardChangeable  bool   `json:"card_changeable"`
	ShutUpTimestamp int64  `json:"shut_up_timestamp"`
}

成员信息的结构定义

type MemberList

type MemberList struct {
	GroupID         uint64 `json:"group_id"`
	UserID          uint64 `json:"user_id"`
	Nickname        string `json:"nickname"`
	Card            string `json:"card"`
	Sex             string `json:"sex"`
	Age             int32  `json:"age"`
	Area            string `json:"area"`
	JoinTime        int32  `json:"join_time"`
	LastSentTime    int32  `json:"last_sent_time"`
	Level           string `json:"level"`
	Role            string `json:"role"`
	Unfriendly      bool   `json:"unfriendly"`
	Title           string `json:"title"`
	TitleExpireTime int64  `json:"title_expire_time"`
	CardChangeable  bool   `json:"card_changeable"`
	ShutUpTimestamp int64  `json:"shut_up_timestamp"`
}

Member Onebot 群成员

type OnebotGroupInfo

type OnebotGroupInfo struct {
	Data    GroupInfo   `json:"data"`
	Message string      `json:"message"`
	RetCode int         `json:"retcode"`
	Status  string      `json:"status"`
	Echo    interface{} `json:"echo"`
}

func ConvertGuildToGroupInfo

func ConvertGuildToGroupInfo(guild *dto.Guild, GroupId string, message callapi.ActionMessage) *OnebotGroupInfo

type OnlineClientsData

type OnlineClientsData struct {
	Clients []interface{} `json:"clients"` // It seems you want an empty array for clients
	TinyID  int64         `json:"tiny_id"`
}

type OnlineClientsResponse

type OnlineClientsResponse struct {
	Data    OnlineClientsData `json:"data"`
	Message string            `json:"message"`
	RetCode int               `json:"retcode"`
	Status  string            `json:"status"`
	Echo    interface{}       `json:"echo"`
}

type Response

type Response struct {
	Retcode int          `json:"retcode"`
	Status  string       `json:"status"`
	Data    []MemberList `json:"data"`
	Echo    interface{}  `json:"echo"` // 使用 interface{} 类型以容纳整数或文本
}

type ServerResponse

type ServerResponse struct {
	Data struct {
		MessageID int `json:"message_id"`
	} `json:"data"`
	Message   string      `json:"message"`
	GroupID   int64       `json:"group_id,omitempty"`
	UserID    int64       `json:"user_id,omitempty"`
	ChannelID int64       `json:"channel_id,omitempty"`
	GuildID   string      `json:"guild_id,omitempty"`
	RetCode   int         `json:"retcode"`
	Status    string      `json:"status"`
	Echo      interface{} `json:"echo"`
}

定义响应结构体

type Statistics

type Statistics struct {
	PacketReceived  uint64 `json:"packet_received"`
	PacketSent      uint64 `json:"packet_sent"`
	PacketLost      uint32 `json:"packet_lost"`
	MessageReceived int    `json:"message_received"`
	MessageSent     int    `json:"message_sent"`
	DisconnectTimes uint32 `json:"disconnect_times"`
	LostTimes       uint32 `json:"lost_times"`
	LastMessageTime int64  `json:"last_message_time"`
}

type StatusData

type StatusData struct {
	AppInitialized bool       `json:"app_initialized"`
	AppEnabled     bool       `json:"app_enabled"`
	PluginsGood    bool       `json:"plugins_good"`
	AppGood        bool       `json:"app_good"`
	Online         bool       `json:"online"`
	Good           bool       `json:"good"`
	Stat           Statistics `json:"stat"`
}

type VersionData

type VersionData struct {
	AppFullName              string `json:"app_full_name"`
	AppName                  string `json:"app_name"`
	AppVersion               string `json:"app_version"`
	CoolQDirectory           string `json:"coolq_directory"`
	CoolQEdition             string `json:"coolq_edition"`
	GoCQHTTP                 bool   `json:"go-cqhttp"`
	PluginBuildConfiguration string `json:"plugin_build_configuration"`
	PluginBuildNumber        int    `json:"plugin_build_number"`
	PluginVersion            string `json:"plugin_version"`
	ProtocolName             int    `json:"protocol_name"`
	ProtocolVersion          string `json:"protocol_version"`
	RuntimeOS                string `json:"runtime_os"`
	RuntimeVersion           string `json:"runtime_version"`
	Version                  string `json:"version"`
}

type VersionInfoResponse

type VersionInfoResponse struct {
	Data    VersionData `json:"data"`
	Message string      `json:"message"`
	RetCode int         `json:"retcode"`
	Status  string      `json:"status"`
	Echo    interface{} `json:"echo"`
}

Jump to

Keyboard shortcuts

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