Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.Veneno.
wechaty
提交
79486d02
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,发现更多精彩内容 >>
提交
79486d02
编写于
6月 14, 2018
作者:
ruiruibupt
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of github.com:Chatie/wechaty into bug-compatible-createroom
上级
ace7f446
c2ff8282
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
76 addition
and
57 deletion
+76
-57
package.json
package.json
+1
-1
src/contact.ts
src/contact.ts
+2
-7
src/friendship.ts
src/friendship.ts
+1
-1
src/puppet-padchat/padchat-manager.ts
src/puppet-padchat/padchat-manager.ts
+34
-6
src/puppet-padchat/padchat-rpc.ts
src/puppet-padchat/padchat-rpc.ts
+7
-1
src/puppet-padchat/puppet-padchat.ts
src/puppet-padchat/puppet-padchat.ts
+11
-13
src/puppet/puppet.ts
src/puppet/puppet.ts
+17
-25
src/room.ts
src/room.ts
+3
-3
未找到文件。
package.json
浏览文件 @
79486d02
{
"name"
:
"wechaty"
,
"version"
:
"0.15.17
0
"
,
"version"
:
"0.15.17
2
"
,
"description"
:
"Wechat for Bot(Personal Account)"
,
"main"
:
"dist/src/index.js"
,
"typings"
:
"dist/src/index.d.ts"
,
...
...
src/contact.ts
浏览文件 @
79486d02
...
...
@@ -530,18 +530,13 @@ export class Contact extends Accessory implements Sayable {
* await contact.sync()
*/
public
async
sync
():
Promise
<
void
>
{
// TODO: make sure the contact.* works when we are refreshing the data
// if (this.isReady()) {
// this.dirtyObj = this.obj
// }
// this.payload = undefined
await
this
.
ready
(
true
)
}
/**
* @private
*/
public
async
ready
(
noCache
=
false
):
Promise
<
void
>
{
public
async
ready
(
dirty
=
false
):
Promise
<
void
>
{
log
.
silly
(
'
Contact
'
,
'
ready() @ %s
'
,
this
.
puppet
)
if
(
this
.
isReady
())
{
// already ready
...
...
@@ -550,7 +545,7 @@ export class Contact extends Accessory implements Sayable {
}
try
{
await
this
.
puppet
.
contactPayload
(
this
.
id
,
noCache
)
await
this
.
puppet
.
contactPayload
(
this
.
id
,
dirty
)
// log.silly('Contact', `ready() this.puppet.contactPayload(%s) resolved`, this)
}
catch
(
e
)
{
...
...
src/friendship.ts
浏览文件 @
79486d02
...
...
@@ -167,7 +167,7 @@ export class Friendship extends Accessory {
}
/**
* no `
noCache
` support because Friendship has no rawPayload(yet)
* no `
dirty
` support because Friendship has no rawPayload(yet)
*/
public
async
ready
():
Promise
<
void
>
{
if
(
this
.
payload
)
{
...
...
src/puppet-padchat/padchat-manager.ts
浏览文件 @
79486d02
...
...
@@ -164,11 +164,9 @@ export class PadchatManager extends PadchatRpc {
&&
this
.
cacheRoomMemberRawPayload
&&
this
.
cacheRoomRawPayload
)
{
await
Promise
.
all
([
this
.
cacheContactRawPayload
.
close
(),
this
.
cacheRoomMemberRawPayload
.
close
(),
this
.
cacheRoomRawPayload
.
close
(),
])
await
this
.
cacheContactRawPayload
.
close
(),
await
this
.
cacheRoomMemberRawPayload
.
close
(),
await
this
.
cacheRoomRawPayload
.
close
(),
this
.
cacheContactRawPayload
=
undefined
this
.
cacheRoomMemberRawPayload
=
undefined
...
...
@@ -485,6 +483,14 @@ export class PadchatManager extends PadchatRpc {
const
autoLoginResult
=
await
this
.
WXAutoLogin
(
token
)
// const autoLoginResult = await this.padchatRpc.WXAutoLogin(this.autoData.token)
if
(
!
autoLoginResult
)
{
/**
* 1.1 Delete token for prevent future useless auto login retry
*/
delete
deviceInfo
.
token
this
.
options
.
memory
.
set
(
MEMORY_SLOT_NAME
,
memorySlot
)
await
this
.
options
.
memory
.
save
()
await
this
.
emitLoginQrcode
()
return
false
}
...
...
@@ -513,6 +519,14 @@ export class PadchatManager extends PadchatRpc {
* 4 Send Login Request to user fail, emit QrCode for scan.
*/
await
this
.
emitLoginQrcode
()
/**
* 5 Delete token for prevent future useless auto login retry
*/
delete
deviceInfo
.
token
this
.
options
.
memory
.
set
(
MEMORY_SLOT_NAME
,
memorySlot
)
await
this
.
options
.
memory
.
save
()
return
false
}
...
...
@@ -584,6 +598,10 @@ export class PadchatManager extends PadchatRpc {
*/
if
(
memorySlot
.
currentUserId
===
userId
)
{
log
.
silly
(
'
PuppetPadchatManager
'
,
'
refresh62Data() userId did not change since last login, keep the data as the same
'
)
// Update Token
memorySlot
.
device
[
userId
]
!
.
token
=
await
this
.
WXGetLoginToken
()
return
memorySlot
}
...
...
@@ -748,7 +766,17 @@ export class PadchatManager extends PadchatRpc {
if
(
!
memberListPayload
||
!
(
'
user_name
'
in
memberListPayload
))
{
// check user_name too becasue the server might return {}
// console.log('memberListPayload', memberListPayload)
throw
new
Error
(
'
no memberListPayload
'
)
// throw new Error('no memberListPayload')
/**
* Room Id not exist
* See: https://github.com/lijiarui/wechaty-puppet-padchat/issues/64#issuecomment-397319016
*/
this
.
roomMemberRawPayloadDirty
(
roomId
)
this
.
roomRawPayloadDirty
(
roomId
)
return
{}
}
log
.
silly
(
'
PuppetPadchatManager
'
,
'
syncRoomMember(%s) total %d members
'
,
...
...
src/puppet-padchat/padchat-rpc.ts
浏览文件 @
79486d02
...
...
@@ -709,12 +709,18 @@ export class PadchatRpc extends EventEmitter {
* Get all member of a room by room id
* @param {any} roomId chatroom_id
*/
public
async
WXGetChatRoomMember
(
roomId
:
string
):
Promise
<
PadchatRoomMemberListPayload
>
{
public
async
WXGetChatRoomMember
(
roomId
:
string
):
Promise
<
null
|
PadchatRoomMemberListPayload
>
{
const
result
=
await
this
.
rpcCall
(
'
WXGetChatRoomMember
'
,
roomId
)
if
(
!
result
)
{
throw
Error
(
'
PadchatRpc, WXGetChatRoomMember, cannot get result from websocket server!
'
)
}
// roomId not exist. (or no permision?)
// See: https://github.com/lijiarui/wechaty-puppet-padchat/issues/64#issuecomment-397319016
if
(
result
.
status
===
-
19
)
{
return
null
}
log
.
silly
(
'
PadchatRpc
'
,
'
WXGetChatRoomMember() result: %s
'
,
JSON
.
stringify
(
result
).
substr
(
0
,
500
))
// 00:40:44 SILL PadchatRpc WXGetChatRoomMember() result: {"chatroom_id":0,"count":0,"member":"null\n","message":"","status":0,"user_name":""}
...
...
src/puppet-padchat/puppet-padchat.ts
浏览文件 @
79486d02
...
...
@@ -18,8 +18,6 @@
*/
import
path
from
'
path
'
// import fs from 'fs'
// import cuid from 'cuid'
import
LRU
from
'
lru-cache
'
import
flatten
from
'
array-flatten
'
...
...
@@ -262,7 +260,7 @@ export class PuppetPadchat extends Puppet {
* 1. Sometimes will get duplicated same messages from rpc, drop the same message from here.
*/
if
(
this
.
cachePadchatMessagePayload
.
has
(
rawPayload
.
msg_id
))
{
log
.
warn
(
'
PuppetPadchat
'
,
'
onPadchatMessage(id=%s) duplicate message: %s
'
,
log
.
silly
(
'
PuppetPadchat
'
,
'
onPadchatMessage(id=%s) duplicate message: %s
'
,
rawPayload
.
msg_id
,
JSON
.
stringify
(
rawPayload
).
substr
(
0
,
500
),
)
...
...
@@ -360,7 +358,7 @@ export class PuppetPadchat extends Puppet {
/**
* Dirty Cache
*/
this
.
roomMemberPayloadDirty
(
roomId
)
await
this
.
roomMemberPayloadDirty
(
roomId
)
return
retry
(
new
Error
(
'
roomMemberSearch() not found
'
))
...
...
@@ -419,7 +417,8 @@ export class PuppetPadchat extends Puppet {
/**
* Dirty Cache
*/
this
.
roomMemberPayloadDirty
(
roomId
)
await
this
.
roomMemberPayloadDirty
(
roomId
)
await
this
.
roomPayloadDirty
(
roomId
)
this
.
emit
(
'
room-leave
'
,
roomId
,
leaverIdList
,
removerId
)
}
...
...
@@ -439,8 +438,8 @@ export class PuppetPadchat extends Puppet {
const
roomId
=
roomTopicEvent
.
roomId
log
.
silly
(
'
PuppetPadchat
'
,
'
onPadchatMessageRoomEventTopic() roomTopicEvent="%s"
'
,
JSON
.
stringify
(
roomTopicEvent
))
const
roomPayload
=
await
this
.
roomPayload
(
roomId
)
const
oldTopic
=
room
Payload
.
topic
const
room
Old
Payload
=
await
this
.
roomPayload
(
roomId
)
const
oldTopic
=
roomOld
Payload
.
topic
const
changerIdList
=
await
this
.
roomMemberSearch
(
roomId
,
changerName
)
if
(
changerIdList
.
length
<
1
)
{
...
...
@@ -456,11 +455,10 @@ export class PuppetPadchat extends Puppet {
/**
* Update Room Payload to new Topic
*/
const
updateRoomPayload
=
await
this
.
roomPayload
(
roomId
)
updateRoomPayload
.
topic
=
newTopic
this
.
cacheRoomPayload
.
set
(
roomId
,
updateRoomPayload
)
this
.
roomPayloadDirty
(
roomId
)
// const updateRoomPayload = await this.roomPayload(roomId)
// updateRoomPayload.topic = newTopic
// this.cacheRoomPayload.set(roomId, updateRoomPayload)
await
this
.
roomPayloadDirty
(
roomId
)
this
.
emit
(
'
room-topic
'
,
roomId
,
newTopic
,
oldTopic
,
changerId
)
}
...
...
@@ -1176,7 +1174,7 @@ export class PuppetPadchat extends Puppet {
// this.padchatManager.friendshipRawPayloadDirty(friendshipId)
}
this
.
friendshipPayloadDirty
(
friendshipId
)
await
super
.
friendshipPayloadDirty
(
friendshipId
)
}
public
async
friendshipRawPayload
(
friendshipId
:
string
):
Promise
<
PadchatMessagePayload
>
{
...
...
src/puppet/puppet.ts
浏览文件 @
79486d02
...
...
@@ -471,18 +471,16 @@ export abstract class Puppet extends EventEmitter implements Sayable {
public
async
contactPayload
(
contactId
:
string
,
noCache
=
false
,
dirty
=
false
,
):
Promise
<
ContactPayload
>
{
// log.silly('Puppet', 'contactPayload(id=%s,
noCache=%s) @ %s', contactId, noCache
, this)
// log.silly('Puppet', 'contactPayload(id=%s,
dirty=%s) @ %s', contactId, dirty
, this)
if
(
!
contactId
)
{
throw
new
Error
(
'
no id
'
)
}
if
(
noCache
)
{
log
.
silly
(
'
Puppet
'
,
'
contactPayload(%s) cache PURGE
'
,
contactId
)
this
.
cacheContactPayload
.
del
(
contactId
)
if
(
dirty
)
{
this
.
contactPayloadDirty
(
contactId
)
}
else
{
const
cachedPayload
=
this
.
contactPayloadCache
(
contactId
)
...
...
@@ -539,18 +537,16 @@ export abstract class Puppet extends EventEmitter implements Sayable {
public
async
friendshipPayload
(
friendshipId
:
string
,
noCache
=
false
,
dirty
=
false
,
):
Promise
<
FriendshipPayload
>
{
log
.
verbose
(
'
Puppet
'
,
'
friendshipPayload(id=%s,
noCache=%s)
'
,
friendshipId
,
noCache
)
log
.
verbose
(
'
Puppet
'
,
'
friendshipPayload(id=%s,
dirty=%s)
'
,
friendshipId
,
dirty
)
if
(
!
friendshipId
)
{
throw
new
Error
(
'
no id
'
)
}
if
(
noCache
)
{
log
.
silly
(
'
Puppet
'
,
'
friendshipPayload(%s) cache PURGE
'
,
friendshipId
)
this
.
cacheFriendshipPayload
.
del
(
friendshipId
)
if
(
dirty
)
{
this
.
friendshipPayloadDirty
(
friendshipId
)
}
else
{
const
cachedPayload
=
this
.
friendshipPayloadCache
(
friendshipId
)
...
...
@@ -608,18 +604,16 @@ export abstract class Puppet extends EventEmitter implements Sayable {
public
async
messagePayload
(
messageId
:
string
,
noCache
=
false
,
dirty
=
false
,
):
Promise
<
MessagePayload
>
{
log
.
verbose
(
'
Puppet
'
,
'
messagePayload(id=%s,
noCache=%s)
'
,
messageId
,
noCache
)
log
.
verbose
(
'
Puppet
'
,
'
messagePayload(id=%s,
dirty=%s)
'
,
messageId
,
dirty
)
if
(
!
messageId
)
{
throw
new
Error
(
'
no id
'
)
}
if
(
noCache
)
{
log
.
silly
(
'
Puppet
'
,
'
messagePayload(%s) cache PURGE
'
,
messageId
)
this
.
cacheMessagePayload
.
del
(
messageId
)
if
(
dirty
)
{
this
.
messagePayloadDirty
(
messageId
)
}
else
{
const
cachedPayload
=
this
.
messagePayloadCache
(
messageId
)
...
...
@@ -828,18 +822,16 @@ export abstract class Puppet extends EventEmitter implements Sayable {
public
async
roomPayload
(
roomId
:
string
,
noCache
=
false
,
dirty
=
false
,
):
Promise
<
RoomPayload
>
{
log
.
verbose
(
'
Puppet
'
,
'
roomPayload(id=%s,
noCache=%s)
'
,
roomId
,
noCache
)
log
.
verbose
(
'
Puppet
'
,
'
roomPayload(id=%s,
dirty=%s)
'
,
roomId
,
dirty
)
if
(
!
roomId
)
{
throw
new
Error
(
'
no id
'
)
}
if
(
noCache
)
{
log
.
silly
(
'
Puppet
'
,
'
roomPayload(%s) cache PURGE
'
,
roomId
)
this
.
cacheRoomPayload
.
del
(
roomId
)
if
(
dirty
)
{
this
.
roomPayloadDirty
(
roomId
)
}
else
{
const
cachedPayload
=
this
.
roomPayloadCache
(
roomId
)
...
...
@@ -905,7 +897,7 @@ export abstract class Puppet extends EventEmitter implements Sayable {
contactId
:
string
,
dirty
=
false
,
):
Promise
<
RoomMemberPayload
>
{
log
.
verbose
(
'
Puppet
'
,
'
roomMemberPayload(roomId=%s, contactId=%s
noCache
=%s)
'
,
roomId
,
contactId
,
dirty
)
log
.
verbose
(
'
Puppet
'
,
'
roomMemberPayload(roomId=%s, contactId=%s
dirty
=%s)
'
,
roomId
,
contactId
,
dirty
)
if
(
!
roomId
||
!
contactId
)
{
throw
new
Error
(
'
no id
'
)
...
...
src/room.ts
浏览文件 @
79486d02
...
...
@@ -240,15 +240,15 @@ export class Room extends Accessory implements Sayable {
* @private
*/
public
async
ready
(
noCache
=
false
,
dirty
=
false
,
):
Promise
<
void
>
{
log
.
verbose
(
'
Room
'
,
'
ready()
'
)
if
(
!
noCache
&&
this
.
isReady
())
{
if
(
!
dirty
&&
this
.
isReady
())
{
return
}
await
this
.
puppet
.
roomPayload
(
this
.
id
,
noCache
)
await
this
.
puppet
.
roomPayload
(
this
.
id
,
dirty
)
const
memberIdList
=
await
this
.
puppet
.
roomMemberList
(
this
.
id
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录