handlers

package
v0.0.0-...-8228301 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BotID string

Functions

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 FindImageUrlInReply

func FindImageUrlInReply(reply *Card) string

func GetGroupList

func GetGroupList(client callapi.Client, Token string, BaseUrl string, message callapi.ActionMessage) (string, error)

func GetGroupMemberInfo

func GetGroupMemberInfo(client callapi.Client, Token string, BaseUrl string, message callapi.ActionMessage) (string, error)

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

func GetGuildServiceProfile

func GetGuildServiceProfile(client callapi.Client, Token string, BaseUrl string, message callapi.ActionMessage) (string, error)

func GetLoginInfo

func GetLoginInfo(client callapi.Client, Token string, BaseUrl string, 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, Token string, BaseUrl string, message callapi.ActionMessage) (string, error)

func GetStatus

func GetStatus(client callapi.Client, Token string, BaseUrl string, message callapi.ActionMessage) (string, error)

func GetVersionInfo

func GetVersionInfo(client callapi.Client, Token string, BaseUrl string, message callapi.ActionMessage) (string, error)

func HandleGetFriendList

func HandleGetFriendList(client callapi.Client, Token string, BaseUrl string, message callapi.ActionMessage) (string, error)

func HandleSendGroupForwardMsg

func HandleSendGroupForwardMsg(client callapi.Client, Token string, BaseUrl string, message callapi.ActionMessage) (string, error)

func HandleSendGroupMsg

func HandleSendGroupMsg(client callapi.Client, Token string, BaseUrl string, message callapi.ActionMessage) (string, error)

func HandleSendGuildChannelMsg

func HandleSendGuildChannelMsg(client callapi.Client, Token string, BaseUrl string, message callapi.ActionMessage) (string, error)

func HandleSendGuildChannelPrivateMsg

func HandleSendGuildChannelPrivateMsg(client callapi.Client, Token string, BaseUrl string, message callapi.ActionMessage, optionalGuildID *string, optionalChannelID *string) (string, error)

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

func HandleSendMsg

func HandleSendMsg(client callapi.Client, Token string, BaseUrl string, message callapi.ActionMessage) (string, error)

func HandleSendPrivateMsg

func HandleSendPrivateMsg(client callapi.Client, Token string, BaseUrl string, message callapi.ActionMessage) (string, error)

func Handle_quick_operation

func Handle_quick_operation(client callapi.Client, Token string, BaseUrl string, message callapi.ActionMessage) (string, error)

func MarkThisMessageAsRead

func MarkThisMessageAsRead(client callapi.Client, Token string, BaseUrl string, message callapi.ActionMessage) (string, error)

func RevertTransformedText

func RevertTransformedText(data interface{}, msgtype string, Token string, BaseUrl string, vgid int64, vuid int64, whitenable bool) string

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

func SendMessage

func SendMessage(messageText string, data interface{}, messageType string, Token string, BaseUrl string) error

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

func SendResponse

func SendResponse(client callapi.Client, err error, message *callapi.ActionMessage) (string, error)

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

func SetGroupBan

func SetGroupBan(client callapi.Client, Token string, BaseUrl string, message callapi.ActionMessage) (string, error)

func SetGroupWholeBan

func SetGroupWholeBan(client callapi.Client, Token string, BaseUrl string, message callapi.ActionMessage) (string, error)

Types

type APIOutput

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

type Card

type Card struct {
	Type    string   `json:"type"`
	Theme   string   `json:"theme"`
	Size    string   `json:"size"`
	Modules []Module `json:"modules"`
}

type ChannelData

type ChannelData struct {
	ID   string
	Name string
	Type int
}

ChannelData 结构体用于存储频道信息

func FetchChannels

func FetchChannels(api *helper.ApiHelper, guildID string) ([]ChannelData, error)

FetchChannels 用于获取子频道列表

type Element

type Element struct {
	Type string `json:"type"`
	Src  string `json:"src,omitempty"`
	Text *Text  `json:"text,omitempty"`
}

type FriendData

type FriendData struct {
	Nickname string `json:"nickname"`
	Remark   string `json:"remark"`
	UserID   string `json:"user_id"`
}

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 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 {
	ID               string
	Name             string
	Topic            string
	UserID           string
	Icon             string
	NotifyType       int
	Region           string
	EnableOpen       bool
	OpenID           string
	DefaultChannelID string
	WelcomeChannelID string
	BoostNum         int
	Level            int
}

func FetchGuilds

func FetchGuilds(api *helper.ApiHelper) ([]GuildData, error)

FetchGuilds 用于获取当前用户加入的服务器列表

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 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         int64  `json:"group_id"`
	UserID          int64  `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 Module

type Module struct {
	Type     string    `json:"type"`
	Elements []Element `json:"elements,omitempty"`
	Text     *Text     `json:"text,omitempty"`
}

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"`
	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 uint64 `json:"message_received"`
	MessageSent     uint64 `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 Text

type Text struct {
	Type    string `json:"type"`
	Content string `json:"content"`
}

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