bot

package
v0.0.0-...-94da729 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2023 License: AGPL-3.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const MAX_TEXT_LENGTH = 80

Variables

View Source
var (
	Clients                    ClientMap
	LoginTokens                TokenMap
	EnergyCount                = 0
	EnergyStop                 = false
	SignCount                  = 0
	SignStop                   = false
	RegisterSignCount          = 0
	RegisterSignStop           = false
	SubmitRequestCallbackCount = 0
	SubmitRequestCallbackStop  = false
	RequestTokenCount          = 0
	RequestTokenStop           = false
	DestoryInstanceCount       = 0
	DestoryInstanceStop        = false
	RSR                        RequestSignResult
	GTL                        *GMCLogin
	SR                         SignRegister
	IsRequestTokenAgain        bool = false
	TTI_i                           = 30
)

Functions

func ConnectUniversal

func ConnectUniversal(cli *client.QQClient)

func EmptyText

func EmptyText() *message.TextElement

func Energy

func Energy(uin uint64, id string, appVersion string, salt []byte) ([]byte, error)

func GetCSRFToken

func GetCSRFToken(c *client.QQClient) int

func GetCookiesWithDomain

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

func HandleDeleteMsg

func HandleDeleteMsg(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 HandleSendMsg

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

func HandleSendMusic

func HandleSendMusic(cli *client.QQClient, req *onebot.SendMusicReq) *onebot.SendMusicResp

func HandleSetGroupBan

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

func InitLog

func InitLog(cli *client.QQClient)

func IsClientExist

func IsClientExist(uin int64) bool

func Login

func Login(cli *client.QQClient) (bool, error)

func MiraiAtToProtoAt

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

func MiraiDiceToProtoDice

func MiraiDiceToProtoDice(elem *message.DiceElement) *onebot.Message

func MiraiFaceToProtoFace

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

func MiraiFingerGuessingToProtoFingerGuessing

func MiraiFingerGuessingToProtoFingerGuessing(elem *message.FingerGuessingElement) *onebot.Message

func MiraiForwardToProtoForward

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

func MiraiFriendImageToProtoImage

func MiraiFriendImageToProtoImage(elem *message.FriendImageElement) *onebot.Message

func MiraiGroupImageToProtoImage

func MiraiGroupImageToProtoImage(elem *message.GroupImageElement) *onebot.Message

func MiraiGuildImageToProtoImage

func MiraiGuildImageToProtoImage(elem *message.GuildImageElement) *onebot.Message

func MiraiLightAppToProtoLightApp

func MiraiLightAppToProtoLightApp(elem *message.LightAppElement) *onebot.Message

func MiraiLocalImageToProtoImage

func MiraiLocalImageToProtoImage(elem *clz.LocalImageElement) *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 MiraiServiceToProtoService

func MiraiServiceToProtoService(elem *message.ServiceElement) *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 PathExists

func PathExists(path string) bool

func ProcessLoginRsp

func ProcessLoginRsp(cli *client.QQClient, rsp *client.LoginResponse) (bool, error)

func ProtoAtToMiraiAt

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

func ProtoDiceToMiraiDice

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

func ProtoFaceToMiraiFace

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

func ProtoFingerGuessingToMiraiFingerGuessing

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

func ProtoGuildImageToMiraiGuildImage

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

func ProtoImageToMiraiImage

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

func ProtoLightAppToMiraiLightApp

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

func ProtoMsgToMiraiMsg

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

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

func ProtoMusicToMiraiMusic

func ProtoMusicToMiraiMusic(_ *client.QQClient, data map[string]string) (m message.IMessageElement)

func ProtoPokeToMiraiPoke

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

func ProtoReplyToMiraiReply

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

func ProtoServiceToMiraiService

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

func ProtoShareToMiraiShare

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

func ProtoSignInToMiraiSignIn

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

func ProtoSleep

func ProtoSleep(data map[string]string)

func ProtoTextToMiraiText

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

func ProtoTtsToMiraiTts

func ProtoTtsToMiraiTts(cli *client.QQClient, data map[string]string) (m message.IMessageElement)

func ProtoVideoToMiraiVideo

func ProtoVideoToMiraiVideo(_ *client.QQClient, data map[string]string) (m message.IMessageElement)

func ProtoVoiceToMiraiVoice

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

func RawMsgToMiraiMsg

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

func RegisterSign

func RegisterSign(uin uint64, androidId []byte, guid []byte, Qimei36 string, signServerAuth string)

func ReleaseClient

func ReleaseClient(cli *client.QQClient)

ReleaseClient 断开连接并释放资源

func RequestToken

func RequestToken(uin uint64)

func SetRelogin

func SetRelogin(cli *client.QQClient, retryInterval int, retryCount int)

func Sign

func Sign(seq uint64, uin string, cmd string, qua string, buff []byte) (sign []byte, extra []byte, token []byte, err error)

func TTIR

func TTIR(uin uint64)

Types

type CaptchaMap

type CaptchaMap 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 WaitingCaptchas CaptchaMap

TODO sync

func (*CaptchaMap) Delete

func (m *CaptchaMap) Delete(key int64)

Delete deletes the value for a key.

func (*CaptchaMap) Load

func (m *CaptchaMap) Load(key int64) (value *WaitingCaptcha, 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 (*CaptchaMap) LoadAndDelete

func (m *CaptchaMap) LoadAndDelete(key int64) (value *WaitingCaptcha, 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 (*CaptchaMap) LoadOrStore

func (m *CaptchaMap) LoadOrStore(key int64, value *WaitingCaptcha) (actual *WaitingCaptcha, 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 (*CaptchaMap) Range

func (m *CaptchaMap) Range(f func(key int64, value *WaitingCaptcha) 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 (*CaptchaMap) Store

func (m *CaptchaMap) Store(key int64, value *WaitingCaptcha)

Store sets the value for a key.

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.

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 GMCLogin

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

func GmcTokenLogin

func GmcTokenLogin() (g GMCLogin, err error)

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
)

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 SignRegister

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

func SRI

func SRI() (sr SignRegister, err error)

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 WaitingCaptcha

type WaitingCaptcha struct {
	Captcha *dto.Bot_Captcha
	Prom    *promise.Promise
}

type WsServer

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

Jump to

Keyboard shortcuts

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