Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/AvengersWeChat/PadChat-SDK
/ functions
Functions
80 in github.com/AvengersWeChat/PadChat-SDK
⨍
Functions
80
◇
Types & classes
2
↓ 64 callers
Method
sendCmd
* 包装ws发送指令数据包 * * @param {string} cmd - 要操作的接口 * @param {object} data - 要发送的数据 * @returns {Promise<object>} 返回ws处理结果 * @private * @membero
index.js:218
↓ 3 callers
Method
login
* 登录账号 * 首次登录不需要传入`wxData`,登陆成功后本地保存`wxData`和`token`,以后使用断线重连或二次登陆,可降低封号概率。 * 任何登陆方式,使用成功登陆过的`wxData`都可降低封号概率。 * * @param {string} type - 登录类型
index.js:331
↓ 3 callers
Method
syncContact
* 同步通讯录 * * 使用此接口可以触发同步通讯录,如果设置`reset`为`true`,则在通讯录同步完毕后触发`loaded`事件 * * @param {boolean} [reset=false] 是否重置通讯录加载完毕状态 * @returns {Promise<ob
index.js:475
↓ 2 callers
Function
saveAutoData
* @description 保存自动登陆数据
demo.js:356
↓ 2 callers
Method
sendMsg
* 发送文字信息 * * @param {string} toUserName - 接收者的wxid * @param {string} content - 内容文本 * @param {Array<string>} [atList=[]] - 向群内发信息时,要@的用户wxid数组
index.js:548
↓ 2 callers
Method
start
* 启动websocket连接 * * @memberof Padchat
index.js:80
↓ 2 callers
Method
syncMsg
* 同步消息 * * 使用此接口手动触发同步消息,一般用于刚登陆后调用,可立即开始同步消息。 * 否则会在有新消息时才开始同步消息。 * * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * @memberof
index.js:462
↓ 1 callers
Method
_send
* ws发送数据 * * @param {object} data - 数据 * @returns {Promise<object>} 返回ws处理结果 * @private * @memberof Padchat
index.js:160
↓ 1 callers
Method
asyncSend
* 包装ws发送数据 * * @param {object} data - 要发送的数据 * @param {number} timeout - 发送超时时间 * @returns {Promise<object>} 返回ws处理结果 * @private * @member
index.js:184
↓ 1 callers
Function
clearRawMsg
* 清除消息结构中多余字段 * * @param {object} obj - 要处理的数据结构 * @private * @returns {object}
index.js:2981
↓ 1 callers
Method
getLoginToken
* 获取二次登陆数据 * * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * ``` { error : '', success: true, data : {
index.js:410
↓ 1 callers
Method
getMsgImage
* 获取消息原始图片 * * 在push事件中收到的data数据是缩略图图片数据,使用本接口获取原图数据 * * @param {object} rawMsgData - 推送的消息结构体,即`push`事件中收到的Object * @returns {Promise<objec
index.js:755
↓ 1 callers
Method
getMsgVideo
* 获取消息原始视频 * * 在push事件中只获得推送通知,不包含视频数据,需要使用本接口获取视频文件数据 * * @param {object} rawMsgData - 推送的消息结构体,即`push`事件中收到的Object * @returns {Promise<obj
index.js:783
↓ 1 callers
Method
getMsgVoice
* 获取消息语音数据 * * 这个接口获取到的与push事件中接收到的数据一致,是base64编码的silk格式语音数据 * * BUG: 超过60Kb的语音数据,只能拉取到60Kb,也就是说大约36~40秒以上的语音会丢失后边部分语音内容 * * @param {objec
index.js:812
↓ 1 callers
Method
getMyInfo
* 获取微信号信息 * * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * ``` { error : '', success: true, data: { use
index.js:431
↓ 1 callers
Method
getWxData
* 获取设备62数据 * * 事实上,只要你有一次登陆成功,以后一直用这个62数据,不需要更换。 * * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * ``` { error: '', success
index.js:387
↓ 1 callers
Method
init
* 初始化 * * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * ``` { error : '', success: true } * ``` * @memberof Padchat
index.js:252
↓ 1 callers
Function
onMsg
(data)
demo.js:378
↓ 1 callers
Method
sendImage
* 发送图片消息 * * @param {string} toUserName - 接收者的wxid * @param {Buffer|string} file - 图片Buffer数据或base64 * @returns {Promise<object>} 返回Promise<ob
index.js:691
↓ 1 callers
Method
sendVoice
* 发送语音消息 * 注意:只能发送silk格式的语音文件 * * @param {string} toUserName - 接收者的wxid * @param {Buffer|string} file - 语音Buffer数据或base64 * @param {number}
index.js:723
Method
acceptTransfer
* 接受转账 * * @param {object} rawMsgData - 推送的消息结构体,即`push`事件中收到的Object * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * ``` { su
index.js:1902
Method
acceptUser
* 通过好友验证 * * @param {string} stranger - 用户stranger数据 * @param {string} ticket - 用户ticket数据 * @returns {Promise<object>} 返回Promise<object>,注意捕捉
index.js:1231
Method
addContact
* 添加好友 * * @param {string} stranger - 用户stranger数据 * @param {string} ticket - 用户ticket数据 * @param {Number} type - 添加好友途径 <br> `0` : 通过微信号搜索
index.js:1269
Method
addFav
* 添加收藏 * * @param {string} content - 内容文本 * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * @memberof Padchat
index.js:1643
Method
addLabel
* 添加标签 * * @param {string} label - 标签名称 * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * ``` { success: true, data : {
index.js:1767
Method
addRoomMember
* 添加群成员 * * @param {string} groupId - 群id * @param {string} userId - 用户wxid * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * ```
index.js:897
Method
close
* 关闭微信实例(不退出登陆) * * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * @memberof Padchat
index.js:262
Method
closePush
* 关闭推送 * * @description 仅用于开发调试,不需要使用 * @private * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * @memberof Padchat
index.js:500
Method
constructor
* Creates an instance of Padchat. * @param {string} [url] - 服务器url,后缀你的token:`ws://127.0.0.1:7777/{YourToken}` * 如:`ws://127.0.0.1:7777/mytoken_
index.js:55
Method
createRoom
* 创建群 * * 注意:如果有用户存在问题不能进群,则会建群失败。 * 但判断是否成功应以`userName`字段 * * @param {string[]} userList - 用户wxid数组 * @returns {Promise<object>} 返回Promis
index.js:839
Method
deleteContact
* 删除好友 * * @param {string} userId - 用户wxid * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * ``` { success: true, data :
index.js:1180
Method
deleteFav
* 删除收藏 * * @param {Number} favId - 收藏id * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * ``` { success: true, data :
index.js:1718
Method
deleteLabel
* 删除标签 * * @param {string} labelId - 标签id,注意是id是string类型 * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * ``` { success: true,
index.js:1789
Method
deleteRoomMember
* 删除群成员 * * @param {string} groupId - 群id * @param {string} userId - 用户wxid * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * ```
index.js:946
Method
dumpWxuser
* @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * @private * @memberof Padchat
index.js:668
Function
getCmdRecv
* 等待指定cmdId返回 * * @param {string} cmdId - 要监听的cmdId * @param {number} [timeout=3000] 超时时间默认为3秒 * @private * @returns {Promise<object>}
index.js:2488
Method
getContact
* 获取用户/群信息 * * @param {string} userId - 用户wxid/群id * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * * 微信用户/公众号返回: * * ``` {
index.js:1122
Method
getContactQrcode
* 获取用户二维码 * 仅限获取自己的二维码,无法获取其他人的二维码 * * @param {string} userId - 用户wxid * @param {Number} style - 二维码风格。可用范围0-3 * @returns {Promise<object>}
index.js:1207
Method
getFav
* 获取收藏消息详情 * * @param {Number} favId - 收藏id * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * ``` { success: true, data :
index.js:1684
Method
getLabelList
* 获取所有标签 * * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * ``` { success: true, data : { label: //标签列表
index.js:1747
Method
getRequestToken
* 获取网页访问授权 * * @param {string} ghName - 公众号gh名称,即`gh_`格式的id * @param {string} url - 网页url * @returns {Promise<object>} 返回Promise<object>,注意捕捉c
index.js:2444
Method
getRoomMembers
* 获取群成员信息 * * @param {string} groupId - 群id * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * ``` { success: true, data :
index.js:874
Method
getRoomQrcode
* 获取微信群二维码 * * @param {string} groupId - 群id * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * ``` { success: true, data
index.js:1042
Method
getSubscriptionInfo
* 获取公众号信息 * * @param {string} ghName - 公众号gh名称,即`gh_`格式的id * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * ``` { success: tru
index.js:2385
Method
heartBeat
* 启动心跳 * * @description 仅用于开发调试,不需要使用 * @private * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * @memberof Padchat
index.js:512
Method
inviteRoomMember
* 邀请群成员 * 会给对方发送一条邀请消息,无法判断对方是否真的接收到 * * @param {string} groupId - 群id * @param {string} userId - 用户wxid * @returns {Promise<object>} 返回Prom
index.js:922
Method
logout
* 退出登录 * * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * @memberof Padchat
index.js:488
Method
massMsg
* 群发文字信息 * * FIXME: 此接口有问题,暂停使用 * * @param {Array<string>} [userList=[]] - 接收者wxid数组 * @param {string} content - 内容文本 * @returns {Promise<
index.js:574
Function
onWsMsg
* 加工处理ws接收到的数据 * * @param {string} msg - ws连接接收到的文本消息 * @private
index.js:2516
Method
openRedPacket
* 领取红包 * * @param {object} rawMsgData - 推送的消息结构体,即`push`事件中收到的Object * @param {string} key - 红包的验证key,通过调用 receiveRedPacket 获得 * @returns {Pro
index.js:2157
Method
operateSubscription
* 操作公众号菜单 * * @param {string} ghName - 公众号gh名称,即`gh_`格式的id * @param {Number} menuId - 菜单id * @param {string} menuKey - 菜单key * @returns {Pro
index.js:2409
Method
queryRedPacket
* 查看红包信息 * NOTE: 如果是别人发的红包,未领取且未领取完毕时,无法取到红包信息 * * @param {object} rawMsgData - 推送的消息结构体,即`push`事件中收到的Object * @param {Number} [index=0] - 列表索
index.js:2062
Method
queryTransfer
* 查看转账消息 * * @param {object} rawMsgData - 推送的消息结构体,即`push`事件中收到的Object * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * ``` {
index.js:1869
Method
quitRoom
* 退出群 * * @param {string} groupId - 群id * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * ``` { success: true, data : {
index.js:969
Method
receiveRedPacket
* 接收红包 * * @param {object} rawMsgData - 推送的消息结构体,即`push`事件中收到的Object * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * ``` { su
index.js:1951
Method
requestUrl
* 访问网页 * * @param {string} url - 网页url地址 * @param {string} xKey - 访问Key,用`getRequestToken`获取 * @param {string} xUin - 访问uin,用`getRequestToken`
index.js:2472
Method
sayHello
* 打招呼 * 如果已经是好友,会收到由系统自动发送,来自对方的一条文本信息 * “xx已通过你的朋友验证请求,现在可以开始聊天了” * * @param {string} stranger - 用户stranger数据 * @param {string} ticket - 用户
index.js:1298
Method
searchContact
* 搜索用户 * 可用此接口来判断是否已经加对方为好友 * * @param {string} userId - 用户wxid * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * ``` { succe
index.js:1158
Method
searchMp
* 搜索公众号 * * @param {string} content - 公众号名称等关键字 * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * ``` { success: true, data
index.js:2279
Method
sendAppMsg
* 发送App消息(含小程序) * * @param {string} toUserName - 接收者的wxid * @param {object|string} content - app消息体文本(appmsg xml结构) * @param {object} object -
index.js:623
Method
setHeadImg
* 设置头像 * * @param {Buffer|string} file - 图片Buffer数据或base64 * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * ``` { success:
index.js:1351
Method
setLabel
* 设置用户标签 * * @param {string} userId - 用户wxid * @param {string} labelId - 标签id * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * ```
index.js:1812
Method
setRemark
* 设置备注 * * @param {string} userId - 用户wxid * @param {string} remark - 备注名称 * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * ```
index.js:1323
Method
setRoomAnnouncement
* 设置群公告 * * @param {string} groupId - 群id * @param {string} content - 群公告内容 * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * ```
index.js:992
Method
setRoomName
* 设置群名称 * * @param {string} groupId - 群id * @param {string} content - 群名称 * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * ``` {
index.js:1016
Method
setSyncContact
* 设置是否同步联系人 * * @memberof Padchat
index.js:440
Method
setSyncMsg
* 设置是否同步消息 * * @memberof Padchat
index.js:449
Method
shareCard
* 分享名片 * * @param {string} toUserName - 接收者的wxid * @param {string} content - 内容文本 * @param {string} userId - 被分享人wxid * @returns {Promise<ob
index.js:655
Method
snsComment
* 评论朋友圈 * * @param {string} userId - 用户wxid * @param {string} momentId - 朋友圈信息id * @param {string} content - 内容文本 * @returns {Promise<object
index.js:1566
Method
snsGetObject
* 获取朋友圈信息详情 * * @param {string} momentId - 朋友圈信息id * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * ``` { success: true, d
index.js:1540
Method
snsLike
* 朋友圈点赞 * * @param {string} userId - 用户wxid * @param {string} momentId - 朋友圈信息id * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch *
index.js:1592
Method
snsSendMoment
* 发朋友圈 * * @param {string} content - 文本内容或`Timelineobject`结构体文本 * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * ``` { success
index.js:1447
Method
snsTimeline
* 查看朋友圈动态 * * @param {string} [momentId=''] - 朋友圈信息id * 首次传入空即获取第一页,以后传入上次拉取的最后一条信息id * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch
index.js:1517
Method
snsUpload
* 上传图片到朋友圈 * NOTE: 此接口只能上传图片,并不会将图片发到朋友圈中 * * @param {Buffer|string} file - 图片Buffer数据或base64 * @returns {Promise<object>} 返回Promise<object>,注
index.js:1384
Method
snsUserPage
* 查看用户朋友圈 * * @param {string} userId - 用户wxid * @param {string} [momentId=''] - 朋友圈信息id * 首次传入空即获取第一页,以后传入上次拉取的最后一条信息id * @returns {Promise<
index.js:1482
Method
snsobjectOp
* 操作朋友圈 * * @param {string} momentId - 朋友圈信息id * @param {Number} type - 操作类型,1为删除朋友圈,4为删除评论,5为取消赞 * @param {Number} commentId - 操作类型,当type为4时,
index.js:1412
Function
structureXml
* 组装appmsg消息体 * * @param {object} object 消息体参数 * @param {object} [object.appid] - appid,忽略即可 * @param {object} [object.sdkver] - sdk版本,忽略即可 * @pa
helper.js:91
Method
syncFav
* 同步收藏消息 * * @param {string} [favKey=''] - 同步key,首次不用传入 * @returns {Promise<object>} 返回Promise<object>,注意捕捉catch * ``` { success: true,
index.js:1630
Function
toCamelCase
* 将object中的属性名称从下划线转换为驼峰格式 * (包含子数据的属性名,会遍历转换) * * @param {any} obj 要转换的object * @param {boolean} [big=true] 是否转换为大驼峰格式 * @returns {Object} 转换后的o
helper.js:20
Function
toUnderLine
* 将object中的属性名称从驼峰转换为下划线格式 * * @param {any} obj 要转换的object * @returns {Object} 转换后的object
helper.js:55