client

package
v0.0.0-...-abba4c7 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: GPL-3.0 Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const Server = "msfwifi.3g.qq.com:8080"

Variables

View Source
var ErrConnectionClosed = errors.New("connection closed")

Functions

func ConvertIP

func ConvertIP(raw uint32) string

func ConvertNTHighwayNetWork

func ConvertNTHighwayNetWork(ipv4s []*oidb2.IPv4) []*highway.NTHighwayIPv4

func OnEvent

func OnEvent(client *QQClient, msg any)

OnEvent 事件响应,耗时操作,需提交协程处理

func ParseNtloginResponse

func ParseNtloginResponse(response []byte, sig *info.SigInfo) (loginState.State, error)

func ParsePacket

func ParsePacket(data []byte) (head *highway.RespDataHighwayHead, body *binary.Reader, err error)

func SendDataAsync

func SendDataAsync(packet []byte, serverURL string, end bool) ([]byte, error)

func SendPacketAsync

func SendPacketAsync(packet *highway.ReqDataHighwayHead, buffer *binary.Builder, serverURL string, end bool) ([]byte, error)

Types

type EventHandle

type EventHandle[T any] struct {
	// contains filtered or unexported fields
}

func (*EventHandle[T]) Subscribe

func (handle *EventHandle[T]) Subscribe(handler func(client *QQClient, event T))

type QQClient

type QQClient struct {
	Uin uint32

	Online atomic.Bool

	GroupMessageEvent           EventHandle[*message.GroupMessage]
	PrivateMessageEvent         EventHandle[*message.PrivateMessage]
	TempMessageEvent            EventHandle[*message.TempMessage]
	GroupInvitedEvent           EventHandle[*event.GroupInvite]            // 邀请入群
	GroupMemberJoinRequestEvent EventHandle[*event.GroupMemberJoinRequest] // 加群申请
	GroupMemberJoinEvent        EventHandle[*event.GroupMemberIncrease]    // 成员入群
	GroupMemberLeaveEvent       EventHandle[*event.GroupMemberDecrease]    // 成员退群
	GroupMuteEvent              EventHandle[*event.GroupMute]
	GroupRecallEvent            EventHandle[*event.GroupRecall]
	FriendRequestEvent          EventHandle[*event.FriendRequest] // 好友申请
	FriendRecallEvent           EventHandle[*event.FriendRecall]
	RenameEvent                 EventHandle[*event.Rename]
	// contains filtered or unexported fields
}

func NewQQclient

func NewQQclient(uin uint32, signUrl string, appInfo *info.AppInfo, deviceInfo *info.DeviceInfo, sig *info.SigInfo) *QQClient

NewQQclient 创建一个新的QQClient

func (*QQClient) Connect

func (c *QQClient) Connect() error

func (*QQClient) DisConnect

func (c *QQClient) DisConnect()

func (*QQClient) FecthQrcode

func (c *QQClient) FecthQrcode() ([]byte, string, error)

func (*QQClient) FetchFriends

func (c *QQClient) FetchFriends() ([]*entity.Friend, error)

FetchFriends 获取好友列表信息

func (*QQClient) FetchGroupMember

func (c *QQClient) FetchGroupMember(groupID uint32, token string) ([]*entity.GroupMember, string, error)

FetchGroupMember 获取对应群的群成员信息,使用token可以获取下一页的群成员信息

func (*QQClient) FetchGroups

func (c *QQClient) FetchGroups() ([]*entity.Group, error)

FetchGroups 获取所有已加入的群的信息

func (*QQClient) FriendPoke

func (c *QQClient) FriendPoke(uin uint32) error

func (*QQClient) GetAllGroupsInfo

func (c *QQClient) GetAllGroupsInfo() (map[uint32]*entity.Group, error)

func (*QQClient) GetAllGroupsMembersData

func (c *QQClient) GetAllGroupsMembersData() (map[uint32]map[uint32]*entity.GroupMember, error)

GetAllGroupsMembersData 获取所有群的群成员信息

func (*QQClient) GetCachedAllGroupsInfo

func (c *QQClient) GetCachedAllGroupsInfo() (map[uint32]*entity.Group, error)

GetCachedAllGroupsInfo 获取所有群信息(缓存)

func (*QQClient) GetCachedFriendInfo

func (c *QQClient) GetCachedFriendInfo(uin uint32) (*entity.Friend, error)

GetCachedFriendInfo 获取好友信息(缓存)

func (*QQClient) GetCachedGroupInfo

func (c *QQClient) GetCachedGroupInfo(groupUin uint32) (*entity.Group, error)

GetCachedGroupInfo 获取群信息(缓存)

func (*QQClient) GetCachedMemberInfo

func (c *QQClient) GetCachedMemberInfo(uin, groupUin uint32) (*entity.GroupMember, error)

GetCachedMemberInfo 获取群成员信息(缓存)

func (*QQClient) GetCachedMembersInfo

func (c *QQClient) GetCachedMembersInfo(groupUin uint32) (map[uint32]*entity.GroupMember, error)

GetCachedMembersInfo 获取指定群所有群成员信息(缓存)

func (*QQClient) GetFriendsData

func (c *QQClient) GetFriendsData() (map[uint32]*entity.Friend, error)

GetFriendsData 获取好友列表数据

func (*QQClient) GetGroupMembersData

func (c *QQClient) GetGroupMembersData(groupUin uint32) (map[uint32]*entity.GroupMember, error)

GetGroupMembersData 获取指定群所有成员信息

func (*QQClient) GetQrcodeResult

func (c *QQClient) GetQrcodeResult() (qrcodeState.State, error)

func (*QQClient) GetServiceServer

func (c *QQClient) GetServiceServer() ([]byte, map[uint32][]string)

func (*QQClient) GetUid

func (c *QQClient) GetUid(uin uint32, groupUin ...uint32) string

GetUid 获取缓存中对应uin的uid

func (*QQClient) GetUin

func (c *QQClient) GetUin(uid string, groupUin ...uint32) uint32

GetUin 获取缓存中对应的uin

func (*QQClient) GroupKickMember

func (c *QQClient) GroupKickMember(groupID, uin uint32, rejectAddRequest bool) error

func (*QQClient) GroupLeave

func (c *QQClient) GroupLeave(groupID uint32) error

func (*QQClient) GroupMuteGlobal

func (c *QQClient) GroupMuteGlobal(groupID uint32, isMute bool) error

func (*QQClient) GroupMuteMember

func (c *QQClient) GroupMuteMember(groupID, duration, uin uint32) error

func (*QQClient) GroupPoke

func (c *QQClient) GroupPoke(groupID, uin uint32) error

func (*QQClient) GroupRemark

func (c *QQClient) GroupRemark(groupID uint32, remark string) error

func (*QQClient) GroupRename

func (c *QQClient) GroupRename(groupID uint32, name string) error

func (*QQClient) GroupRenameMember

func (c *QQClient) GroupRenameMember(groupID, uin uint32, name string) error

func (*QQClient) GroupSetAdmin

func (c *QQClient) GroupSetAdmin(groupID, uin uint32, isAdmin bool) error

func (*QQClient) GroupSetSpecialTitle

func (c *QQClient) GroupSetSpecialTitle(groupUin, uin uint32, title string) error

func (*QQClient) ImageUploadGroup

func (c *QQClient) ImageUploadGroup(groupUin uint32, element message.IMessageElement) (*message.GroupImageElement, error)

func (*QQClient) ImageUploadPrivate

func (c *QQClient) ImageUploadPrivate(targetUid string, element message.IMessageElement) (*message.FriendImageElement, error)

func (*QQClient) KeyExchange

func (c *QQClient) KeyExchange()

func (*QQClient) Login

func (c *QQClient) Login(password, qrcodePath string) (bool, error)

func (*QQClient) Loop

func (c *QQClient) Loop() error

func (*QQClient) NickName

func (c *QQClient) NickName() string

func (*QQClient) OnConnected

func (c *QQClient) OnConnected()

func (*QQClient) OnDisconnected

func (c *QQClient) OnDisconnected()

func (*QQClient) OnMessage

func (c *QQClient) OnMessage(msgLen int)

func (*QQClient) PasswordLogin

func (c *QQClient) PasswordLogin(password string) (loginState.State, error)

func (*QQClient) QrcodeLogin

func (c *QQClient) QrcodeLogin(refreshInterval int) (bool, error)

func (*QQClient) ReadLoop

func (c *QQClient) ReadLoop()

func (*QQClient) RecallGroupMessage

func (c *QQClient) RecallGroupMessage(GrpUin, seq uint32) (bool, error)

func (*QQClient) RefreshAllGroupMembersCache

func (c *QQClient) RefreshAllGroupMembersCache() error

RefreshAllGroupMembersCache 刷新所有群的群成员缓存

func (*QQClient) RefreshAllGroupsInfo

func (c *QQClient) RefreshAllGroupsInfo() error

RefreshAllGroupsInfo 刷新所有群信息缓存

func (*QQClient) RefreshFriendCache

func (c *QQClient) RefreshFriendCache() error

RefreshFriendCache 刷新好友缓存

func (*QQClient) RefreshGroupMembersCache

func (c *QQClient) RefreshGroupMembersCache(groupUin uint32) error

RefreshGroupMembersCache 刷新指定群的群成员员缓存

func (*QQClient) Register

func (c *QQClient) Register() (bool, error)

func (*QQClient) SSOHeartbeat

func (c *QQClient) SSOHeartbeat(calcLatency bool) int64

func (*QQClient) Send

func (c *QQClient) Send(data []byte) error

func (*QQClient) SendAndWait

func (c *QQClient) SendAndWait(data []byte, seq, timeout int) (*wtlogin.SSOPacket, error)

func (*QQClient) SendGroupMessage

func (c *QQClient) SendGroupMessage(groupUin uint32, elements []message2.IMessageElement) (resp *action.SendMessageResponse, err error)

func (*QQClient) SendOidbPacket

func (c *QQClient) SendOidbPacket(pkt *oidb.OidbPacket) error

func (*QQClient) SendOidbPacketAndWait

func (c *QQClient) SendOidbPacketAndWait(pkt *oidb.OidbPacket) (*wtlogin.SSOPacket, error)

func (*QQClient) SendPrivateMessage

func (c *QQClient) SendPrivateMessage(uin uint32, elements []message2.IMessageElement) (resp *action.SendMessageResponse, err error)

func (*QQClient) SendRawMessage

func (c *QQClient) SendRawMessage(route *message.RoutingHead, body *message.MessageBody) (resp *action.SendMessageResponse, err error)

func (*QQClient) SendTempMessage

func (c *QQClient) SendTempMessage(groupID uint32, uin uint32, elements []message2.IMessageElement) (resp *action.SendMessageResponse, err error)

func (*QQClient) SendUniPacket

func (c *QQClient) SendUniPacket(cmd string, buf []byte) error

func (*QQClient) SendUniPacketAndAwait

func (c *QQClient) SendUniPacketAndAwait(cmd string, buf []byte) (*wtlogin.SSOPacket, error)

func (*QQClient) SendUpBlockAsync

func (c *QQClient) SendUpBlockAsync(block UpBlock, server string) bool

func (*QQClient) Stop

func (c *QQClient) Stop()

Stop 停止整个client,一旦停止不能重新连接

func (*QQClient) TokenLogin

func (c *QQClient) TokenLogin(token []byte) (loginState.State, error)

func (*QQClient) UploadSrcByStreamAsync

func (c *QQClient) UploadSrcByStreamAsync(commonId int, stream io.ReadSeeker, ticket []byte, md5 []byte, extendInfo []byte) bool

type ResultStore

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

ResultStore 灵感来源于ddl的onebot适配器

func NewResultStore

func NewResultStore() *ResultStore

func (*ResultStore) AddResult

func (s *ResultStore) AddResult(seq int, data *wtlogin.SSOPacket) bool

AddResult 收到消息的时候调用,返回此seq是否存在,如果存在则存储数据

func (*ResultStore) AddSeq

func (s *ResultStore) AddSeq(seq int)

AddSeq 发消息的时候调用,把seq加到map里面

func (*ResultStore) ContainSeq

func (s *ResultStore) ContainSeq(seq int) bool

ContainSeq 判断这个seq是否存在

func (*ResultStore) DeleteSeq

func (s *ResultStore) DeleteSeq(seq int)

DeleteSeq 删除seq

func (*ResultStore) Fecth

func (s *ResultStore) Fecth(seq, timeout int) (*wtlogin.SSOPacket, error)

Fecth 等待获取数据直到超时,这里找不到对应的seq会直接返回错误,务必在发包之前调用 AddSeq,如果发包出错可以 DeleteSeq

type TCPClient

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

func NewTCPClient

func NewTCPClient(addr string, timeout int) *TCPClient

func (*TCPClient) Close

func (c *TCPClient) Close()

func (*TCPClient) Connect

func (c *TCPClient) Connect() error

func (*TCPClient) IsClosed

func (c *TCPClient) IsClosed() bool

func (*TCPClient) ReadBytes

func (c *TCPClient) ReadBytes(len int) ([]byte, error)

func (*TCPClient) Write

func (c *TCPClient) Write(b []byte) error

type UpBlock

type UpBlock struct {
	CommandId  int
	Uin        uint
	Sequence   uint
	FileSize   uint64
	Offset     uint64
	Ticket     []byte
	FileMd5    []byte
	Block      []byte
	ExtendInfo []byte
	Timestamp  uint64
}

Jump to

Keyboard shortcuts

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