Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.Veneno.
wechaty
提交
9a50ec40
W
wechaty
项目概览
.Veneno.
/
wechaty
与 Fork 源项目一致
Fork自
wechaty / wechaty
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
W
wechaty
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9a50ec40
编写于
6月 10, 2018
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
check more and hold token check before instanciating
上级
33b940cc
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
50 addition
and
25 deletion
+50
-25
package.json
package.json
+1
-1
src/puppet-padchat/bridge.ts
src/puppet-padchat/bridge.ts
+26
-6
src/puppet-padchat/config.ts
src/puppet-padchat/config.ts
+13
-10
src/puppet-padchat/padchat-rpc.ts
src/puppet-padchat/padchat-rpc.ts
+6
-6
src/puppet-padchat/puppet-padchat.ts
src/puppet-padchat/puppet-padchat.ts
+2
-2
src/puppet-padchat/pure-function-helper.ts
src/puppet-padchat/pure-function-helper.ts
+2
-0
未找到文件。
package.json
浏览文件 @
9a50ec40
...
...
@@ -100,7 +100,7 @@
"
cuid
"
:
"
^2.1.1
"
,
"
express
"
:
"
^4.16.3
"
,
"
file-box
"
:
"
^0.8.19
"
,
"
flash-store
"
:
"
^0.4.
0
"
,
"
flash-store
"
:
"
^0.4.
2
"
,
"
fs-extra
"
:
"
^6.0.1
"
,
"
hot-import
"
:
"
^0.2.1
"
,
"
jimp
"
:
"
^0.2.28
"
,
...
...
src/puppet-padchat/bridge.ts
浏览文件 @
9a50ec40
...
...
@@ -64,7 +64,7 @@ export class Bridge extends PadchatRpc {
private
loginTimer
?:
NodeJS
.
Timer
private
selfId
?
:
string
private
selfName
?
:
string
//
private selfName? : string
// private password? : string
// private nickname? : string
...
...
@@ -139,7 +139,16 @@ export class Bridge extends PadchatRpc {
this
.
cacheRoomRawPayload
=
new
FlashStoreSync
(
path
.
join
(
baseDir
,
'
room-raw-payload
'
))
this
.
cacheRoomMemberRawPayload
=
new
FlashStoreSync
(
path
.
join
(
baseDir
,
'
room-member-raw-payload
'
))
log
.
silly
(
'
PuppetPadchatBridge
'
,
'
initCache() workdir="%s"
'
,
baseDir
)
await
this
.
cacheContactRawPayload
.
ready
()
await
this
.
cacheRoomRawPayload
.
ready
()
await
this
.
cacheRoomMemberRawPayload
.
ready
()
log
.
verbose
(
'
PuppetPadchatBridge
'
,
'
initCache() inited %d Contacts, %d Rooms, %d RoomMembers, cachedir="%s"
'
,
this
.
cacheContactRawPayload
.
size
,
this
.
cacheRoomRawPayload
.
size
,
this
.
cacheRoomMemberRawPayload
.
size
,
baseDir
,
)
}
private
releaseCache
():
void
{
...
...
@@ -174,6 +183,17 @@ export class Bridge extends PadchatRpc {
// await this.padchatRpc.start()
await
super
.
start
()
this
.
on
(
'
padchat-logout
'
,
()
=>
{
if
(
this
.
selfId
)
{
this
.
emit
(
'
logout
'
)
}
else
{
/**
* PadchatRpc will receive 'logout' message multiple times when the server is logouted.
*/
log
.
warn
(
'
PuppetPadchatBridge
'
,
'
start() on(padchat-logout) received but selfId is undefined
'
)
}
})
// this.padchatRpc.on('message', messageRawPayload => {
// log.silly('PuppetPadchatBridge', 'start() padchatRpc.on(message)')
// this.emit('message', messageRawPayload)
...
...
@@ -218,9 +238,9 @@ export class Bridge extends PadchatRpc {
throw
new
Error
(
'
userId exist
'
)
}
this
.
selfId
=
userId
if
(
userName
)
{
this
.
selfName
=
userName
}
//
if (userName) {
//
this.selfName = userName
//
}
await
this
.
stopCheckScan
()
...
...
@@ -492,7 +512,7 @@ export class Bridge extends PadchatRpc {
// const result = await this.padchatRpc.WXGetQRCode()
const
result
=
await
this
.
WXGetQRCode
()
if
(
!
result
)
{
if
(
!
result
||
!
result
.
qr_code
)
{
log
.
verbose
(
'
PuppetPadchatBridge
'
,
`emitLoginQrCode() result not found. Call WXInitialize() and try again ...`
)
// await this.padchatRpc.WXInitialize()
await
this
.
WXInitialize
()
...
...
src/puppet-padchat/config.ts
浏览文件 @
9a50ec40
...
...
@@ -4,22 +4,25 @@ import {
export
const
WECHATY_PUPPET_PADCHAT_ENDPOINT
=
process
.
env
[
'
WECHATY_PUPPET_PADCHAT_ENDPOINT
'
]
||
'
ws://54.223.36.77:9091/wx
'
const
WECHATY_PUPPET_PADCHAT_TOKEN
=
process
.
env
[
'
WECHATY_PUPPET_PADCHAT_TOKEN
'
]
as
string
if
(
!
WECHATY_PUPPET_PADCHAT_TOKEN
)
{
log
.
error
(
'
PuppetPadchatConfig
'
,
`
function
padchatToken
()
{
const
token
=
process
.
env
[
'
WECHATY_PUPPET_PADCHAT_TOKEN
'
]
as
string
if
(
!
token
)
{
log
.
error
(
'
PuppetPadchatConfig
'
,
`
WECHATY_PUPPET_PADCHAT_TOKEN environment variable not found.
WECHATY_PUPPET_PADCHAT_TOKEN environment variable not found.
PuppetPadchat need a token before it can be used,
Please set WECHATY_PUPPET_PADCHAT_TOKEN then retry again.
PuppetPadchat need a token before it can be used,
Please set WECHATY_PUPPET_PADCHAT_TOKEN then retry again.
Learn more about it at: https://github.com/Chatie/wechaty/issues/1296
Learn more about it at: https://github.com/Chatie/wechaty/issues/1296
`
)
process
.
exit
(
1
)
`
)
throw
new
Error
(
'
set WECHATY_PUPPET_PADCHAT_TOKEN and try again
'
)
}
return
token
}
export
{
WECHATY_PUPPET_PADCHAT_TOKEN
,
padchatToken
,
}
src/puppet-padchat/padchat-rpc.ts
浏览文件 @
9a50ec40
...
...
@@ -205,7 +205,7 @@ export class PadchatRpc extends EventEmitter {
payload
.
type
,
JSON
.
stringify
(
payload
),
)
this
.
emit
(
'
logout
'
,
payload
.
msg
)
this
.
emit
(
'
padchat-
logout
'
,
payload
.
msg
)
return
}
...
...
@@ -259,11 +259,11 @@ export class PadchatRpc extends EventEmitter {
// )
// log.silly('PadchatRpc', 'onSocketPadchat(%s)', JSON.stringify(padchatPayload).substr(0, 500))
if
(
padchatPayload
.
type
===
PadchatPayloadType
.
Logout
)
{
// this.emit('logout', this.selfId())
console
.
log
(
'
onSocketPadchat:
'
,
JSON
.
stringify
(
padchatPayload
))
this
.
emit
(
'
logout
'
)
}
//
if (padchatPayload.type === PadchatPayloadType.Logout) {
//
// this.emit('logout', this.selfId())
//
console.log('onSocketPadchat: ', JSON.stringify(padchatPayload))
//
this.emit('logout')
//
}
let
result
:
any
...
...
src/puppet-padchat/puppet-padchat.ts
浏览文件 @
9a50ec40
...
...
@@ -53,7 +53,7 @@ import {
}
from
'
../config
'
import
{
WECHATY_PUPPET_PADCHAT_TOKEN
,
padchatToken
,
WECHATY_PUPPET_PADCHAT_ENDPOINT
,
}
from
'
./config
'
...
...
@@ -113,7 +113,7 @@ export class PuppetPadchat extends Puppet {
this
.
bridge
=
new
Bridge
({
memory
:
this
.
options
.
memory
,
token
:
WECHATY_PUPPET_PADCHAT_TOKEN
,
token
:
padchatToken
()
,
endpoint
:
WECHATY_PUPPET_PADCHAT_ENDPOINT
,
})
}
...
...
src/puppet-padchat/pure-function-helper.ts
浏览文件 @
9a50ec40
...
...
@@ -327,6 +327,8 @@ export class PadchatPureFunctionHelper {
}
public
static
async
imageBase64ToQrcode
(
base64
:
string
):
Promise
<
string
>
{
// console.log('base64: ', typeof base64, String(base64).substr(0, 500))
const
imageBuffer
=
Buffer
.
from
(
base64
,
'
base64
'
)
const
future
=
new
Promise
<
string
>
((
resolve
,
reject
)
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录