bot

package
v0.0.0-...-e5dc0fd Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: AGPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const MAX_TEXT_LENGTH = 80

Variables

This section is empty.

Functions

func ConnectUniversal

func ConnectUniversal(cli *client.QQClient)

func EmptyText

func EmptyText() *message.TextElement

func ForwrdSendMsg

func ForwrdSendMsg(cli *client.QQClient, f *onebot.Frame)

func GetCSRFToken

func GetCSRFToken(c *client.QQClient) int

func GetCookiesWithDomain

func GetCookiesWithDomain(c *client.QQClient, domain string) string

func HandleDeletMsg

func HandleDeletMsg(cli *client.QQClient, req *onebot.DeleteMsgReq) *onebot.DeleteMsgResp

func HandleEventFrame

func HandleEventFrame(cli *client.QQClient, eventFrame *onebot.Frame)

func HandleGetCookies

func HandleGetCookies(cli *client.QQClient, req *onebot.GetCookiesReq) *onebot.GetCookiesResp

func HandleGetMsg

func HandleGetMsg(cli *client.QQClient, req *onebot.GetMsgReq) *onebot.GetMsgResp

func HandleImageOcr

func HandleImageOcr(cli *client.QQClient)

func HandleSendMsg

func HandleSendMsg(cli *client.QQClient, req *onebot.SendMsgReq) *onebot.SendMsgResp

func HandleSetGroupAddRequest

func HandleSetGroupAddRequest(cli *client.QQClient, req *onebot.SetGroupAddRequestReq) *onebot.SetGroupAddRequestResp

accept bool, sequence uint64, typ uint32, groupUin uint32, message string

func HandleSetGroupBan

func HandleSetGroupBan(cli *client.QQClient, req *onebot.SetGroupBanReq) *onebot.SetGroupBanResp

func IsClientExist

func IsClientExist(uin int64) bool

func MiraiAtToProtoAt

func MiraiAtToProtoAt(elem *message.AtElement) *onebot.Message

func MiraiFaceToProtoFace

func MiraiFaceToProtoFace(elem *message.FaceElement) *onebot.Message

func MiraiForwardToProtoForward

func MiraiForwardToProtoForward(cli *client.QQClient, elem *message.ForwardMessage) *onebot.Message

func MiraiForwardToRawForward

func MiraiForwardToRawForward(cli *client.QQClient, elem *message.ForwardMessage) string

func MiraiImageToProtoImage

func MiraiImageToProtoImage(elem *message.ImageElement) *onebot.Message

func MiraiMsgToProtoMsg

func MiraiMsgToProtoMsg(cli *client.QQClient, messageChain []message.IMessageElement) []*onebot.Message

func MiraiMsgToRawMsg

func MiraiMsgToRawMsg(cli *client.QQClient, messageChain []message.IMessageElement) string

func MiraiReplyToProtoReply

func MiraiReplyToProtoReply(cli *client.QQClient, elem *message.ReplyElement) *onebot.Message

func MiraiTextToProtoText

func MiraiTextToProtoText(elem *message.TextElement) *onebot.Message

func MiraiVideoToProtoVideo

func MiraiVideoToProtoVideo(cli *client.QQClient, elem *message.ShortVideoElement) *onebot.Message

func MiraiVoiceToProtoVoice

func MiraiVoiceToProtoVoice(elem *message.VoiceElement) *onebot.Message

func OnWsRecvMessage

func OnWsRecvMessage(cli *client.QQClient, plugin *config.Plugin) func(ws *safe_ws.SafeWebSocket, messageType int, data []byte)

func ProtoAtToMiraiAt

func ProtoAtToMiraiAt(data map[string]string) message.IMessageElement

func ProtoFaceToMiraiFace

func ProtoFaceToMiraiFace(data map[string]string) message.IMessageElement

func ProtoForwardToMiraiForward

func ProtoForwardToMiraiForward(data map[string]string) *message.ForwardMessage

func ProtoImageToMiraiImage

func ProtoImageToMiraiImage(data map[string]string) message.IMessageElement

func ProtoMsgToMiraiMsg

func ProtoMsgToMiraiMsg(cli *client.QQClient, msgList []*onebot.Message, notConvertText bool) []message.IMessageElement

消息列表,不自动把code变成msg

func ProtoReplyToMiraiReply

func ProtoReplyToMiraiReply(data map[string]string) *message.ReplyElement

func ProtoSleep

func ProtoSleep(data map[string]string)

func ProtoTextToMiraiText

func ProtoTextToMiraiText(data map[string]string) message.IMessageElement

func ProtoVideoToMiraiVideo

func ProtoVideoToMiraiVideo(data map[string]string) *clz.LocalVideo

func ProtoVoiceToMiraiVoice

func ProtoVoiceToMiraiVoice(data map[string]string) message.IMessageElement

func RawMsgToMiraiMsg

func RawMsgToMiraiMsg(cli *client.QQClient, str string) []message.IMessageElement

func ReleaseClient

func ReleaseClient(cli *client.QQClient)

func UpgradeWebsocket

func UpgradeWebsocket(cli *client.QQClient, w http.ResponseWriter, r *http.Request) error

Types

type ClientMap

type ClientMap struct {
	// contains filtered or unexported fields
}

Map is like a Go map[interface{}]interface{} but is safe for concurrent use by multiple goroutines without additional locking or coordination. Loads, stores, and deletes run in amortized constant time.

The Map type is specialized. Most code should use a plain Go map instead, with separate locking or coordination, for better type safety and to make it easier to maintain other invariants along with the map content.

The Map type is optimized for two common use cases: (1) when the entry for a given key is only ever written once but read many times, as in caches that only grow, or (2) when multiple goroutines read, write, and overwrite entries for disjoint sets of keys. In these two cases, use of a Map may significantly reduce lock contention compared to a Go map paired with a separate Mutex or RWMutex.

The zero Map is empty and ready for use. A Map must not be copied after first use.

var (
	Clients ClientMap
)

func (*ClientMap) Delete

func (m *ClientMap) Delete(key int64)

Delete deletes the value for a key.

func (*ClientMap) Load

func (m *ClientMap) Load(key int64) (value *client.QQClient, ok bool)

Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.

func (*ClientMap) LoadAndDelete

func (m *ClientMap) LoadAndDelete(key int64) (value *client.QQClient, loaded bool)

LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present.

func (*ClientMap) LoadOrStore

func (m *ClientMap) LoadOrStore(key int64, value *client.QQClient) (actual *client.QQClient, loaded bool)

LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored.

func (*ClientMap) Range

func (m *ClientMap) Range(f func(key int64, value *client.QQClient) bool)

Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.

Range does not necessarily correspond to any consistent snapshot of the Map's contents: no key will be visited more than once, but if the value for any key is stored or deleted concurrently, Range may reflect any mapping for that key from any point during the Range call.

Range may be O(N) with the number of elements in the map even if f returns false after a constant number of calls.

func (*ClientMap) Store

func (m *ClientMap) Store(key int64, value *client.QQClient)

Store sets the value for a key.

type ForwardChildNode

type ForwardChildNode struct {
	Uin     int64             `json:"uin,omitempty"`
	Name    string            `json:"name,omitempty"`
	GroupId int64             `json:"group_id,omitempty"`
	Content []*onebot.Message `json:"content,omitempty"`
}

type ForwardNode

type ForwardNode struct {
	Type string            `json:"type,omitempty"`
	Data *ForwardChildNode `json:"data,omitempty"`
}

type ForwardServer

type ForwardServer struct {
	Url           string
	Session       *safe_ws.ForwardSafeWebSocket
	Mu            sync.Mutex
	WaitingFrames map[string]*promise.Promise
}

func ForwradConnect

func ForwradConnect(cli *client.QQClient, url string, conn *websocket.Conn) *ForwardServer

type GMCLogin

type GMCLogin struct {
	DeviceSeed     int64
	ClientProtocol int32
	SignServer     string
	SignServerKey  string
}

type LifeTime

type LifeTime struct {
	Time          int64  `json:"time,omitempty"`
	SelfId        int64  `json:"self_id,omitempty"`
	PostType      string `json:"post_type,omitempty"`
	MetaEventType string `json:"meta_event_type"`
	SubType       string `json:"sub_type"`
}

type Logger

type Logger struct {
}

func (*Logger) Debug

func (l *Logger) Debug(format string, args ...any)

func (*Logger) Dump

func (l *Logger) Dump(dumped []byte, format string, args ...any)

func (*Logger) Error

func (l *Logger) Error(format string, args ...any)

func (*Logger) Info

func (l *Logger) Info(format string, args ...any)

func (*Logger) Warning

func (l *Logger) Warning(format string, args ...any)

type Node

type Node struct {
	XMLName xml.Name
	Attr    []xml.Attr `xml:",any,attr"`
}

type RemoteMap

type RemoteMap struct {
	// contains filtered or unexported fields
}

Map is like a Go map[interface{}]interface{} but is safe for concurrent use by multiple goroutines without additional locking or coordination. Loads, stores, and deletes run in amortized constant time.

The Map type is specialized. Most code should use a plain Go map instead, with separate locking or coordination, for better type safety and to make it easier to maintain other invariants along with the map content.

The Map type is optimized for two common use cases: (1) when the entry for a given key is only ever written once but read many times, as in caches that only grow, or (2) when multiple goroutines read, write, and overwrite entries for disjoint sets of keys. In these two cases, use of a Map may significantly reduce lock contention compared to a Go map paired with a separate Mutex or RWMutex.

The zero Map is empty and ready for use. A Map must not be copied after first use.

var (
	// RemoteServers key是botId,value是map(key是serverName,value是server)
	RemoteServers RemoteMap

	SafeForwardMap = NewForwards()
)

func (*RemoteMap) Delete

func (m *RemoteMap) Delete(key int64)

Delete deletes the value for a key.

func (*RemoteMap) Load

func (m *RemoteMap) Load(key int64) (value map[string]*WsServer, ok bool)

Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.

func (*RemoteMap) LoadAndDelete

func (m *RemoteMap) LoadAndDelete(key int64) (value map[string]*WsServer, loaded bool)

LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present.

func (*RemoteMap) LoadOrStore

func (m *RemoteMap) LoadOrStore(key int64, value map[string]*WsServer) (actual map[string]*WsServer, loaded bool)

LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored.

func (*RemoteMap) Range

func (m *RemoteMap) Range(f func(key int64, value map[string]*WsServer) bool)

Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.

Range does not necessarily correspond to any consistent snapshot of the Map's contents: no key will be visited more than once, but if the value for any key is stored or deleted concurrently, Range may reflect any mapping for that key from any point during the Range call.

Range may be O(N) with the number of elements in the map even if f returns false after a constant number of calls.

func (*RemoteMap) Store

func (m *RemoteMap) Store(key int64, value map[string]*WsServer)

Store sets the value for a key.

type RequestCallback

type RequestCallback struct {
	Cmd        string `json:"cmd,omitempty"` // trpc.o3.ecdh_access.EcdhAccess.SsoSecureA2Establish
	Body       string `json:"body,omitempty"`
	CallBackId int    `json:"callbackId,omitempty"`
}

type RequestSignData

type RequestSignData struct {
	Token           string `json:"token,omitempty"`
	Extra           string `json:"extra,omitempty"`
	Sign            string `json:"sign,omitempty"`
	O3dId           string `json:"o3did,omitempty"`
	RequestCallback []*RequestCallback
}

type RequestSignResult

type RequestSignResult struct {
	Code int    `json:"code,omitempty"`
	Msg  string `json:"msg,omitempty"`
	Data *RequestSignData
}

type SafeForwards

type SafeForwards struct {
	Map map[string]*ForwardServer
	RW  *sync.RWMutex
}

func NewForwards

func NewForwards() *SafeForwards

func (*SafeForwards) DeleteForward

func (f *SafeForwards) DeleteForward(key string)

func (*SafeForwards) GetForward

func (f *SafeForwards) GetForward(key string) *ForwardServer

func (*SafeForwards) SetForward

func (f *SafeForwards) SetForward(key string, value *ForwardServer)

type SignRegister

type SignRegister struct {
	Uin       uint64
	AndroidId string
	Guid      string
	Qimei36   string
	Key       string
}

type TokenMap

type TokenMap struct {
	// contains filtered or unexported fields
}

Map is like a Go map[interface{}]interface{} but is safe for concurrent use by multiple goroutines without additional locking or coordination. Loads, stores, and deletes run in amortized constant time.

The Map type is specialized. Most code should use a plain Go map instead, with separate locking or coordination, for better type safety and to make it easier to maintain other invariants along with the map content.

The Map type is optimized for two common use cases: (1) when the entry for a given key is only ever written once but read many times, as in caches that only grow, or (2) when multiple goroutines read, write, and overwrite entries for disjoint sets of keys. In these two cases, use of a Map may significantly reduce lock contention compared to a Go map paired with a separate Mutex or RWMutex.

The zero Map is empty and ready for use. A Map must not be copied after first use.

func (*TokenMap) Delete

func (m *TokenMap) Delete(key int64)

Delete deletes the value for a key.

func (*TokenMap) Load

func (m *TokenMap) Load(key int64) (value []byte, ok bool)

Load returns the value stored in the map for a key, or nil if no value is present. The ok result indicates whether value was found in the map.

func (*TokenMap) LoadAndDelete

func (m *TokenMap) LoadAndDelete(key int64) (value []byte, loaded bool)

LoadAndDelete deletes the value for a key, returning the previous value if any. The loaded result reports whether the key was present.

func (*TokenMap) LoadOrStore

func (m *TokenMap) LoadOrStore(key int64, value []byte) (actual []byte, loaded bool)

LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The loaded result is true if the value was loaded, false if stored.

func (*TokenMap) Range

func (m *TokenMap) Range(f func(key int64, value []byte) bool)

Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.

Range does not necessarily correspond to any consistent snapshot of the Map's contents: no key will be visited more than once, but if the value for any key is stored or deleted concurrently, Range may reflect any mapping for that key from any point during the Range call.

Range may be O(N) with the number of elements in the map even if f returns false after a constant number of calls.

func (*TokenMap) Store

func (m *TokenMap) Store(key int64, value []byte)

Store sets the value for a key.

type WsServer

type WsServer struct {
	*safe_ws.SafeWebSocket // 线程安全的ws
	*config.Plugin         // 服务器组配置
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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