diff --git a/README.md b/README.md index 492aee5..db6eaa1 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,21 @@ + +[![Dependency Status](https://gemnasium.com/badges/github.com/joehecn/j.svg)](https://gemnasium.com/github.com/joehecn/j) + # j -> An electron-vue project +> 微信个人桌面机器人 +- 微信网页版 API +- electron-vue -#### Build Setup +## 介绍 +微信个人网页版API的微信机器人, github 上有很多轮子了,来一个 electron-vue 版的 +## 安装 +Windows, MacOS 两个版本 +## 功能 +- 自动回复 +- 群发 +## 开发 +### Build Setup ``` bash # install dependencies @@ -25,17 +38,20 @@ npm run lint --- -This project was generated with [electron-vue](https://github.com/SimulatedGREG/electron-vue)@[de85f81](https://github.com/SimulatedGREG/electron-vue/tree/de85f81890c01500113738bfe57bef136f9fbf52) using [vue-cli](https://github.com/vuejs/vue-cli). Documentation about the original structure can be found [here](https://simulatedgreg.gitbooks.io/electron-vue/content/index.html). - - -# TODOS +## 问题 +欢迎 issues +## 更新 - [x] 名单选中状态加深对比度 v0.0.2 - [x] 消息发送完成后清空消息框 v0.0.3 - [x] 没有选择组时,不显示 tabs v0.0.3 - [x] 显示版本号 v0.0.4 - [ ] 导出好友列表完成后通知消息 - 暂时没有好办法?托盘? - [x] 软件版本更新提示 github api v0.0.5 -- [x] 构建 Windows 版本 -- [x] F 修复 Windows 下侧边栏太窄添加按钮显示不全的问题 -- [x] N 新增 群 -- [x] N 新增 发送图片 +- [x] 构建 Windows 版本 v0.0.6 +- [x] F 修复 Windows 下侧边栏太窄添加按钮显示不全的问题 v0.0.6 +- [x] N 新增 群 v0.0.7 +- [x] N 新增 发送图片 v0.0.7 +- [x] F 修复 login 200 重定向动态域名 v0.0.8 + +## 依赖 +This project was generated with [electron-vue](https://github.com/SimulatedGREG/electron-vue)@[de85f81](https://github.com/SimulatedGREG/electron-vue/tree/de85f81890c01500113738bfe57bef136f9fbf52) using [vue-cli](https://github.com/vuejs/vue-cli). Documentation about the original structure can be found [here](https://simulatedgreg.gitbooks.io/electron-vue/content/index.html). diff --git a/build/github/latest-mac.json b/build/github/latest-mac.json index a9292f1..007ceba 100644 --- a/build/github/latest-mac.json +++ b/build/github/latest-mac.json @@ -1,5 +1,5 @@ { - "version": "0.0.7", - "releaseDate": "2017-11-07T09:15:06.121Z", - "url": "https://github.com/joehecn/j/releases/download/v0.0.7/j-0.0.7-mac.zip" + "version": "0.0.8", + "releaseDate": "2017-11-08T03:47:04.055Z", + "url": "https://github.com/joehecn/j/releases/download/v0.0.8/j-0.0.8-mac.zip" } diff --git a/package.json b/package.json index b187c09..fbd0e3c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "j", - "version": "v0.0.7", + "version": "v0.0.8", "author": "joehe ", "description": "An electron-vue project", "main": "./dist/electron/main.js", diff --git a/src/renderer/jbot/daemon.js b/src/renderer/jbot/daemon.js index 36b185b..f56daf0 100644 --- a/src/renderer/jbot/daemon.js +++ b/src/renderer/jbot/daemon.js @@ -33,6 +33,7 @@ export default new class Daemon extends Emitter { ctx.webwxDataTicket = webwxDataTicket let res = await webwxinit(ctx.BaseRequest, ctx.codes[1].lang, ctx.passTicket) + console.log(res) ctx.SyncKey = res.SyncKey ctx.User = res.User @@ -45,6 +46,7 @@ export default new class Daemon extends Emitter { this.emit('on_memberlist', res.MemberList) while (true) { + console.log('心跳') res = await synccheck(ctx.BaseRequest, ctx.SyncKey.List) // 新消息 @@ -52,6 +54,8 @@ export default new class Daemon extends Emitter { res = await webwxsync(ctx.BaseRequest, ctx.codes[1].lang, ctx.SyncKey) ctx.SyncKey = res.SyncKey res.AddMsgList.forEach(item => { + console.log(item.MsgType) + console.log(item.StatusNotifyUserName) switch (item.MsgType) { // 文本消息 case 1: @@ -64,6 +68,7 @@ export default new class Daemon extends Emitter { // 在 StatusNotifyUserName 获取群 if (item.StatusNotifyUserName) { const List = getList(item.StatusNotifyUserName) + console.log(List) if (List.length > 0) { webwxbatchgetcontact(ctx.BaseRequest, ctx.codes[1].lang, ctx.passTicket, List).then(ContactList => { this.emit('on_batchlist', ContactList) diff --git a/src/renderer/jbot/img.js b/src/renderer/jbot/img.js index 9cf6283..c59ede4 100644 --- a/src/renderer/jbot/img.js +++ b/src/renderer/jbot/img.js @@ -9,10 +9,15 @@ export const getImg = async url => { return imgs[url] } // console.log('get img from 微信') - const res = await coverBase64(url) - if (res) { - imgs[url] = res - } - return res + try { + const res = await coverBase64(url) + if (res) { + imgs[url] = res + } + + return res + } catch (e) { + console.log(e) + } } diff --git a/src/renderer/jbot/wbwx.js b/src/renderer/jbot/wbwx.js index ff4bde4..aeeb80f 100644 --- a/src/renderer/jbot/wbwx.js +++ b/src/renderer/jbot/wbwx.js @@ -45,6 +45,21 @@ import { URL } from 'url' import { parseString } from 'xml2js' // import FormData from 'form-data' +// `https://login.wx2.qq.com/jslogin` +// `https://login.wx2.qq.com/cgi-bin/mmwebwx-bin/login` +// `https://${_host}/cgi-bin/mmwebwx-bin/webwxnewloginpage` +// `https://${_host}/cgi-bin/mmwebwx-bin/webwxinit` +// `https://${_host}/cgi-bin/mmwebwx-bin/webwxstatusnotify` +// `https://${_host}/cgi-bin/mmwebwx-bin/webwxgetcontact` +// `https://webpush.${_host}/cgi-bin/mmwebwx-bin/synccheck` +// `https://${_host}/cgi-bin/mmwebwx-bin/webwxsync` +// `https://${_host}/cgi-bin/mmwebwx-bin/webwxbatchgetcontact` +// `https://${_host}/cgi-bin/mmwebwx-bin/webwxsendmsg` +// `https://file.${_host}/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json` +// `https://${_host}/cgi-bin/mmwebwx-bin/webwxsendmsgimg` +// `https://${_host}` +let _host = '' + let j = RPN.jar() const rpn = RPN.defaults({jar: j}) @@ -54,6 +69,7 @@ const _getDeviceID = () => { } const _parseString = str => { + console.log(str) return new Promise((resolve, reject) => { parseString(str, { explicitArray: false @@ -127,7 +143,8 @@ export const login = async (uuid, tip) => { const arr2 = res.match(/window.redirect_uri="(\S+?)";/) if (arr2 && arr2[1]) { const u = new URL(arr2[1]) - + console.log(u) + _host = u.host codes[1].ticket = u.searchParams.get('ticket') codes[1].uuid = uuid codes[1].lang = u.searchParams.get('lang') @@ -160,7 +177,7 @@ export const login = async (uuid, tip) => { */ // webwx_data_ticket: webwxDataTicket export const webwxnewloginpage = async qs => { - const url = 'https://wx2.qq.com/cgi-bin/mmwebwx-bin/webwxnewloginpage' + const url = `https://${_host}/cgi-bin/mmwebwx-bin/webwxnewloginpage` const res = await rpn({ url, qs @@ -198,7 +215,7 @@ export const webwxnewloginpage = async qs => { export const webwxinit = async (BaseRequest, lang, passTicket) => { BaseRequest.DeviceID = _getDeviceID() const res = await rpn({ - url: 'https://wx2.qq.com/cgi-bin/mmwebwx-bin/webwxinit', + url: `https://${_host}/cgi-bin/mmwebwx-bin/webwxinit`, method: 'POST', qs: { r: ~new Date(), @@ -224,7 +241,7 @@ export const webwxinit = async (BaseRequest, lang, passTicket) => { export const webwxstatusnotify = async (BaseRequest, lang, passTicket, userName) => { BaseRequest.DeviceID = _getDeviceID() const res = await rpn({ - url: 'https://wx2.qq.com/cgi-bin/mmwebwx-bin/webwxstatusnotify', + url: `https://${_host}/cgi-bin/mmwebwx-bin/webwxstatusnotify`, method: 'POST', qs: { lang, @@ -291,7 +308,7 @@ export const webwxstatusnotify = async (BaseRequest, lang, passTicket, userName) */ export const webwxgetcontact = async (lang, passTicket, skey) => { const res = await rpn({ - url: 'https://wx2.qq.com/cgi-bin/mmwebwx-bin/webwxgetcontact', + url: `https://${_host}/cgi-bin/mmwebwx-bin/webwxgetcontact`, qs: { lang, pass_ticket: passTicket, @@ -323,7 +340,7 @@ export const synccheck = async (BaseRequest, list) => { let res try { res = await rpn({ - url: 'https://webpush.wx2.qq.com/cgi-bin/mmwebwx-bin/synccheck', + url: `https://webpush.${_host}/cgi-bin/mmwebwx-bin/synccheck`, qs: { r: Date.now(), skey: BaseRequest.Skey, @@ -392,7 +409,7 @@ export const synccheck = async (BaseRequest, list) => { export const webwxsync = async (BaseRequest, lang, SyncKey) => { BaseRequest.DeviceID = _getDeviceID() const res = await rpn({ - url: 'https://wx2.qq.com/cgi-bin/mmwebwx-bin/webwxsync', + url: `https://${_host}/cgi-bin/mmwebwx-bin/webwxsync`, method: 'POST', qs: { sid: BaseRequest.Sid, @@ -417,7 +434,7 @@ export const webwxsync = async (BaseRequest, lang, SyncKey) => { export const webwxbatchgetcontact = async (BaseRequest, lang, passTicket, List) => { BaseRequest.DeviceID = _getDeviceID() const res = await rpn({ - url: 'https://wx2.qq.com/cgi-bin/mmwebwx-bin/webwxbatchgetcontact', + url: `https://${_host}/cgi-bin/mmwebwx-bin/webwxbatchgetcontact`, method: 'POST', qs: { type: 'ex', @@ -478,7 +495,7 @@ export const webwxbatchgetcontact = async (BaseRequest, lang, passTicket, List) export const webwxsendmsg = async (BaseRequest, lang, passTicket, Msg) => { BaseRequest.DeviceID = _getDeviceID() const res = await rpn({ - url: 'https://wx2.qq.com/cgi-bin/mmwebwx-bin/webwxsendmsg', + url: `https://${_host}/cgi-bin/mmwebwx-bin/webwxsendmsg`, method: 'POST', qs: { lang, @@ -505,7 +522,7 @@ export const webwxsendmsg = async (BaseRequest, lang, passTicket, Msg) => { export const webwxuploadmedia = async (BaseRequest, passTicket, webwxDataTicket, file, FileMd5, buf, Msg) => { BaseRequest.DeviceID = _getDeviceID() const res = await rpn({ - url: 'https://file.wx2.qq.com/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json', + url: `https://file.${_host}/cgi-bin/mmwebwx-bin/webwxuploadmedia?f=json`, method: 'POST', json: true, formData: { @@ -549,7 +566,7 @@ export const webwxuploadmedia = async (BaseRequest, passTicket, webwxDataTicket, export const webwxsendmsgimg = async (BaseRequest, passTicket, Msg) => { BaseRequest.DeviceID = _getDeviceID() const res = await rpn({ - url: 'https://wx2.qq.com/cgi-bin/mmwebwx-bin/webwxsendmsgimg', + url: `https://${_host}/cgi-bin/mmwebwx-bin/webwxsendmsgimg`, method: 'POST', qs: { fun: 'async', @@ -595,7 +612,7 @@ export const coverBase64 = url => { resolve(data) }) - rpn(`https://wx2.qq.com${url}`).on('response', response => { + rpn(`https://${_host}${url}`).on('response', response => { type = response.headers['content-type'] // 'image/png' }).pipe(ws) })