Class Client

一个客户端

Hierarchy (view full)

Constructors

Properties

Accessors

Methods

_calcMsgCntPerMin _msgExists acquireGfs addClass addFriend addMatcher apiPing bail bailSync buildReserveFields calcPoW cleanCache deleteClass deleteFriend deleteMsg deleteStamp em emit fetchQrcode generateSignPacket generateT544Packet getApiQQVer getApkInfo getApkInfoList getChannelInfo getChannelList getChatHistory getCmdWhiteList getCookies getCsrfToken getForumUrl getForwardMsg getFriendList getGroupInfo getGroupList getGroupMemberInfo getGroupMemberList getGroupShareJson getGuildInfo getGuildList getGuildMemberList getMsg getProfile getRoamingStamp getSign getStrangerInfo getStrangerList getSystemMsg getT544 getVideoUrl group imageOcr inviteFriend isOnline listeners login logout makeForwardMsg off offTrap on once passwordLogin qrcodeLogin queryQrcodeResult refreshToken register reloadBlackList reloadFriendList reloadGroupList reloadGuilds reloadStrangerList removeEssenceMessage renameClass reportReaded requestSignToken requestToken sendDiscussMsg sendGroupMsg sendGroupNotice sendGroupPoke sendGroupSign sendGuildMsg sendHeartbeat sendLike sendOidb sendOidbSvcTrpcTcp sendPacket sendPrivateMsg sendSmsCode sendSMSCode sendTempMsg sendUni setAvatar setBirthday setDescription setEssenceMessage setFriendAddRequest setGender setGroupAddRequest setGroupAdmin setGroupAnonymous setGroupAnonymousBan setGroupBan setGroupCard setGroupKick setGroupLeave setGroupMemberScreenMsg setGroupName setGroupPortrait setGroupSpecialTitle setGroupWholeBan setNickname setOnlineStatus setPortrait setRemoteServer setSignature setSignServer sliderLogin ssoPacketListHandler submitSlider submitSmsCode submitSMSCode submitSsoPacket switchQQVer syncTimeDiff terminate token_expire tokenLogin trap trapOnce trip tripAsync updateCmdWhiteList user writeUni

Constructors

Properties

_cache: Map<number, Set<string>> = ...
_sync_cookie?: Uint8Array
age: number = 0

年龄

apk: Apk
bid: string = ""

未知属性

blacklist: Set<number> = ...

黑名单列表

classes: Map<number, string> = ...

好友分组

config: Required<Config>

配置

cookies: {
    : string;
    aq.qq.com: string;
    buluo.qq.com: string;
    connect.qq.com: string;
    docs.qq.com: string;
    game.qq.com: string;
    gamecenter.qq.com: string;
    haoma.qq.com: string;
    id.qq.com: string;
    kg.qq.com: string;
    mail.qq.com: string;
    mma.qq.com: string;
    office.qq.com: string;
    openmobile.qq.com: string;
    qqweb.qq.com: string;
    qun.qq.com: string;
    qzone.qq.com: string;
    ti.qq.com: string;
    v.qq.com: string;
    vip.qq.com: string;
    y.qq.com: string;
} = ...

未知属性

device: Device
dir: string

账号本地数据存储目录

emp_interval: number = ...

token刷新间隔(秒)

fl: Map<number, FriendInfo> = ...

好友列表

gl: Map<number, GroupInfo> = ...

群列表

gml: Map<number, Map<number, MemberInfo>> = ...

群员列表缓存

guilds: Map<string, Guild> = ...

我加入的频道列表

heartbeat: (() => void) = NOOP

随心跳一起触发的函数,可以随意设定

Type declaration

    • (): void
    • no operation

      Returns void

interval: number = 60

心跳间隔(秒)

logger: Logger | Logger

日志记录器,初始情况下是log4js.Logger

login_timer: null | Timeout = null
nickname: string = ""

昵称

password_md5?: Buffer

密码的md5值,调用 login 后会保存在这里,用于token过期时恢复登录

pickDiscuss: ((...args: [gid: number]) => Discuss) = ...

创建一个讨论组对象

Type declaration

    • (...args): Discuss
    • Parameters

      • Rest...args: [gid: number]

      Returns Discuss

      一个Discuss对象

pickFriend: ((...args: [uin: number, strict: boolean]) => Friend) = ...

得到一个好友对象, 通常不会重复创建、调用

Type declaration

    • (...args): Friend
    • Parameters

      • Rest...args: [uin: number, strict: boolean]

      Returns Friend

      一个Friend对象

pickGroup: ((...args: [gid: number, strict: boolean]) => Group) = ...

得到一个群对象, 通常不会重复创建、调用

Type declaration

    • (...args): Group
    • Parameters

      • Rest...args: [gid: number, strict: boolean]

      Returns Group

      一个Group对象

pickGuild: ((...args: [guild_id: string]) => Guild) = ...

创建一个频道对象,通常不会重复创建、调用

Type declaration

    • (...args): Guild
    • Parameters

      • Rest...args: [guild_id: string]

      Returns Guild

      一个Guild对象

pickMember: ((...args: [gid: number, uin: number, strict: boolean]) => Member) = ...

得到一个群员对象, 通常不会重复创建、调用

Type declaration

    • (...args): Member
    • Parameters

      • Rest...args: [gid: number, uin: number, strict: boolean]

      Returns Member

      一个Member对象

pickUser: ((...args: [uin: number]) => User) = ...

创建一个用户对象

Type declaration

    • (...args): User
    • Parameters

      • Rest...args: [uin: number]

      Returns User

      一个User对象

pkg: any = ...
pskey: {
    [domain: string]: Buffer;
} = {}
pt4token: {
    [domain: string]: Buffer;
} = {}
register_retry_num: number = 3

上线失败重试次数

sex: Gender = "unknown"

性别

sig: Record<string, any> = ...
sign_type: string = ""
signCmd: String[] = []
sl: Map<number, StrangerInfo> = ...

陌生人列表

stamp: Set<string> = ...

漫游表情缓存

statistics: {
    lost_pkt_cnt: number;
    lost_times: number;
    msg_cnt_per_min: number;
    recv_msg_cnt: number;
    recv_pkt_cnt: number;
    remote_ip: string;
    remote_port: number;
    sent_msg_cnt: number;
    sent_pkt_cnt: number;
    start_time: number;
    ver: string;
} = ...

数据统计

status: OnlineStatus = OnlineStatus.Offline

在线状态

tiny_id: string = ""

相当于频道中的qq号

token_retry_num: number = 2

token登录重试次数

uid: string
uin: number

Accessors

  • get stat(): {
        lost_pkt_cnt: number;
        lost_times: number;
        msg_cnt_per_min: number;
        recv_msg_cnt: number;
        recv_pkt_cnt: number;
        remote_ip: string;
        remote_port: number;
        sent_msg_cnt: number;
        sent_pkt_cnt: number;
        start_time: number;
        ver: string;
    }
  • 数据统计

    Returns {
        lost_pkt_cnt: number;
        lost_times: number;
        msg_cnt_per_min: number;
        recv_msg_cnt: number;
        recv_pkt_cnt: number;
        remote_ip: string;
        remote_port: number;
        sent_msg_cnt: number;
        sent_pkt_cnt: number;
        start_time: number;
        ver: string;
    }

    • lost_pkt_cnt: number
    • lost_times: number
    • msg_cnt_per_min: number
    • recv_msg_cnt: number
    • recv_pkt_cnt: number
    • remote_ip: string
    • remote_port: number
    • sent_msg_cnt: number
    • sent_pkt_cnt: number
    • start_time: number
    • ver: string

Methods

  • Parameters

    • from: number
    • type: number
    • seq: number
    • time: number

    Returns boolean

  • 添加好友分组

    Parameters

    • name: string

    Returns Promise<void>

  • Parameters

    • group_id: number
    • user_id: number
    • comment: string = ""

    Returns Promise<boolean>

    use Member.addFriend

  • Type Parameters

    • T extends Trapper = this

    Parameters

    • this: T
    • matcher: Matcher
    • listener: Listener

    Returns ToDispose<T>

  • Parameters

    • matcher: Matcher
    • Rest...args: any[]

    Returns any

  • Parameters

    • matcher: Matcher
    • Rest...args: any[]

    Returns Promise<any>

  • 清空缓存文件 fs.rm need v14.14

    Returns void

  • 删除好友分组

    Parameters

    • id: number

    Returns Promise<void>

  • Parameters

    • user_id: number
    • block: boolean = true

    Returns Promise<boolean>

    use Friend.delete

  • 删除表情(支持批量)

    Parameters

    • id: string | string[]

    Returns Promise<void>

  • emit an event

    Parameters

    • name: string = ""
    • Optionaldata: any

    Returns void

  • Parameters

    • guild_id: string
    • channel_id: string

    Returns null | {
        channel_id: string;
        channel_name: string;
        channel_type: ChannelType;
        guild_id: string;
    }

  • 获取子频道列表 use Guild.channels

    Parameters

    • guild_id: string

    Returns {
        channel_id: string;
        channel_name: string;
        channel_type: ChannelType;
        guild_id: string;
    }[]

  • 生成频道帖子分享url

    Parameters

    • guild_id: string

      {string} 频道id

    • channel_id: string

      {string} 子频道id

    • forum_id: string

      {string} 帖子id

    Returns Promise<string>

    帖子分享url

  • 获取群分享JSON

    Parameters

    • group_id: number

    Returns Promise<any>

  • Parameters

    • guild_id: string

    Returns null | {
        guild_id: string;
        guild_name: string;
    }

    use Guild.info

  • Returns {
        guild_id: string;
        guild_name: string;
    }[]

    use guilds

  • 获取用户资料卡信息

    Parameters

    • uin: number

    Returns Promise<UserProfile>

  • 获取漫游表情

    Parameters

    • no_cache: boolean = false

    Returns Promise<string[]>

  • Parameters

    • user_id: number

    Returns Promise<{
        age: number;
        area: string;
        nickname: string;
        sex: Gender;
        user_id: number;
    }>

  • 获取视频下载地址 use Friend.getVideoUrl

    Parameters

    • fid: string
    • md5: string | Buffer

    Returns Promise<null | string>

  • Parameters

    • group_id: number
    • user_id: number

    Returns Promise<boolean>

    use Group.invite

  • Parameters

    • Optionalmatcher: Matcher

    Returns Listener[]

  • 只能在初始化Client时传了uin或扫码登录,才能调用

    • 传了password则尝试密码登录
    • 不传password则尝试扫码登录 未传任何参数 则尝试扫码登录 掉线重连时也是自动调用此函数,走相同逻辑 你也可以在配置中修改reconn_interval,关闭掉线重连并自行处理

    Parameters

    • Optionalpassword: string | Buffer

      可以为密码原文,或密码的md5值

    Returns Promise<void>

  • 传了uin,未传password 会优先尝试使用token登录 (token在上次登录成功后存放在this.dir${uin}_token中) 传了uin无token或token失效时:

    • 传了password则尝试密码登录
    • 不传password则尝试扫码登录 未传任何参数 则尝试扫码登录 掉线重连时也是自动调用此函数,走相同逻辑 你也可以在配置中修改reconn_interval,关闭掉线重连并自行处理

    Parameters

    • Optionaluin: number

      登录账号

    • Optionalpassword: string | Buffer

      可以为密码原文,或密码的md5值

    Returns Promise<void>

  • Parameters

    • matcher: Matcher
    • Optionallistener: Listener

    Returns void

  • 获取扫码结果(可定时查询,retcode为0则调用qrcodeLogin登录)

    Returns Promise<{
        retcode: number;
        t106: undefined | Buffer;
        t16a: undefined | Buffer;
        t318: undefined | Buffer;
        tgtgt: undefined | Buffer;
        uin: undefined | number;
    }>

  • 重载黑名单

    Returns Promise<void>

  • 重载好友列表

    Returns Promise<void>

  • 重载群列表

    Returns Promise<void>

  • 重新加载频道列表

    Returns Promise<void>

  • 重载陌生人列表

    Returns Promise<void>

  • 移除群精华消息 use Group.removeEssence

    Parameters

    • message_id: string

      消息id

    Returns Promise<string>

  • 重命名好友分组

    Parameters

    • id: number
    • name: string

    Returns Promise<void>

  • Parameters

    • group_id: number
    • content: string

    Returns Promise<boolean>

    use Group.announce

  • Parameters

    • group_id: number

    Returns Promise<{
        result: number;
    }>

    use Group.sign

  • Parameters

    • guild_id: string
    • channel_id: string
    • message: Sendable

    Returns Promise<GuildMessageRet>

    use Guild.sendMsg

  • Parameters

    • user_id: number
    • times: number = 1

    Returns Promise<boolean>

    use Friend.thumbUp

  • dont use it if not clear the usage

    Parameters

    • cmd: string
    • body: Uint8Array
    • timeout: number = 5

    Returns Promise<Buffer>

  • 发送一个业务包并等待返回

    Parameters

    • cmd: string
    • body: Uint8Array
    • timeout: number = 5

    Returns Promise<Buffer>

  • 设置头像

    Parameters

    • file: string | Buffer | Readable

    Returns Promise<void>

  • 设置生日

    Parameters

    • birthday: string | number

      YYYYMMDD格式的string(会过滤非数字字符)或number

    Returns Promise<boolean>

  • 设置个人说明

    Parameters

    • description: string = ""

    Returns Promise<boolean>

  • 添加群精华消息 use Group.addEssence

    Parameters

    • message_id: string

      消息id

    Returns Promise<string>

  • 设置性别

    Parameters

    • gender: 0 | 1 | 2

      0:未知,1:男,2:女

    Returns Promise<boolean>

  • Parameters

    • group_id: number
    • enable: boolean = true

    Returns Promise<boolean>

    use Group.allowAnony

  • Parameters

    • group_id: number
    • flag: string
    • duration: number = 1800

    Returns Promise<void>

    use Group.muteAnony

  • Parameters

    • group_id: number
    • user_id: number
    • reject_add_request: boolean = false
    • Optionalmessage: string

    Returns Promise<boolean>

  • Parameters

    • group_id: number

    Returns Promise<boolean>

    use Group.quit

  • 设置当前群成员消息屏蔽状态

    Parameters

    • group_id: number

      {number} 群号

    • member_id: number

      {number} 成员QQ号

    • OptionalisScreen: boolean

      {boolean} 是否屏蔽 默认true

    Returns Promise<boolean>

  • Parameters

    • group_id: number
    • name: string

    Returns Promise<boolean>

    use Group.setName

  • Parameters

    • group_id: number
    • file: string | Buffer | Readable

    Returns Promise<void>

    use Group.setAvatar

  • Parameters

    • group_id: number
    • user_id: number
    • special_title: string
    • duration: number = -1

    Returns Promise<boolean>

  • Parameters

    • group_id: number
    • enable: boolean = true

    Returns Promise<boolean>

    use Group.muteAll

  • 设置昵称

    Parameters

    • nickname: string

    Returns Promise<boolean>

  • Parameters

    • file: string | Buffer | Readable

    Returns Promise<void>

    use setAvatar

  • 设置个性签名

    Parameters

    • signature: string = ""

    Returns Promise<boolean>

  • Type Parameters

    Parameters

    Returns boolean

  • Type Parameters

    • S extends string | symbol

    Parameters

    • event: S & Exclude<S, keyof EventMap>
    • Rest...args: any[]

    Returns boolean

  • Parameters

    • matcher: Matcher
    • Rest...args: any[]

    Returns Promise<void>