nodewechat / wechat4u Goto Github PK
View Code? Open in Web Editor NEW微信 wechat web 网页版接口的 JavaScript 实现,兼容Node和浏览器,微信机器人
微信 wechat web 网页版接口的 JavaScript 实现,兼容Node和浏览器,微信机器人
wechat Error: read ECONNRESET
at exports._errnoException (util.js:890:11)
at TLSWrap.onread (net.js:554:26) +40s
wechat Error: 同步失败
at /wechat4u/wechat.js:559:13
at process._tickCallback (node.js:412:9) +0ms
wxbot Error: 同步失败
at /wechat4u/wechat.js:559:13
at process._tickCallback (node.js:412:9) +1ms
app 关闭注销连接 +322ms 0
wechat Receive +1s 0 Message
新连接 88
wechat Error: 扫描状态code错误: 408
at wechat4u/wechat.js:148:15
at process._tickCallback (node.js:412:9) +17s
wechat 启动失败 +1ms [Error: 获取扫描状态信息失败]
app 关闭登陆失败连接 +0ms 87
wechat WebSync Normal +12s
wechat:err
{ [Error: read ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }
getUUID:获取UUID失败
新连接 88
目前的调用方法:
sendImage(toUserName, fileData, fileType, fileSize)
fileData 可以为 node 中的 stream,buffer 以及浏览器中的文件和 Blob。
let imgPath = __dirname + '/../public/images/nodeWechat.png'
wechat.sendImage(user['UserName'], fs.createReadStream(imgPath)) // type , size 默认为 fs.stats 数据
let imgData = ...
let imgType = ... // 应该只有手动填
wechat.sendImage(user['UserName'], imgData, imgType) // size 默认为 imgData.length
wechat.sendImage(user['UserName'], fileInputElement.files[0]))
群usename 貌似是动态生成的
contacts里面又没有群信息
多谢
如题:如何下载头像和消息图片~
{
"Uin": 236008826,
"UserName": "@912d2268c7e87688e5c8f33003b488f3adcfd3b4d25fcb9a271550bfc18a7328",
"NickName": "膜法师",
"AttrStatus": 4357,
"PYInitial": "",
"PYQuanPin": "",
"RemarkPYInitial": "",
"RemarkPYQuanPin": "",
"MemberStatus": 0,
"DisplayName": "",
"KeyWord": ""
}
wechat CheckScan +430ms
wechat ReferenceError: debug is not defined
at /Users/wuhaiping/git/learning/new_weixin/wechatBot/node_modules/.npminstall/wechat4u/0.3.0/wechat4u/lib/utils.js:92:7
at String.replace (native)
at convertEmoji (/Users/wuhaiping/git/learning/new_weixin/wechatBot/node_modules/.npminstall/wechat4u/0.3.0/wechat4u/lib/utils.js:78:12)
at /Users/wuhaiping/git/learning/new_weixin/wechatBot/node_modules/.npminstall/wechat4u/0.3.0/wechat4u/lib/wechat.js:303:34
at process._tickCallback (node.js:406:9) +9s
wechat 启动失败 +5ms [Error: 获取通讯录失败]
app 关闭登陆失败连接 +2ms 1
app 新连接 +2s 2
wechat CheckScan +27ms
wechat Error: 扫描状态code错误: 408
at /Users/wuhaiping/git/learning/new_weixin/wechatBot/node_modules/.npminstall/wechat4u/0.3.0/wechat4u/lib/wechat.js:138:17
at process._tickCallback (node.js:406:9)
https://github.com/nodeWechat/wechat4u/blob/master/package.json#L7
这里的DEBUG=wxbot,wechat,app
去掉吧,改成手动设置
我想实现多个群的互转,尤其是语音
我在控制台看到每次收到一个消息message就触发了三次,这是什么原因?
core { status: 200, statusText: 'OK', headers: { server: 'nginx', date: 'Thu, 03 Nov 2016 16:21:56 GMT', 'content-length': '309', connection: 'close', 'access-control-allow-origin': '*' }, config: { adapter: [Function: httpAdapter], transformRequest: { '0': [Function: transformRequest] }, transformResponse: { '0': [Function: transformResponse] }, headers: { Accept: 'application/json, text/plain, /', 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.109 Safari/537.36', connection: 'close', cookie: 'pgv_pvi=1542490112; pgv_si=s1592886272; webwx_data_ticket=gSdlZSriZQ8t+H+YhSOFYl+2; wxuin=196358974; wxsid=CXPBwuyj7K6ZYT0p; wxloadtime=1478190086_expired; mm_lang=zh-CN; webwxuvid=a86bb6a5b873fdd6db550090476f0a092aac1e2a0b9b577859b8d975499112927ea5741957c02240ebdfc371d5d5a79a; webwx_auth_ticket=CIsBELrfzdIMGoABted3Tdrt2VQB/uwB1gigwUWCP2MG1gyMcc05jTJc7c22CZtqB5M/ZBIiXoI7DELgljWmJn/h8rk4+owaXw8MvEMFFwhEvDrsq2mMr2a5Hq7TKUeLlHoIZEEOFsroyCwktIrgkn92/mOz4NSWBiIialMSvqjTqf4P5IoNmDrr4UQ; wxpluginkey=1478167381', 'Content-Type': 'multipart/form-data; boundary=--------------------------858953728799556867126369' }, timeout: 0, xsrfCookieName: 'XSRF-TOKEN', xsrfHeaderName: 'X-XSRF-TOKEN', maxContentLength: -1, validateStatus: [Function: validateStatus], httpAgent: false, httpsAgent: false, method: 'POST', url: 'https://file.wx2.qq.com/cgi-bin/mmwebwx-bin/webwxuploadmedia', params: { f: 'json' }, data: FormData { _overheadLength: 1127, _valueLength: 116885, _lengthRetrievers: [], writable: false, readable: true, dataSize: 0, maxDataSize: 2097152, pauseStreams: true, _released: true, _streams: [], _currentStream: null, _boundary: '--------------------------858953728799556867126369', _events: {}, _eventsCount: 0 } }, request: ClientRequest { domain: null, _events: { error: [Object], prefinish: [Function: requestOnPrefinish] }, _eventsCount: 2, _maxListeners: undefined, output: [], outputEncodings: [], outputCallbacks: [], outputSize: 0, writable: true, _last: true, upgrading: false, chunkedEncoding: true, shouldKeepAlive: false, useChunkedEncodingByDefault: true, sendDate: false, _removedHeader: { connection: false }, _contentLength: null, _hasBody: true, _trailer: '', finished: true, _headerSent: true, socket: TLSSocket { _tlsOptions: [Object], _secureEstablished: true, _securePending: false, _newSessionPending: false, _controlReleased: true, _SNICallback: null, servername: null, npnProtocol: false, alpnProtocol: false, authorized: true, authorizationError: null, encrypted: true, _events: [Object], _eventsCount: 9, connecting: false, _hadError: false, _handle: null, _parent: null, _host: 'file.wx2.qq.com', _readableState: [Object], readable: false, domain: null, _maxListeners: undefined, _writableState: [Object], writable: false, allowHalfOpen: false, destroyed: true, _bytesDispatched: 119174, _sockname: null, _pendingData: null, _pendingEncoding: '', server: undefined, _server: null, ssl: null, _requestCert: true, _rejectUnauthorized: true, parser: null, _httpMessage: [Circular], read: [Function], _consuming: true, _idleNext: null, _idlePrev: null, _idleTimeout: -1 }, connection: TLSSocket { _tlsOptions: [Object], _secureEstablished: true, _securePending: false, _newSessionPending: false, _controlReleased: true, _SNICallback: null, servername: null, npnProtocol: false, alpnProtocol: false, authorized: true, authorizationError: null, encrypted: true, _events: [Object], _eventsCount: 9, connecting: false, _hadError: false, _handle: null, _parent: null, _host: 'file.wx2.qq.com', _readableState: [Object], readable: false, domain: null, _maxListeners: undefined, _writableState: [Object], writable: false, allowHalfOpen: false, destroyed: true, _bytesDispatched: 119174, _sockname: null, _pendingData: null, _pendingEncoding: '', server: undefined, _server: null, ssl: null, _requestCert: true, _rejectUnauthorized: true, parser: null, _httpMessage: [Circular], read: [Function], _consuming: true, _idleNext: null, _idlePrev: null, _idleTimeout: -1 }, _header: 'POST /cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json HTTP/1.1\r\nAccept: application/json, text/plain, /\r\nuser-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.109 Safari/537.36\r\nconnection: close\r\ncookie: pgv_pvi=1542490112; pgv_si=s1592886272; webwx_data_ticket=gSdlZSriZQ8t+H+YhSOFYl+2; wxuin=196358974; wxsid=CXPBwuyj7K6ZYT0p; wxloadtime=1478190086_expired; mm_lang=zh-CN; webwxuvid=a86bb6a5b873fdd6db550090476f0a092aac1e2a0b9b577859b8d975499112927ea5741957c02240ebdfc371d5d5a79a; webwx_auth_ticket=CIsBELrfzdIMGoABted3Tdrt2VQB/uwB1gigwUWCP2MG1gyMcc05jTJc7c22CZtqB5M/ZBIiXoI7DELgljWmJn/h8rk4+owaXw8MvEMFFwhEvDrsq2mMr2a5Hq7TKUeLlHoIZEEOFsroyCwktIrgkn92/mOz4NSWBiIialMSvqjTqf4P5IoNmDrr4UQ; wxpluginkey=1478167381\r\nContent-Type: multipart/form-data; boundary=--------------------------858953728799556867126369\r\nHost: file.wx2.qq.com\r\nTransfer-Encoding: chunked\r\n\r\n', _headers: { accept: 'application/json, text/plain, /', 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.109 Safari/537.36', connection: 'close', cookie: 'pgv_pvi=1542490112; pgv_si=s1592886272; webwx_data_ticket=gSdlZSriZQ8t+H+YhSOFYl+2; wxuin=196358974; wxsid=CXPBwuyj7K6ZYT0p; wxloadtime=1478190086_expired; mm_lang=zh-CN; webwxuvid=a86bb6a5b873fdd6db550090476f0a092aac1e2a0b9b577859b8d975499112927ea5741957c02240ebdfc371d5d5a79a; webwx_auth_ticket=CIsBELrfzdIMGoABted3Tdrt2VQB/uwB1gigwUWCP2MG1gyMcc05jTJc7c22CZtqB5M/ZBIiXoI7DELgljWmJn/h8rk4+owaXw8MvEMFFwhEvDrsq2mMr2a5Hq7TKUeLlHoIZEEOFsroyCwktIrgkn92/mOz4NSWBiIialMSvqjTqf4P5IoNmDrr4UQ; wxpluginkey=1478167381', 'content-type': 'multipart/form-data; boundary=--------------------------858953728799556867126369', host: 'file.wx2.qq.com' }, _headerNames: { accept: 'Accept', 'user-agent': 'user-agent', connection: 'connection', cookie: 'cookie', 'content-type': 'Content-Type', host: 'Host' }, _onPendingData: null, agent: Agent { domain: null, _events: [Object], _eventsCount: 1, _maxListeners: undefined, defaultPort: 443, protocol: 'https:', options: [Object], requests: {}, sockets: [Object], freeSockets: {}, keepAliveMsecs: 1000, keepAlive: false, maxSockets: Infinity, maxFreeSockets: 256, maxCachedSessions: 100, _sessionCache: [Object] }, socketPath: undefined, timeout: undefined, method: 'POST', path: '/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json', _ended: true, parser: null, res: IncomingMessage { _readableState: [Object], readable: false, domain: null, _events: [Object], _eventsCount: 3, _maxListeners: undefined, socket: [Object], connection: [Object], httpVersionMajor: 1, httpVersionMinor: 1, httpVersion: '1.1', complete: true, headers: [Object], rawHeaders: [Object], trailers: {}, rawTrailers: [], upgrade: false, url: '', method: null, statusCode: 200, statusMessage: 'OK', client: [Object], _consuming: true, _dumped: false, req: [Circular], fetchedUrls: [Object], read: [Function] } }, data: { BaseResponse: { Ret: 1205, ErrMsg: '' }, MediaId: '@crypt_710c07a2_9c10181e10d5059ca0c8c058d32a48e791e8d6d75247f8b28748e3a6593040a3ac5883c41a883c064dc3df3e2cf8b1eaaa48ff0da1b0d6a57e70fd97d25dbf9ba7bb0f880eb9299513e7407262b2414f', StartPos: 116499, CDNThumbImgHeight: 0, CDNThumbImgWidth: 0 } } +982ms
Error: 上传媒体文件失败
无法登陆了 扫了就显示登录超时 已经不能用了吗?
如何保持长连接?保持登录后的微信用户在wechat4u node端一直在线。可以接收联系人发送来的信息
bot.uploadMedia(fs.createReadStream('./media/test.png'))
.then(res => {
return bot.sendEmoticon(res.mediaId, msg.FromUserName)
})
.catch(err => {
console.log(err)
})
例如将 https://www.baidu.com/img/bd_logo1.png 上传至微信并发送此表情。
我发一个表情给自己,表情包的那种,或者图片等均出现狂刷的情况
好像没有办法过滤公众号或者服务号?
哎,有点乱啊
如题,会报TypeError: Parameter 'url' must be a string, not undefined错误。请问这么处理呢?经常性的
有遇到的记录一下。
现在人数多一点加群就需要确认了,如何用 wechat4u 自动确认呢?
rt
如题。如果能有个什么MySQL支持那就更好了╮(╯▽╰)╭
core Error: socket hang up
at createHangUpError (_http_client.js:253:15)
at TLSSocket.socketOnEnd (_http_client.js:345:23)
at emitNone (events.js:91:20)
at TLSSocket.emit (events.js:185:7)
at endReadableNT (_stream_readable.js:974:12)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9) +45s
这个 error会导致程序崩掉,是什么原因造成的
ERROR in ./~/.0.4.0@wechat4u/lib/wechat.js Module not found: Error: Can't resolve 'fs' in ‘\Chrome\node_modules.0.4.0@wechat4u\lib'
现在是不支持浏览器了吗?我切换到^0.2.5可以
issue 发在这里有点不合适啊,不过也算作 voice-message 和 image-message 事件的 example 吧。展示下能够做到的功能。
大概记录下思路:
语音识别:暂时没找到直接可以处理 MP3 编码的语音识别模块,大致思路是转换成 wav 或其他原始编码,再对接相关 API 获得识别内容。前者可以通过 ffmpeg 或 sox 转换,应该都有 node 的模块,API 目前觉得 baidu 和 google 的各有利弊,再看看吧。
图片特征描述提取: 暂时就考虑用 node-tesseract 和 百度识图 吧
应该logout()下
如题
wechat Error: connect ETIMEDOUT 101.226.76.164:443
at Object.exports._errnoException (util.js:856:11)
at exports._exceptionWithHostPort (util.js:879:20)
at TCPConnectWrap.afterConnect as oncomplete +9s
wechat Error: connect ETIMEDOUT 101.226.76.164:443
at Object.exports._errnoException (util.js:856:11)
at exports._exceptionWithHostPort (util.js:879:20)
at TCPConnectWrap.afterConnect as oncomplete +9s
wechat Error: 同步失败
at /Users/wuhaiping/git/learning/new_weixin/wechatBot/node_modules/wechat4u/lib/wechat.js:594:15
at process._tickCallback (node.js:406:9) +0ms
wxbot Error: 同步失败
at /Users/wuhaiping/git/learning/new_weixin/wechatBot/node_modules/wechat4u/lib/wechat.js:594:15
at process._tickCallback (node.js:406:9) +1ms
app 关闭注销连接 +487ms 0
我用亚马逊的EC2部署时,发现调用一次sendMsg,有时重复发送消息多次(2次、3次不等),而在自己的国内电脑上就不会
https://github.com/nodeWechat/wechat4u/blob/master/src/wechat.js#L324
syncPolling () {
this._syncCheck().then(state => {
if (state.retcode !== CONF.SYNCCHECK_RET_SUCCESS) {
throw new Error('你登出了微信')
} else {
if (state.selector !== CONF.SYNCCHECK_SELECTOR_NORMAL) {
return this._sync().then(data => {
setTimeout(() => {
this.syncPolling()
}, 1000)
this._handleMsg(data)
})
} else {
debug('WebSync Normal')
setTimeout(() => {
this.syncPolling()
}, 1000)
}
}
}).catch(err => {
if (++this.syncErrorCount > 3) {
debug(err)
this.emit('error', err)
this.logout()
} else {
setTimeout(() => {
this.syncPolling()
}, 1000)
}
})
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.