client

package
v0.0.0-...-a1dc7ad Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2020 License: AGPL-3.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NeedCaptcha       LoginError = 1
	OtherLoginError   LoginError = 3
	UnsafeDeviceError LoginError = 4
	UnknownLoginError LoginError = -1

	Owner MemberPermission = iota
	Administrator
	Member
)

Variables

View Source
var EmptyBytes = []byte{}
View Source
var (
	ErrAlreadyOnline = errors.New("already online")
)
View Source
var NumberRange = "0123456789"
View Source
var SystemDeviceInfo = &DeviceInfo{
	Display:     []byte("MIRAI.123456.001"),
	Product:     []byte("mirai"),
	Device:      []byte("mirai"),
	Board:       []byte("mirai"),
	Brand:       []byte("mamoe"),
	Model:       []byte("mirai"),
	Bootloader:  []byte("unknown"),
	FingerPrint: []byte("mamoe/mirai/mirai:10/MIRAI.200122.001/1234567:user/release-keys"),
	BootId:      []byte("cb886ae2-00b6-4d68-a230-787f111d12c7"),
	ProcVersion: []byte("Linux version 3.0.31-cb886ae2 (android-build@xxx.xxx.xxx.xxx.com)"),
	BaseBand:    []byte{},
	SimInfo:     []byte("T-Mobile"),
	OSType:      []byte("android"),
	MacAddress:  []byte("00:50:56:C0:00:08"),
	IpAddress:   []byte{10, 0, 1, 3},
	WifiBSSID:   []byte("00:50:56:C0:00:08"),
	WifiSSID:    []byte("<unknown ssid>"),
	IMEI:        "468356291846738",
	AndroidId:   []byte("MIRAI.123456.001"),
	APN:         []byte("wifi"),
	Version: &Version{
		Incremental: []byte("5891938"),
		Release:     []byte("10"),
		CodeName:    []byte("REL"),
		Sdk:         29,
	},
}

default

Functions

func GenRandomDevice

func GenRandomDevice()

func NewUinFilterPrivate

func NewUinFilterPrivate(uin int64) func(*message.PrivateMessage) bool

Types

type ClientDisconnectedEvent

type ClientDisconnectedEvent struct {
	Message string
}

type CurrentTalkative

type CurrentTalkative struct {
	Uin      int64  `json:"uin"`
	DayCount int32  `json:"day_count"`
	Avatar   string `json:"avatar"`
	Name     string `json:"nick"`
}

type DeviceInfo

type DeviceInfo struct {
	Display     []byte
	Product     []byte
	Device      []byte
	Board       []byte
	Brand       []byte
	Model       []byte
	Bootloader  []byte
	FingerPrint []byte
	BootId      []byte
	ProcVersion []byte
	BaseBand    []byte
	SimInfo     []byte
	OSType      []byte
	MacAddress  []byte
	IpAddress   []byte
	WifiBSSID   []byte
	WifiSSID    []byte
	IMSIMd5     []byte
	IMEI        string
	AndroidId   []byte
	APN         []byte
	Guid        []byte
	TgtgtKey    []byte
	Version     *Version
}

func (*DeviceInfo) GenDeviceInfoData

func (info *DeviceInfo) GenDeviceInfoData() []byte

func (*DeviceInfo) GenNewGuid

func (info *DeviceInfo) GenNewGuid()

func (*DeviceInfo) GenNewTgtgtKey

func (info *DeviceInfo) GenNewTgtgtKey()

func (*DeviceInfo) ReadJson

func (info *DeviceInfo) ReadJson(d []byte) error

func (*DeviceInfo) ToJson

func (info *DeviceInfo) ToJson() []byte

type DeviceInfoFile

type DeviceInfoFile struct {
	Display     string `json:"display"`
	Product     string `json:"product"`
	Device      string `json:"device"`
	Board       string `json:"board"`
	Model       string `json:"model"`
	FingerPrint string `json:"finger_print"`
	BootId      string `json:"boot_id"`
	ProcVersion string `json:"proc_version"`
	IMEI        string `json:"imei"`
}

type FriendInfo

type FriendInfo struct {
	Uin      int64
	Nickname string
	Remark   string
	FaceId   int16
}

type FriendListResponse

type FriendListResponse struct {
	TotalCount int32
	List       []*FriendInfo
}

type FriendMessageRecalledEvent

type FriendMessageRecalledEvent struct {
	FriendUin int64
	MessageId int32
	Time      int64
}

type GroupHonorInfo

type GroupHonorInfo struct {
	GroupCode        string            `json:"gc"`
	Uin              string            `json:"uin"`
	Type             HonorType         `json:"type"`
	TalkativeList    []HonorMemberInfo `json:"talkativeList"`
	CurrentTalkative CurrentTalkative  `json:"currentTalkative"`
	ActorList        []HonorMemberInfo `json:"actorList"`
	LegendList       []HonorMemberInfo `json:"legendList"`
	StrongNewbieList []HonorMemberInfo `json:"strongnewbieList"`
	EmotionList      []HonorMemberInfo `json:"emotionList"`
}

type GroupInfo

type GroupInfo struct {
	Uin            int64
	Code           int64
	Name           string
	Memo           string
	OwnerUin       int64
	MemberCount    uint16
	MaxMemberCount uint16
	Members        []*GroupMemberInfo
	// contains filtered or unexported fields
}

func (*GroupInfo) AdministratorOrOwner

func (g *GroupInfo) AdministratorOrOwner() bool

func (*GroupInfo) FindMember

func (g *GroupInfo) FindMember(uin int64) *GroupMemberInfo

func (*GroupInfo) MuteAll

func (g *GroupInfo) MuteAll(mute bool)

func (*GroupInfo) Quit

func (g *GroupInfo) Quit()

func (*GroupInfo) SelfPermission

func (g *GroupInfo) SelfPermission() MemberPermission

func (*GroupInfo) UpdateMemo

func (g *GroupInfo) UpdateMemo(newMemo string)

func (*GroupInfo) UpdateName

func (g *GroupInfo) UpdateName(newName string)

type GroupInvitedRequest

type GroupInvitedRequest struct {
	RequestId   int64
	InvitorUin  int64
	InvitorNick string
	GroupCode   int64
	GroupName   string
	// contains filtered or unexported fields
}

func (*GroupInvitedRequest) Accept

func (r *GroupInvitedRequest) Accept()

func (*GroupInvitedRequest) Reject

func (r *GroupInvitedRequest) Reject(block bool, reason string)

type GroupLeaveEvent

type GroupLeaveEvent struct {
	Group    *GroupInfo
	Operator *GroupMemberInfo
}

type GroupMemberInfo

type GroupMemberInfo struct {
	Group                  *GroupInfo
	Uin                    int64
	Nickname               string
	CardName               string
	Level                  uint16
	JoinTime               int64
	LastSpeakTime          int64
	SpecialTitle           string
	SpecialTitleExpireTime int64
	Permission             MemberPermission
}

func (*GroupMemberInfo) DisplayName

func (m *GroupMemberInfo) DisplayName() string

func (*GroupMemberInfo) EditCard

func (m *GroupMemberInfo) EditCard(card string)

func (*GroupMemberInfo) EditSpecialTitle

func (m *GroupMemberInfo) EditSpecialTitle(title string)

func (*GroupMemberInfo) Kick

func (m *GroupMemberInfo) Kick(msg string)

func (*GroupMemberInfo) Manageable

func (m *GroupMemberInfo) Manageable() bool

func (*GroupMemberInfo) Mute

func (m *GroupMemberInfo) Mute(time uint32)

type GroupMessageRecalledEvent

type GroupMessageRecalledEvent struct {
	GroupCode   int64
	OperatorUin int64
	AuthorUin   int64
	MessageId   int32
	Time        int32
}

type GroupMuteEvent

type GroupMuteEvent struct {
	GroupCode   int64
	OperatorUin int64
	TargetUin   int64
	Time        int32
}

type HonorMemberInfo

type HonorMemberInfo struct {
	Uin    int64  `json:"uin"`
	Avatar string `json:"avatar"`
	Name   string `json:"name"`
	Desc   string `json:"desc"`
}

type HonorType

type HonorType int
const (
	Talkative    HonorType = 1 //龙王
	Performer    HonorType = 2 //群聊之火
	Legend       HonorType = 3 //群聊炙焰
	StrongNewbie HonorType = 5 //冒尖小春笋
	Emotion      HonorType = 6 //快乐源泉
)

type LogEvent

type LogEvent struct {
	Type    string
	Message string
}

type LoginError

type LoginError int

type LoginResponse

type LoginResponse struct {
	Success bool
	Error   LoginError

	// Captcha info
	CaptchaImage []byte
	CaptchaSign  []byte

	// Unsafe device
	VerifyUrl string

	// other error
	ErrorMessage string
}

type MemberJoinGroupEvent

type MemberJoinGroupEvent struct {
	Group  *GroupInfo
	Member *GroupMemberInfo
}

type MemberLeaveGroupEvent

type MemberLeaveGroupEvent struct {
	Group    *GroupInfo
	Member   *GroupMemberInfo
	Operator *GroupMemberInfo
}

type MemberPermission

type MemberPermission int

type MemberPermissionChangedEvent

type MemberPermissionChangedEvent struct {
	Group         *GroupInfo
	Member        *GroupMemberInfo
	OldPermission MemberPermission
	NewPermission MemberPermission
}

type NewFriendEvent

type NewFriendEvent struct {
	Friend *FriendInfo
}

type NewFriendRequest

type NewFriendRequest struct {
	RequestId     int64
	Message       string
	RequesterUin  int64
	RequesterNick string
	// contains filtered or unexported fields
}

func (*NewFriendRequest) Accept

func (r *NewFriendRequest) Accept()

func (*NewFriendRequest) Reject

func (r *NewFriendRequest) Reject()

type QQClient

type QQClient struct {
	Uin         int64
	PasswordMd5 [16]byte

	Nickname   string
	Age        uint16
	Gender     uint16
	FriendList []*FriendInfo
	GroupList  []*GroupInfo
	Online     bool

	SequenceId              int32
	OutGoingPacketSessionId []byte
	RandomKey               []byte
	Conn                    net.Conn
	// contains filtered or unexported fields
}

func NewClient

func NewClient(uin int64, password string) *QQClient

NewClient create new qq client

func NewClientMd5

func NewClientMd5(uin int64, passwordMd5 [16]byte) *QQClient

func (*QQClient) Debug

func (c *QQClient) Debug(msg string, args ...interface{})

func (*QQClient) Error

func (c *QQClient) Error(msg string, args ...interface{})

func (*QQClient) FindFriend

func (c *QQClient) FindFriend(uin int64) *FriendInfo

func (*QQClient) FindGroup

func (c *QQClient) FindGroup(code int64) *GroupInfo

func (*QQClient) FindGroupByUin

func (c *QQClient) FindGroupByUin(uin int64) *GroupInfo

func (*QQClient) GetForwardMessage

func (c *QQClient) GetForwardMessage(resId string) *message.ForwardMessage

func (*QQClient) GetFriendList

func (c *QQClient) GetFriendList() (*FriendListResponse, error)

GetFriendList request friend list

func (*QQClient) GetGroupFileUrl

func (c *QQClient) GetGroupFileUrl(groupCode int64, fileId string, busId int32) string

func (*QQClient) GetGroupHonorInfo

func (c *QQClient) GetGroupHonorInfo(groupCode int64, honorType HonorType) (*GroupHonorInfo, error)

func (*QQClient) GetGroupList

func (c *QQClient) GetGroupList() ([]*GroupInfo, error)

func (*QQClient) GetGroupMembers

func (c *QQClient) GetGroupMembers(group *GroupInfo) ([]*GroupMemberInfo, error)

func (*QQClient) GetShortVideoUrl

func (c *QQClient) GetShortVideoUrl(uuid, md5 []byte) string

func (*QQClient) Info

func (c *QQClient) Info(msg string, args ...interface{})

func (*QQClient) Login

func (c *QQClient) Login() (*LoginResponse, error)

Login send login request

func (*QQClient) OnDisconnected

func (c *QQClient) OnDisconnected(f func(*QQClient, *ClientDisconnectedEvent))

func (*QQClient) OnFriendMessageRecalled

func (c *QQClient) OnFriendMessageRecalled(f func(*QQClient, *FriendMessageRecalledEvent))

func (*QQClient) OnGroupInvited

func (c *QQClient) OnGroupInvited(f func(*QQClient, *GroupInvitedRequest))

func (*QQClient) OnGroupMemberJoined

func (c *QQClient) OnGroupMemberJoined(f func(*QQClient, *MemberJoinGroupEvent))

func (*QQClient) OnGroupMemberLeaved

func (c *QQClient) OnGroupMemberLeaved(f func(*QQClient, *MemberLeaveGroupEvent))

func (*QQClient) OnGroupMemberPermissionChanged

func (c *QQClient) OnGroupMemberPermissionChanged(f func(*QQClient, *MemberPermissionChangedEvent))

func (*QQClient) OnGroupMessage

func (c *QQClient) OnGroupMessage(f func(*QQClient, *message.GroupMessage))

func (*QQClient) OnGroupMessageRecalled

func (c *QQClient) OnGroupMessageRecalled(f func(*QQClient, *GroupMessageRecalledEvent))

func (*QQClient) OnGroupMuted

func (c *QQClient) OnGroupMuted(f func(*QQClient, *GroupMuteEvent))

func (*QQClient) OnJoinGroup

func (c *QQClient) OnJoinGroup(f func(*QQClient, *GroupInfo))

func (*QQClient) OnLeaveGroup

func (c *QQClient) OnLeaveGroup(f func(*QQClient, *GroupLeaveEvent))

func (*QQClient) OnLog

func (c *QQClient) OnLog(f func(*QQClient, *LogEvent))

func (*QQClient) OnNewFriendAdded

func (c *QQClient) OnNewFriendAdded(f func(*QQClient, *NewFriendEvent))

func (*QQClient) OnNewFriendRequest

func (c *QQClient) OnNewFriendRequest(f func(*QQClient, *NewFriendRequest))

func (*QQClient) OnPrivateMessage

func (c *QQClient) OnPrivateMessage(f func(*QQClient, *message.PrivateMessage))

func (*QQClient) OnPrivateMessageF

func (c *QQClient) OnPrivateMessageF(filter func(*message.PrivateMessage) bool, f func(*QQClient, *message.PrivateMessage))

func (*QQClient) OnTempMessage

func (c *QQClient) OnTempMessage(f func(*QQClient, *message.TempMessage))

func (*QQClient) OnUserWantJoinGroup

func (c *QQClient) OnUserWantJoinGroup(f func(*QQClient, *UserJoinGroupRequest))

func (*QQClient) QueryFriendImage

func (c *QQClient) QueryFriendImage(target int64, hash []byte, size int32) (*message.FriendImageElement, error)

func (*QQClient) QueryGroupImage

func (c *QQClient) QueryGroupImage(groupCode int64, hash []byte, size int32) (*message.GroupImageElement, error)

func (*QQClient) RecallGroupMessage

func (c *QQClient) RecallGroupMessage(groupCode int64, msgId, msgInternalId int32)

func (*QQClient) ReloadFriendList

func (c *QQClient) ReloadFriendList() error

ReloadFriendList refresh QQClient.FriendList field via GetFriendList()

func (*QQClient) ReloadGroupList

func (c *QQClient) ReloadGroupList() error

func (*QQClient) SendGroupForwardMessage

func (c *QQClient) SendGroupForwardMessage(groupCode int64, m *message.ForwardMessage) *message.GroupMessage

func (*QQClient) SendGroupMessage

func (c *QQClient) SendGroupMessage(groupCode int64, m *message.SendingMessage, f ...bool) *message.GroupMessage

func (*QQClient) SendPrivateMessage

func (c *QQClient) SendPrivateMessage(target int64, m *message.SendingMessage) *message.PrivateMessage

func (*QQClient) SendTempMessage

func (c *QQClient) SendTempMessage(groupCode, target int64, m *message.SendingMessage) *message.TempMessage

func (*QQClient) SolveFriendRequest

func (c *QQClient) SolveFriendRequest(req *NewFriendRequest, accept bool)

func (*QQClient) SolveGroupJoinRequest

func (c *QQClient) SolveGroupJoinRequest(i interface{}, accept, block bool, reason string)

func (*QQClient) SubmitCaptcha

func (c *QQClient) SubmitCaptcha(result string, sign []byte) (*LoginResponse, error)

SubmitCaptcha send captcha to server

func (*QQClient) UploadGroupImage

func (c *QQClient) UploadGroupImage(groupCode int64, img []byte) (*message.GroupImageElement, error)

func (*QQClient) UploadGroupPtt

func (c *QQClient) UploadGroupPtt(groupCode int64, voice []byte) (*message.GroupVoiceElement, error)

func (*QQClient) UploadPrivateImage

func (c *QQClient) UploadPrivateImage(target int64, img []byte) (*message.FriendImageElement, error)

type UserJoinGroupRequest

type UserJoinGroupRequest struct {
	RequestId     int64
	Message       string
	RequesterUin  int64
	RequesterNick string
	GroupCode     int64
	GroupName     string
	// contains filtered or unexported fields
}

func (*UserJoinGroupRequest) Accept

func (r *UserJoinGroupRequest) Accept()

func (*UserJoinGroupRequest) Reject

func (r *UserJoinGroupRequest) Reject(block bool, reason string)

type Version

type Version struct {
	Incremental []byte
	Release     []byte
	CodeName    []byte
	Sdk         uint32
}

Directories

Path Synopsis
pb
msg

Jump to

Keyboard shortcuts

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