Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.Veneno.
wechaty
提交
e418ccc8
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,发现更多精彩内容 >>
提交
e418ccc8
编写于
6月 09, 2018
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
room.topic() from sync to async, with default values (#1295)
上级
70ac7b1e
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
112 addition
and
62 deletion
+112
-62
examples/api-ai-bot.ts
examples/api-ai-bot.ts
+2
-2
examples/gist-bot/on-message.ts
examples/gist-bot/on-message.ts
+1
-1
examples/gist-bot/on-room-join.ts
examples/gist-bot/on-room-join.ts
+2
-2
examples/hot-reload-bot/listener/message.js
examples/hot-reload-bot/listener/message.js
+1
-1
examples/monster/listeners/on-message.js
examples/monster/listeners/on-message.js
+1
-1
examples/room-bot.ts
examples/room-bot.ts
+9
-9
examples/self-testing-bot.ts
examples/self-testing-bot.ts
+13
-10
src/message.ts
src/message.ts
+5
-2
src/puppet-padchat/bridge.ts
src/puppet-padchat/bridge.ts
+42
-14
src/puppet-padchat/padchat-rpc.ts
src/puppet-padchat/padchat-rpc.ts
+5
-3
src/puppet-padchat/pure-function-helper.ts
src/puppet-padchat/pure-function-helper.ts
+2
-0
src/puppet-puppeteer/puppeteer-room.spec.ts
src/puppet-puppeteer/puppeteer-room.spec.ts
+1
-1
src/puppet/puppet.ts
src/puppet/puppet.ts
+9
-10
src/room.ts
src/room.ts
+19
-6
未找到文件。
examples/api-ai-bot.ts
浏览文件 @
e418ccc8
...
...
@@ -79,14 +79,14 @@ bot
})
.
on
(
'
login
'
,
user
=>
log
.
info
(
'
Bot
'
,
`bot login:
${
user
}
`
))
.
on
(
'
logout
'
,
user
=>
log
.
info
(
'
Bot
'
,
'
bot %s logout.
'
,
user
))
.
on
(
'
message
'
,
m
=>
{
.
on
(
'
message
'
,
async
m
=>
{
if
(
m
.
self
())
{
return
}
// co(function* () {
// const msg = yield m.load()
const
room
=
m
.
room
()
if
(
room
&&
/Wechaty/i
.
test
(
room
.
topic
()))
{
if
(
room
&&
/Wechaty/i
.
test
(
await
room
.
topic
()))
{
log
.
info
(
'
Bot
'
,
'
talk: %s
'
,
m
)
talk
(
m
)
}
else
{
...
...
examples/gist-bot/on-message.ts
浏览文件 @
e418ccc8
...
...
@@ -33,7 +33,7 @@ export async function onMessage(this: Wechaty, message: Message): Promise<void>
const
sender
=
message
.
from
()
const
content
=
message
.
text
()
console
.
log
((
room
?
'
[
'
+
room
.
topic
()
+
'
]
'
:
''
)
console
.
log
((
room
?
'
[
'
+
await
room
.
topic
()
+
'
]
'
:
''
)
+
'
<
'
+
sender
.
name
()
+
'
>
'
+
'
:
'
+
message
,
)
...
...
examples/gist-bot/on-room-join.ts
浏览文件 @
e418ccc8
...
...
@@ -42,8 +42,8 @@ export async function onRoomJoin(
*
*/
if
(
room
.
topic
()
!==
'
ding
'
)
{
await
this
.
say
(
'
Room
'
+
room
.
topic
()
if
(
await
room
.
topic
()
!==
'
ding
'
)
{
await
this
.
say
(
'
Room
'
+
await
room
.
topic
()
+
'
got new memeber
'
+
inviteeName
+
'
invited by
'
+
inviter
.
name
(),
)
...
...
examples/hot-reload-bot/listener/message.js
浏览文件 @
e418ccc8
...
...
@@ -21,7 +21,7 @@ exports = module.exports = async function onMessage (message) {
const
sender
=
message
.
from
();
const
content
=
message
.
text
();
const
topic
=
room
?
'
[
'
+
room
.
topic
()
+
'
]
'
:
''
;
const
topic
=
room
?
'
[
'
+
await
room
.
topic
()
+
'
]
'
:
''
;
console
.
log
(
`
${
topic
}
<
${
sender
.
name
()}
> :
${
message
.
toStringDigest
()}
`
);
...
...
examples/monster/listeners/on-message.js
浏览文件 @
e418ccc8
...
...
@@ -35,7 +35,7 @@ export default async function onMessage (message) {
const
room
=
message
.
room
()
const
sender
=
message
.
from
()
const
content
=
message
.
text
()
const
roomName
=
room
?
`[
${
room
.
topic
()}
] `
:
''
const
roomName
=
room
?
`[
${
await
room
.
topic
()}
] `
:
''
process
.
stdout
.
write
(
`
${
roomName
}
<
${
sender
.
name
()}
>(
${
message
.
type
()}
:
${
message
.
typeSub
()}
): `
)
...
...
examples/room-bot.ts
浏览文件 @
e418ccc8
...
...
@@ -121,9 +121,9 @@ bot
/**
* Global Event: room-join
*/
.
on
(
'
room-join
'
,
function
(
this
,
room
,
inviteeList
,
inviter
)
{
.
on
(
'
room-join
'
,
async
function
(
this
,
room
,
inviteeList
,
inviter
)
{
log
.
info
(
'
Bot
'
,
'
EVENT: room-join - Room %s got new member %s, invited by %s
'
,
room
.
topic
(),
await
room
.
topic
(),
inviteeList
.
map
(
c
=>
c
.
name
()).
join
(
'
,
'
),
inviter
.
name
(),
)
...
...
@@ -132,9 +132,9 @@ bot
/**
* Global Event: room-leave
*/
.
on
(
'
room-leave
'
,
function
(
this
,
room
,
leaverList
)
{
.
on
(
'
room-leave
'
,
async
function
(
this
,
room
,
leaverList
)
{
log
.
info
(
'
Bot
'
,
'
EVENT: room-leave - Room %s lost member %s
'
,
room
.
topic
(),
await
room
.
topic
(),
leaverList
.
map
(
c
=>
c
.
name
()).
join
(
'
,
'
),
)
})
...
...
@@ -163,7 +163,7 @@ bot
const
sender
=
message
.
from
()
const
content
=
message
.
text
()
console
.
log
((
room
?
'
[
'
+
room
.
topic
()
+
'
]
'
:
''
)
console
.
log
((
room
?
'
[
'
+
await
room
.
topic
()
+
'
]
'
:
''
)
+
'
<
'
+
sender
.
name
()
+
'
>
'
+
'
:
'
+
message
,
)
...
...
@@ -182,7 +182,7 @@ bot
* in-room message
*/
if
(
room
)
{
if
(
/^ding/i
.
test
(
room
.
topic
()))
{
if
(
/^ding/i
.
test
(
await
room
.
topic
()))
{
/**
* move contact out of room
*/
...
...
@@ -297,7 +297,7 @@ async function manageDingRoom() {
async
function
checkRoomJoin
(
room
:
Room
,
inviteeList
:
Contact
[],
inviter
:
Contact
)
{
log
.
info
(
'
Bot
'
,
'
checkRoomJoin(%s, %s, %s)
'
,
room
.
topic
(),
await
room
.
topic
(),
inviteeList
.
map
(
c
=>
c
.
name
()).
join
(
'
,
'
),
inviter
.
name
(),
)
...
...
@@ -315,7 +315,7 @@ async function checkRoomJoin(room: Room, inviteeList: Contact[], inviter: Contac
inviteeList
,
)
room
.
topic
(
'
ding - warn
'
+
inviter
.
name
())
await
room
.
topic
(
'
ding - warn
'
+
inviter
.
name
())
setTimeout
(
_
=>
inviteeList
.
forEach
(
c
=>
room
.
del
(
c
)),
10
*
1000
,
...
...
@@ -337,7 +337,7 @@ async function checkRoomJoin(room: Room, inviteeList: Contact[], inviter: Contac
}
async
function
putInRoom
(
contact
:
Contact
,
room
:
Room
)
{
log
.
info
(
'
Bot
'
,
'
putInRoom(%s, %s)
'
,
contact
.
name
(),
room
.
topic
())
log
.
info
(
'
Bot
'
,
'
putInRoom(%s, %s)
'
,
contact
.
name
(),
await
room
.
topic
())
try
{
await
room
.
add
(
contact
)
...
...
examples/self-testing-bot.ts
浏览文件 @
e418ccc8
...
...
@@ -96,26 +96,29 @@ bot
const
from
=
msg
.
from
()
// Room.findAll()
if
(
/^testRoom$/
.
test
(
text
))
{
if
(
/^testRoom$/
i
.
test
(
text
))
{
const
roomList
=
await
bot
.
Room
.
findAll
()
const
topicList
=
await
Promise
.
all
(
roomList
.
map
(
async
room
=>
await
room
.
topic
()),
)
let
n
=
0
from
.
say
(
roomList
.
map
(
room
=>
room
.
topic
())
.
map
(
topic
=>
n
++
+
'
.
'
+
topic
)
await
from
.
say
(
topicList
.
map
(
topic
=>
++
n
+
'
.
'
+
topic
)
.
join
(
'
\n
'
),
)
return
}
// Contact.findAll()
if
(
/^testContact$/
.
test
(
text
))
{
if
(
/^testContact$/
i
.
test
(
text
))
{
const
contactList
=
await
bot
.
Contact
.
findAll
()
let
n
=
0
from
.
say
(
await
from
.
say
(
contactList
.
map
(
contact
=>
contact
.
name
())
.
map
(
name
=>
n
++
+
'
.
'
+
name
)
.
map
(
name
=>
++
n
+
'
.
'
+
name
)
.
join
(
'
\n
'
),
)
return
...
...
@@ -131,14 +134,14 @@ bot
console
.
error
(
'
contact not found
'
)
return
}
msg
.
forward
(
contact
)
await
msg
.
forward
(
contact
)
return
}
if
(
/^froom$/
.
test
(
text
))
{
console
.
log
(
'
begin to check msg forward room
'
)
const
room
=
bot
.
Room
.
load
(
'
6350854677@chatroom
'
)
msg
.
forward
(
room
)
await
msg
.
forward
(
room
)
return
}
...
...
src/message.ts
浏览文件 @
e418ccc8
...
...
@@ -156,7 +156,6 @@ export class Message extends Accessory implements Sayable {
const
msgStrList
=
[
'
Message
'
,
// `#${MessageDirection[this.direction]}`,
`#
${
MessageType
[
this
.
type
()]}
`
,
'
(
'
,
this
.
room
()
?
(
this
.
room
()
+
'
▲
'
)
:
''
,
...
...
@@ -177,7 +176,11 @@ export class Message extends Accessory implements Sayable {
}
const
filename
=
this
.
payload
.
filename
if
(
!
filename
)
{
throw
new
Error
(
'
no file for message id:
'
+
this
.
id
+
'
with type:
'
+
this
.
payload
.
type
)
throw
new
Error
(
'
no file for message id:
'
+
this
.
id
+
'
with type:
'
+
Message
.
Type
[
this
.
payload
.
type
]
+
'
(
'
+
this
.
payload
.
type
+
'
)
'
,
)
}
msgStrList
.
push
(
`<
${
filename
}
>`
)
}
...
...
src/puppet-padchat/bridge.ts
浏览文件 @
e418ccc8
...
...
@@ -124,11 +124,19 @@ export class Bridge extends EventEmitter {
await
this
.
padchatRpc
.
start
()
this
.
padchatRpc
.
on
(
'
message
'
,
messageRawPayload
=>
{
log
.
silly
(
'
PuppetPadchatBridge
'
,
`start() padchatRpc.on('message')`
)
log
.
silly
(
'
PuppetPadchatBridge
'
,
'
start() padchatRpc.on(message)
'
)
this
.
emit
(
'
message
'
,
messageRawPayload
)
})
this
.
padchatRpc
.
on
(
'
logout
'
,
data
=>
{
log
.
silly
(
'
PuppetPadchatBridge
'
,
'
start() padchatRpc.on(logout, %s)
'
,
data
)
if
(
this
.
selfId
)
{
this
.
selfId
=
undefined
this
.
emit
(
'
logout
'
,
data
)
}
else
{
log
.
warn
(
'
PuppetPadchatBridge
'
,
'
start() padchatRpc.on(logout) received `logout` event when no `selfId`
'
)
}
})
// TODO: 顺序变一下,要check user_name 的
await
this
.
loadAutoData
()
const
restoreSucceed
=
await
this
.
restoreLogin
()
...
...
@@ -228,6 +236,8 @@ export class Bridge extends EventEmitter {
if
(
result
.
expired_time
&&
result
.
expired_time
<
10
)
{
// result.expire_time is second
// emit new qrcode before the old one expired
this
.
loginScanQrCode
=
undefined
this
.
loginScanStatus
=
undefined
waitUserResponse
=
false
}
...
...
@@ -331,6 +341,24 @@ export class Bridge extends EventEmitter {
* "user_name": "wxid_5zj4i5htp9ih22"
* }
*/
/**
* WXAutoLoginresult: {
* "email": "",
* "external": "",
* "long_link_server": "",
* "message": "\n�\u0002<e>\n<ShowType>1</ShowType>\n<Content><![CDATA[你已退出微信]]></Content>\n
* <Url><![CDATA[]]></Url>\n<DispSec>30</DispSec>\n<Title><![CDATA[]]></Title>\n<Action>4</Action>\n
* <DelayConnSec>0</DelayConnSec>\n<Countdown>0</Countdown>\n<Ok><![CDATA[]]></Ok>\n<Cancel><![CDATA[]]></Cancel>\n</e>\n",
* "nick_name": "",
* "phone_number": "",
* "qq": 0,
* "short_link_server": "",
* "status": -2023,
* "uin": 4763975,
* "user_name": "lizhuohuan"
* }
*/
const
autoLoginResult
=
await
this
.
padchatRpc
.
WXAutoLogin
(
this
.
autoData
.
token
)
if
(
!
autoLoginResult
)
{
...
...
@@ -538,12 +566,10 @@ export class Bridge extends EventEmitter {
continue
}
log
.
verbose
(
'
PuppetPadchatBridge
'
,
'
syncContactsAndRooms() sync contact, got new/total: %d/%d
'
,
syncContactList
.
length
,
(
Object
.
keys
(
this
.
cacheContactRawPayload
).
length
+
Object
.
keys
(
this
.
cacheRoomRawPayload
).
length
),
log
.
verbose
(
'
PuppetPadchatBridge
'
,
'
syncContactsAndRooms() adding new %d to Contact(%d) & Room(%d) ...
'
,
syncContactList
.
length
,
Object
.
keys
(
this
.
cacheContactRawPayload
).
length
,
Object
.
keys
(
this
.
cacheRoomRawPayload
).
length
,
)
for
(
const
syncContact
of
syncContactList
)
{
...
...
@@ -555,16 +581,14 @@ export class Bridge extends EventEmitter {
}
if
(
syncContact
.
msg_type
===
PadchatContactMsgType
.
Contact
)
{
log
.
verbose
(
'
PuppetPadchatBridge
'
,
'
syncContactsAndRooms() sync for %s(%s)
'
,
syncContact
.
nick_name
,
syncContact
.
user_name
,
)
if
(
pfHelper
.
isRoomId
(
syncContact
.
user_name
))
{
// /@chatroom$/.test(syncContact.user_name)) {
/**
* Room
*/
// user_name or chatroom_id ?
log
.
verbose
(
'
PuppetPadchatBridge
'
,
'
syncContactsAndRooms() sync Room %s(%s)
'
,
syncContact
.
nick_name
,
syncContact
.
user_name
,
)
const
roomId
=
syncContact
.
user_name
const
roomPayload
=
syncContact
as
PadchatRoomPayload
...
...
@@ -575,6 +599,10 @@ export class Bridge extends EventEmitter {
/**
* Contact
*/
log
.
verbose
(
'
PuppetPadchatBridge
'
,
'
syncContactsAndRooms() sync Contact %s(%s)
'
,
syncContact
.
nick_name
,
syncContact
.
user_name
,
)
const
contactPayload
=
syncContact
as
PadchatContactPayload
const
contactId
=
contactPayload
.
user_name
...
...
src/puppet-padchat/padchat-rpc.ts
浏览文件 @
e418ccc8
...
...
@@ -188,7 +188,7 @@ export class PadchatRpc extends EventEmitter {
apiName
:
string
,
...
params
:
string
[]
):
Promise
<
any
>
{
log
.
silly
(
'
PadchatRpc
'
,
'
rpcCall(%s, %s)
'
,
apiName
,
JSON
.
stringify
(
params
))
log
.
silly
(
'
PadchatRpc
'
,
'
rpcCall(%s, %s)
'
,
apiName
,
JSON
.
stringify
(
params
)
.
substr
(
0
,
500
)
)
return
await
this
.
jsonRpc
.
request
(
apiName
,
params
)
}
...
...
@@ -200,11 +200,13 @@ export class PadchatRpc extends EventEmitter {
// console.log('server payload:', payload)
if
(
payload
.
type
===
PadchatPayloadType
.
Logout
)
{
log
.
verbose
(
'
PadchatRpc
'
,
'
onSocket(payload.type=%s) logout, payload=%s
'
,
// {"type":-1,"msg":"掉线了"}
log
.
verbose
(
'
PadchatRpc
'
,
'
onSocket(payload.type=%s) logout, payload=%s(%s)
'
,
PadchatPayloadType
[
payload
.
type
],
payload
.
type
,
JSON
.
stringify
(
payload
),
)
this
.
emit
(
'
logout
'
)
this
.
emit
(
'
logout
'
,
payload
.
msg
)
return
}
...
...
src/puppet-padchat/pure-function-helper.ts
浏览文件 @
e418ccc8
...
...
@@ -135,6 +135,8 @@ export class PadchatPureFunctionHelper {
rawPayload
:
PadchatMessagePayload
,
):
MessagePayload
{
console
.
log
(
rawPayload
)
let
type
:
MessageType
switch
(
rawPayload
.
sub_type
)
{
...
...
src/puppet-puppeteer/puppeteer-room.spec.ts
浏览文件 @
e418ccc8
...
...
@@ -106,7 +106,7 @@ test('Room smok testing', async t => {
// t.is((r as any).payload[.('encryId') , EXPECTED.encryId, 'should set EncryChatRoomId')
t
.
is
(
room
.
topic
(),
ROOM_EXPECTED
.
topic
,
'
should set topic/NickName
'
)
t
.
is
(
await
room
.
topic
(),
ROOM_EXPECTED
.
topic
,
'
should set topic/NickName
'
)
const
contact1
=
new
wechaty
.
Contact
(
ROOM_EXPECTED
.
memberId1
)
const
alias1
=
await
room
.
alias
(
contact1
)
...
...
src/puppet/puppet.ts
浏览文件 @
e418ccc8
...
...
@@ -445,9 +445,9 @@ export abstract class Puppet extends EventEmitter implements Sayable {
const
cachedPayload
=
this
.
cacheContactPayload
.
get
(
contactId
)
if
(
cachedPayload
)
{
log
.
silly
(
'
Puppet
'
,
'
contactPayload(
) cache HIT
'
)
log
.
silly
(
'
Puppet
'
,
'
contactPayload(
%s) cache HIT
'
,
contactId
)
}
else
{
log
.
silly
(
'
Puppet
'
,
'
contactPayload(
) cache MISS
'
)
log
.
silly
(
'
Puppet
'
,
'
contactPayload(
%s) cache MISS
'
,
contactId
)
}
return
cachedPayload
...
...
@@ -508,9 +508,9 @@ export abstract class Puppet extends EventEmitter implements Sayable {
const
cachedPayload
=
this
.
cacheFriendRequestPayload
.
get
(
friendRequestId
)
if
(
cachedPayload
)
{
log
.
silly
(
'
Puppet
'
,
'
friendRequestPayload(
) cache HIT
'
)
log
.
silly
(
'
Puppet
'
,
'
friendRequestPayload(
%s) cache HIT
'
,
friendRequestId
)
}
else
{
log
.
silly
(
'
Puppet
'
,
'
friendRequestPayload(
) cache MISS
'
)
log
.
silly
(
'
Puppet
'
,
'
friendRequestPayload(
%s) cache MISS
'
,
friendRequestId
)
}
return
cachedPayload
...
...
@@ -571,9 +571,9 @@ export abstract class Puppet extends EventEmitter implements Sayable {
}
const
cachedPayload
=
this
.
cacheMessagePayload
.
get
(
messageId
)
if
(
cachedPayload
)
{
log
.
silly
(
'
Puppet
'
,
'
messagePayloadCache(
) cache HIT
'
)
log
.
silly
(
'
Puppet
'
,
'
messagePayloadCache(
%s) cache HIT
'
,
messageId
)
}
else
{
log
.
silly
(
'
Puppet
'
,
'
messagePayloadCache(
) cache MISS
'
)
log
.
silly
(
'
Puppet
'
,
'
messagePayloadCache(
%s) cache MISS
'
,
messageId
)
}
return
cachedPayload
...
...
@@ -717,7 +717,6 @@ export abstract class Puppet extends EventEmitter implements Sayable {
id
=>
this
.
roomPayload
(
id
),
),
)
console
.
log
(
'
roomPayload resolved.
'
)
const
filterFunction
=
this
.
roomQueryFilterFactory
(
query
)
...
...
@@ -725,7 +724,7 @@ export abstract class Puppet extends EventEmitter implements Sayable {
.
filter
(
filterFunction
)
.
map
(
payload
=>
payload
.
id
)
console
.
log
(
'
roomIdList filtered. result length=
'
+
roomIdList
.
length
)
log
.
silly
(
'
Puppet
'
,
'
roomSearch() roomIdList filtered. result length=%d
'
,
roomIdList
.
length
)
return
roomIdList
}
...
...
@@ -772,9 +771,9 @@ export abstract class Puppet extends EventEmitter implements Sayable {
}
const
cachedPayload
=
this
.
cacheRoomPayload
.
get
(
roomId
)
if
(
cachedPayload
)
{
log
.
silly
(
'
Puppet
'
,
'
roomPayloadCache(
) cache HIT
'
)
log
.
silly
(
'
Puppet
'
,
'
roomPayloadCache(
%s) cache HIT
'
,
roomId
)
}
else
{
log
.
silly
(
'
Puppet
'
,
'
roomPayloadCache(
) cache MISS
'
)
log
.
silly
(
'
Puppet
'
,
'
roomPayloadCache(
%s) cache MISS
'
,
roomId
)
}
return
cachedPayload
...
...
src/room.ts
浏览文件 @
e418ccc8
...
...
@@ -470,14 +470,14 @@ export class Room extends Accessory implements Sayable {
await
this
.
puppet
.
roomQuit
(
this
.
id
)
}
public
topic
()
:
string
public
topic
(
newTopic
:
string
):
Promise
<
void
>
public
async
topic
()
:
Promise
<
string
>
public
async
topic
(
newTopic
:
string
):
Promise
<
void
>
/**
* SET/GET topic from the room
*
* @param {string} [newTopic] If set this para, it will change room topic.
* @returns {
(string | void)
}
* @returns {
Promise<string | void>
}
*
* @example <caption>When you say anything in a room, it will get room topic. </caption>
* const bot = Wechaty.instance()
...
...
@@ -485,7 +485,7 @@ export class Room extends Accessory implements Sayable {
* .on('message', async m => {
* const room = m.room()
* if (room) {
* const topic = room.topic()
* const topic =
await
room.topic()
* console.log(`room topic is : ${topic}`)
* }
* })
...
...
@@ -502,7 +502,7 @@ export class Room extends Accessory implements Sayable {
* }
* })
*/
public
topic
(
newTopic
?:
string
):
string
|
Promise
<
void
>
{
public
async
topic
(
newTopic
?:
string
):
Promise
<
void
|
string
>
{
log
.
verbose
(
'
Room
'
,
'
topic(%s)
'
,
newTopic
?
newTopic
:
''
)
if
(
!
this
.
isReady
())
{
log
.
warn
(
'
Room
'
,
'
topic() room not ready
'
)
...
...
@@ -510,7 +510,20 @@ export class Room extends Accessory implements Sayable {
}
if
(
typeof
newTopic
===
'
undefined
'
)
{
return
this
.
payload
&&
this
.
payload
.
topic
||
''
if
(
this
.
payload
&&
this
.
payload
.
topic
)
{
return
this
.
payload
.
topic
}
else
{
const
memberIdList
=
await
this
.
puppet
.
roomMemberList
(
this
.
id
)
const
memberList
=
memberIdList
.
filter
(
id
=>
id
!==
this
.
puppet
.
selfId
())
.
map
(
id
=>
this
.
wechaty
.
Contact
.
load
(
id
))
let
defaultTopic
=
memberList
[
0
].
name
()
for
(
let
i
=
1
;
i
<
3
&&
memberList
[
i
];
i
++
)
{
defaultTopic
+=
'
,
'
+
memberList
[
i
].
name
()
}
return
defaultTopic
}
}
const
future
=
this
.
puppet
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录