Skip to content

Commit

Permalink
v0.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
joehecn committed Nov 8, 2017
1 parent 29cc2e7 commit c7da095
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 31 deletions.
36 changes: 26 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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).
6 changes: 3 additions & 3 deletions build/github/latest-mac.json
Original file line number Diff line number Diff line change
@@ -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"
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "j",
"version": "v0.0.7",
"version": "v0.0.8",
"author": "joehe <leanbrown@live.cn>",
"description": "An electron-vue project",
"main": "./dist/electron/main.js",
Expand Down
5 changes: 5 additions & 0 deletions src/renderer/jbot/daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -45,13 +46,16 @@ 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)

// 新消息
if (res[1] === '2') {
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:
Expand All @@ -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)
Expand Down
15 changes: 10 additions & 5 deletions src/renderer/jbot/img.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
41 changes: 29 additions & 12 deletions src/renderer/jbot/wbwx.js
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand All @@ -54,6 +69,7 @@ const _getDeviceID = () => {
}

const _parseString = str => {
console.log(str)
return new Promise((resolve, reject) => {
parseString(str, {
explicitArray: false
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -160,7 +177,7 @@ export const login = async (uuid, tip) => {
</error> */
// 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
Expand Down Expand Up @@ -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(),
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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',
Expand Down Expand Up @@ -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,
Expand All @@ -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: {
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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)
})
Expand Down

0 comments on commit c7da095

Please sign in to comment.