Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.Veneno.
wechaty
提交
b8328abc
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,发现更多精彩内容 >>
提交
b8328abc
编写于
6月 13, 2018
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename bridge to padchatManager
上级
a85bae8d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
62 addition
and
62 deletion
+62
-62
src/puppet-padchat/puppet-padchat.ts
src/puppet-padchat/puppet-padchat.ts
+62
-62
未找到文件。
src/puppet-padchat/puppet-padchat.ts
浏览文件 @
b8328abc
...
@@ -123,7 +123,7 @@ export class PuppetPadchat extends Puppet {
...
@@ -123,7 +123,7 @@ export class PuppetPadchat extends Puppet {
private
readonly
cachePadchatMessagePayload
:
LRU
.
Cache
<
string
,
PadchatMessagePayload
>
private
readonly
cachePadchatMessagePayload
:
LRU
.
Cache
<
string
,
PadchatMessagePayload
>
// private readonly cachePadchatRoomPayload : LRU.Cache<string, PadchatRoomRawPayload>
// private readonly cachePadchatRoomPayload : LRU.Cache<string, PadchatRoomRawPayload>
public
bridge
?:
PadchatManager
public
padchatManager
?:
PadchatManager
constructor
(
constructor
(
public
options
:
PuppetOptions
,
public
options
:
PuppetOptions
,
...
@@ -156,7 +156,7 @@ export class PuppetPadchat extends Puppet {
...
@@ -156,7 +156,7 @@ export class PuppetPadchat extends Puppet {
public
startWatchdog
():
void
{
public
startWatchdog
():
void
{
log
.
verbose
(
'
PuppetPadchat
'
,
'
initWatchdogForPuppet()
'
)
log
.
verbose
(
'
PuppetPadchat
'
,
'
initWatchdogForPuppet()
'
)
if
(
!
this
.
bridge
)
{
if
(
!
this
.
padchatManager
)
{
throw
new
Error
(
'
no bridge
'
)
throw
new
Error
(
'
no bridge
'
)
}
}
...
@@ -166,7 +166,7 @@ export class PuppetPadchat extends Puppet {
...
@@ -166,7 +166,7 @@ export class PuppetPadchat extends Puppet {
/**
/**
* Use bridge's heartbeat to feed dog
* Use bridge's heartbeat to feed dog
*/
*/
this
.
bridge
.
on
(
'
heartbeat
'
,
(
data
:
string
)
=>
{
this
.
padchatManager
.
on
(
'
heartbeat
'
,
(
data
:
string
)
=>
{
log
.
silly
(
'
PuppetPadchat
'
,
'
startWatchdog() bridge.on(heartbeat)
'
)
log
.
silly
(
'
PuppetPadchat
'
,
'
startWatchdog() bridge.on(heartbeat)
'
)
this
.
watchdog
.
feed
({
this
.
watchdog
.
feed
({
data
,
data
,
...
@@ -206,7 +206,7 @@ export class PuppetPadchat extends Puppet {
...
@@ -206,7 +206,7 @@ export class PuppetPadchat extends Puppet {
*/
*/
this
.
state
.
on
(
'
pending
'
)
this
.
state
.
on
(
'
pending
'
)
const
bridge
=
this
.
bridge
=
new
PadchatManager
({
const
bridge
=
this
.
padchatManager
=
new
PadchatManager
({
memory
:
this
.
options
.
memory
,
memory
:
this
.
options
.
memory
,
token
:
padchatToken
(),
token
:
padchatToken
(),
endpoint
:
WECHATY_PUPPET_PADCHAT_ENDPOINT
,
endpoint
:
WECHATY_PUPPET_PADCHAT_ENDPOINT
,
...
@@ -220,11 +220,11 @@ export class PuppetPadchat extends Puppet {
...
@@ -220,11 +220,11 @@ export class PuppetPadchat extends Puppet {
}
}
protected
async
login
(
selfId
:
string
):
Promise
<
void
>
{
protected
async
login
(
selfId
:
string
):
Promise
<
void
>
{
if
(
!
this
.
bridge
)
{
if
(
!
this
.
padchatManager
)
{
throw
new
Error
(
'
no bridge
'
)
throw
new
Error
(
'
no bridge
'
)
}
}
await
super
.
login
(
selfId
)
await
super
.
login
(
selfId
)
this
.
bridge
.
syncContactsAndRooms
()
this
.
padchatManager
.
syncContactsAndRooms
()
}
}
public
async
startBridge
(
bridge
:
PadchatManager
):
Promise
<
void
>
{
public
async
startBridge
(
bridge
:
PadchatManager
):
Promise
<
void
>
{
...
@@ -350,14 +350,14 @@ export class PuppetPadchat extends Puppet {
...
@@ -350,14 +350,14 @@ export class PuppetPadchat extends Puppet {
return
tryIdList
return
tryIdList
}
}
if
(
!
this
.
bridge
)
{
if
(
!
this
.
padchatManager
)
{
throw
new
Error
(
'
no manager
'
)
throw
new
Error
(
'
no manager
'
)
}
}
/**
/**
* PURGE Cache and Reload
* PURGE Cache and Reload
*/
*/
await
this
.
bridge
.
getRoomMemberIdList
(
roomId
,
true
)
await
this
.
padchatManager
.
getRoomMemberIdList
(
roomId
,
true
)
return
retry
(
new
Error
(
'
roomMemberSearch() not found
'
))
return
retry
(
new
Error
(
'
roomMemberSearch() not found
'
))
...
@@ -454,7 +454,7 @@ export class PuppetPadchat extends Puppet {
...
@@ -454,7 +454,7 @@ export class PuppetPadchat extends Puppet {
public
async
stop
():
Promise
<
void
>
{
public
async
stop
():
Promise
<
void
>
{
log
.
verbose
(
'
PuppetPadchat
'
,
'
stop()
'
)
log
.
verbose
(
'
PuppetPadchat
'
,
'
stop()
'
)
if
(
!
this
.
bridge
)
{
if
(
!
this
.
padchatManager
)
{
throw
new
Error
(
'
no bridge
'
)
throw
new
Error
(
'
no bridge
'
)
}
}
...
@@ -469,8 +469,8 @@ export class PuppetPadchat extends Puppet {
...
@@ -469,8 +469,8 @@ export class PuppetPadchat extends Puppet {
this
.
watchdog
.
sleep
()
this
.
watchdog
.
sleep
()
await
this
.
logout
()
await
this
.
logout
()
setImmediate
(()
=>
this
.
bridge
&&
this
.
bridge
.
removeAllListeners
())
setImmediate
(()
=>
this
.
padchatManager
&&
this
.
padchatManager
.
removeAllListeners
())
await
this
.
bridge
.
stop
()
await
this
.
padchatManager
.
stop
()
// await some tasks...
// await some tasks...
this
.
state
.
off
(
true
)
this
.
state
.
off
(
true
)
...
@@ -486,7 +486,7 @@ export class PuppetPadchat extends Puppet {
...
@@ -486,7 +486,7 @@ export class PuppetPadchat extends Puppet {
return
return
}
}
if
(
!
this
.
bridge
)
{
if
(
!
this
.
padchatManager
)
{
throw
new
Error
(
'
no bridge
'
)
throw
new
Error
(
'
no bridge
'
)
}
}
...
@@ -497,7 +497,7 @@ export class PuppetPadchat extends Puppet {
...
@@ -497,7 +497,7 @@ export class PuppetPadchat extends Puppet {
// await this.bridge.WXLogout()
// await this.bridge.WXLogout()
// }
// }
await
this
.
bridge
.
logout
()
await
this
.
padchatManager
.
logout
()
}
}
/**
/**
...
@@ -516,11 +516,11 @@ export class PuppetPadchat extends Puppet {
...
@@ -516,11 +516,11 @@ export class PuppetPadchat extends Puppet {
return
payload
.
alias
||
''
return
payload
.
alias
||
''
}
}
if
(
!
this
.
bridge
)
{
if
(
!
this
.
padchatManager
)
{
throw
new
Error
(
'
no bridge
'
)
throw
new
Error
(
'
no bridge
'
)
}
}
await
this
.
bridge
.
WXSetUserRemark
(
contactId
,
alias
||
''
)
await
this
.
padchatManager
.
WXSetUserRemark
(
contactId
,
alias
||
''
)
return
return
}
}
...
@@ -528,11 +528,11 @@ export class PuppetPadchat extends Puppet {
...
@@ -528,11 +528,11 @@ export class PuppetPadchat extends Puppet {
public
async
contactList
():
Promise
<
string
[]
>
{
public
async
contactList
():
Promise
<
string
[]
>
{
log
.
verbose
(
'
PuppetPadchat
'
,
'
contactList()
'
)
log
.
verbose
(
'
PuppetPadchat
'
,
'
contactList()
'
)
if
(
!
this
.
bridge
)
{
if
(
!
this
.
padchatManager
)
{
throw
new
Error
(
'
no bridge
'
)
throw
new
Error
(
'
no bridge
'
)
}
}
const
contactIdList
=
this
.
bridge
.
getContactIdList
()
const
contactIdList
=
this
.
padchatManager
.
getContactIdList
()
return
contactIdList
return
contactIdList
}
}
...
@@ -553,10 +553,10 @@ export class PuppetPadchat extends Puppet {
...
@@ -553,10 +553,10 @@ export class PuppetPadchat extends Puppet {
if
(
contactId
!==
this
.
selfId
())
{
if
(
contactId
!==
this
.
selfId
())
{
throw
new
Error
(
'
can not set avatar for others
'
)
throw
new
Error
(
'
can not set avatar for others
'
)
}
}
if
(
!
this
.
bridge
)
{
if
(
!
this
.
padchatManager
)
{
throw
new
Error
(
'
no bridge
'
)
throw
new
Error
(
'
no bridge
'
)
}
}
await
this
.
bridge
.
WXSetHeadImage
(
await
file
.
toBase64
())
await
this
.
padchatManager
.
WXSetHeadImage
(
await
file
.
toBase64
())
return
return
}
}
...
@@ -577,10 +577,10 @@ export class PuppetPadchat extends Puppet {
...
@@ -577,10 +577,10 @@ export class PuppetPadchat extends Puppet {
if
(
contactId
!==
this
.
selfId
())
{
if
(
contactId
!==
this
.
selfId
())
{
throw
new
Error
(
'
can not set avatar for others
'
)
throw
new
Error
(
'
can not set avatar for others
'
)
}
}
if
(
!
this
.
bridge
)
{
if
(
!
this
.
padchatManager
)
{
throw
new
Error
(
'
no bridge
'
)
throw
new
Error
(
'
no bridge
'
)
}
}
const
base64
=
await
this
.
bridge
.
WXGetUserQRCode
(
contactId
,
0
)
const
base64
=
await
this
.
padchatManager
.
WXGetUserQRCode
(
contactId
,
0
)
const
qrcode
=
await
fileBoxToQrcode
(
base64
)
const
qrcode
=
await
fileBoxToQrcode
(
base64
)
return
qrcode
return
qrcode
}
}
...
@@ -588,10 +588,10 @@ export class PuppetPadchat extends Puppet {
...
@@ -588,10 +588,10 @@ export class PuppetPadchat extends Puppet {
public
async
contactRawPayload
(
contactId
:
string
):
Promise
<
PadchatContactPayload
>
{
public
async
contactRawPayload
(
contactId
:
string
):
Promise
<
PadchatContactPayload
>
{
log
.
silly
(
'
PuppetPadchat
'
,
'
contactRawPayload(%s)
'
,
contactId
)
log
.
silly
(
'
PuppetPadchat
'
,
'
contactRawPayload(%s)
'
,
contactId
)
if
(
!
this
.
bridge
)
{
if
(
!
this
.
padchatManager
)
{
throw
new
Error
(
'
no bridge
'
)
throw
new
Error
(
'
no bridge
'
)
}
}
const
rawPayload
=
await
this
.
bridge
.
contactRawPayload
(
contactId
)
const
rawPayload
=
await
this
.
padchatManager
.
contactRawPayload
(
contactId
)
return
rawPayload
return
rawPayload
}
}
...
@@ -615,7 +615,7 @@ export class PuppetPadchat extends Puppet {
...
@@ -615,7 +615,7 @@ export class PuppetPadchat extends Puppet {
// TODO
// TODO
if
(
!
this
.
bridge
)
{
if
(
!
this
.
padchatManager
)
{
throw
new
Error
(
'
no bridge
'
)
throw
new
Error
(
'
no bridge
'
)
}
}
...
@@ -631,22 +631,22 @@ export class PuppetPadchat extends Puppet {
...
@@ -631,22 +631,22 @@ export class PuppetPadchat extends Puppet {
break
break
case
MessageType
.
Audio
:
case
MessageType
.
Audio
:
result
=
await
this
.
bridge
.
WXGetMsgVoice
(
rawText
)
result
=
await
this
.
padchatManager
.
WXGetMsgVoice
(
rawText
)
console
.
log
(
result
)
console
.
log
(
result
)
return
FileBox
.
fromBase64
(
result
.
data
.
image
,
'
test.slk
'
)
return
FileBox
.
fromBase64
(
result
.
data
.
image
,
'
test.slk
'
)
case
MessageType
.
Emoticon
:
case
MessageType
.
Emoticon
:
result
=
await
this
.
bridge
.
WXGetMsgImage
(
rawText
)
result
=
await
this
.
padchatManager
.
WXGetMsgImage
(
rawText
)
console
.
log
(
result
)
console
.
log
(
result
)
return
FileBox
.
fromBase64
(
result
.
data
.
image
,
'
test.gif
'
)
return
FileBox
.
fromBase64
(
result
.
data
.
image
,
'
test.gif
'
)
case
MessageType
.
Image
:
case
MessageType
.
Image
:
result
=
await
this
.
bridge
.
WXGetMsgImage
(
rawText
)
result
=
await
this
.
padchatManager
.
WXGetMsgImage
(
rawText
)
console
.
log
(
result
)
console
.
log
(
result
)
return
FileBox
.
fromBase64
(
result
.
data
.
image
,
'
test.jpg
'
)
return
FileBox
.
fromBase64
(
result
.
data
.
image
,
'
test.jpg
'
)
case
MessageType
.
Video
:
case
MessageType
.
Video
:
result
=
await
this
.
bridge
.
WXGetMsgVideo
(
rawText
)
result
=
await
this
.
padchatManager
.
WXGetMsgVideo
(
rawText
)
console
.
log
(
result
)
console
.
log
(
result
)
return
FileBox
.
fromBase64
(
result
.
data
.
image
,
'
test.mp4
'
)
return
FileBox
.
fromBase64
(
result
.
data
.
image
,
'
test.mp4
'
)
...
@@ -704,10 +704,10 @@ export class PuppetPadchat extends Puppet {
...
@@ -704,10 +704,10 @@ export class PuppetPadchat extends Puppet {
if
(
!
id
)
{
if
(
!
id
)
{
throw
Error
(
'
no id
'
)
throw
Error
(
'
no id
'
)
}
}
if
(
!
this
.
bridge
)
{
if
(
!
this
.
padchatManager
)
{
throw
new
Error
(
'
no bridge
'
)
throw
new
Error
(
'
no bridge
'
)
}
}
await
this
.
bridge
.
WXSendMsg
(
id
,
text
)
await
this
.
padchatManager
.
WXSendMsg
(
id
,
text
)
}
}
public
async
messageSendFile
(
public
async
messageSendFile
(
...
@@ -721,7 +721,7 @@ export class PuppetPadchat extends Puppet {
...
@@ -721,7 +721,7 @@ export class PuppetPadchat extends Puppet {
throw
new
Error
(
'
no id!
'
)
throw
new
Error
(
'
no id!
'
)
}
}
if
(
!
this
.
bridge
)
{
if
(
!
this
.
padchatManager
)
{
throw
new
Error
(
'
no bridge
'
)
throw
new
Error
(
'
no bridge
'
)
}
}
...
@@ -729,7 +729,7 @@ export class PuppetPadchat extends Puppet {
...
@@ -729,7 +729,7 @@ export class PuppetPadchat extends Puppet {
switch
(
type
)
{
switch
(
type
)
{
case
'
.slk
'
:
case
'
.slk
'
:
// 发送语音消息(微信silk格式语音)
// 发送语音消息(微信silk格式语音)
await
this
.
bridge
.
WXSendVoice
(
await
this
.
padchatManager
.
WXSendVoice
(
id
,
id
,
await
file
.
toBase64
(),
await
file
.
toBase64
(),
60
,
60
,
...
@@ -737,7 +737,7 @@ export class PuppetPadchat extends Puppet {
...
@@ -737,7 +737,7 @@ export class PuppetPadchat extends Puppet {
break
break
default
:
default
:
await
this
.
bridge
.
WXSendImage
(
await
this
.
padchatManager
.
WXSendImage
(
id
,
id
,
await
file
.
toBase64
(),
await
file
.
toBase64
(),
)
)
...
@@ -751,7 +751,7 @@ export class PuppetPadchat extends Puppet {
...
@@ -751,7 +751,7 @@ export class PuppetPadchat extends Puppet {
):
Promise
<
void
>
{
):
Promise
<
void
>
{
log
.
verbose
(
'
PuppetPadchat
'
,
'
messageSend("%s", %s)
'
,
JSON
.
stringify
(
receiver
),
contactId
)
log
.
verbose
(
'
PuppetPadchat
'
,
'
messageSend("%s", %s)
'
,
JSON
.
stringify
(
receiver
),
contactId
)
if
(
!
this
.
bridge
)
{
if
(
!
this
.
padchatManager
)
{
throw
new
Error
(
'
no bridge
'
)
throw
new
Error
(
'
no bridge
'
)
}
}
...
@@ -762,7 +762,7 @@ export class PuppetPadchat extends Puppet {
...
@@ -762,7 +762,7 @@ export class PuppetPadchat extends Puppet {
const
payload
=
await
this
.
contactPayload
(
contactId
)
const
payload
=
await
this
.
contactPayload
(
contactId
)
const
title
=
payload
.
name
+
'
名片
'
const
title
=
payload
.
name
+
'
名片
'
await
this
.
bridge
.
WXShareCard
(
id
,
contactId
,
title
)
await
this
.
padchatManager
.
WXShareCard
(
id
,
contactId
,
title
)
}
}
public
async
messageForward
(
public
async
messageForward
(
...
@@ -802,11 +802,11 @@ export class PuppetPadchat extends Puppet {
...
@@ -802,11 +802,11 @@ export class PuppetPadchat extends Puppet {
):
Promise
<
PadchatRoomMemberPayload
>
{
):
Promise
<
PadchatRoomMemberPayload
>
{
log
.
silly
(
'
PuppetPadchat
'
,
'
roomMemberRawPayload(%s)
'
,
roomId
)
log
.
silly
(
'
PuppetPadchat
'
,
'
roomMemberRawPayload(%s)
'
,
roomId
)
if
(
!
this
.
bridge
)
{
if
(
!
this
.
padchatManager
)
{
throw
new
Error
(
'
no bridge
'
)
throw
new
Error
(
'
no bridge
'
)
}
}
const
rawPayload
=
await
this
.
bridge
.
roomMemberRawPayload
(
roomId
,
contactId
)
const
rawPayload
=
await
this
.
padchatManager
.
roomMemberRawPayload
(
roomId
,
contactId
)
return
rawPayload
return
rawPayload
}
}
...
@@ -827,11 +827,11 @@ export class PuppetPadchat extends Puppet {
...
@@ -827,11 +827,11 @@ export class PuppetPadchat extends Puppet {
public
async
roomRawPayload
(
roomId
:
string
):
Promise
<
PadchatRoomPayload
>
{
public
async
roomRawPayload
(
roomId
:
string
):
Promise
<
PadchatRoomPayload
>
{
log
.
verbose
(
'
PuppetPadchat
'
,
'
roomRawPayload(%s)
'
,
roomId
)
log
.
verbose
(
'
PuppetPadchat
'
,
'
roomRawPayload(%s)
'
,
roomId
)
if
(
!
this
.
bridge
)
{
if
(
!
this
.
padchatManager
)
{
throw
new
Error
(
'
no bridge
'
)
throw
new
Error
(
'
no bridge
'
)
}
}
const
rawPayload
=
await
this
.
bridge
.
roomRawPayload
(
roomId
)
const
rawPayload
=
await
this
.
padchatManager
.
roomRawPayload
(
roomId
)
return
rawPayload
return
rawPayload
}
}
...
@@ -849,11 +849,11 @@ export class PuppetPadchat extends Puppet {
...
@@ -849,11 +849,11 @@ export class PuppetPadchat extends Puppet {
public
async
roomMemberList
(
roomId
:
string
):
Promise
<
string
[]
>
{
public
async
roomMemberList
(
roomId
:
string
):
Promise
<
string
[]
>
{
log
.
verbose
(
'
PuppetPadchat
'
,
'
roomMemberList(%s)
'
,
roomId
)
log
.
verbose
(
'
PuppetPadchat
'
,
'
roomMemberList(%s)
'
,
roomId
)
if
(
!
this
.
bridge
)
{
if
(
!
this
.
padchatManager
)
{
throw
new
Error
(
'
no bridge
'
)
throw
new
Error
(
'
no bridge
'
)
}
}
const
memberIdList
=
await
this
.
bridge
.
getRoomMemberIdList
(
roomId
)
const
memberIdList
=
await
this
.
padchatManager
.
getRoomMemberIdList
(
roomId
)
log
.
silly
(
'
PuppetPadchat
'
,
'
roomMemberList()=%d
'
,
memberIdList
.
length
)
log
.
silly
(
'
PuppetPadchat
'
,
'
roomMemberList()=%d
'
,
memberIdList
.
length
)
return
memberIdList
return
memberIdList
...
@@ -862,11 +862,11 @@ export class PuppetPadchat extends Puppet {
...
@@ -862,11 +862,11 @@ export class PuppetPadchat extends Puppet {
public
async
roomList
():
Promise
<
string
[]
>
{
public
async
roomList
():
Promise
<
string
[]
>
{
log
.
verbose
(
'
PuppetPadchat
'
,
'
roomList()
'
)
log
.
verbose
(
'
PuppetPadchat
'
,
'
roomList()
'
)
if
(
!
this
.
bridge
)
{
if
(
!
this
.
padchatManager
)
{
throw
new
Error
(
'
no bridge
'
)
throw
new
Error
(
'
no bridge
'
)
}
}
const
roomIdList
=
await
this
.
bridge
.
getRoomIdList
()
const
roomIdList
=
await
this
.
padchatManager
.
getRoomIdList
()
log
.
silly
(
'
PuppetPadchat
'
,
'
roomList()=%d
'
,
roomIdList
.
length
)
log
.
silly
(
'
PuppetPadchat
'
,
'
roomList()=%d
'
,
roomIdList
.
length
)
return
roomIdList
return
roomIdList
...
@@ -878,12 +878,12 @@ export class PuppetPadchat extends Puppet {
...
@@ -878,12 +878,12 @@ export class PuppetPadchat extends Puppet {
):
Promise
<
void
>
{
):
Promise
<
void
>
{
log
.
verbose
(
'
PuppetPadchat
'
,
'
roomDel(%s, %s)
'
,
roomId
,
contactId
)
log
.
verbose
(
'
PuppetPadchat
'
,
'
roomDel(%s, %s)
'
,
roomId
,
contactId
)
if
(
!
this
.
bridge
)
{
if
(
!
this
.
padchatManager
)
{
throw
new
Error
(
'
no bridge
'
)
throw
new
Error
(
'
no bridge
'
)
}
}
// Should check whether user is in the room. WXDeleteChatRoomMember won't check if user in the room automatically
// Should check whether user is in the room. WXDeleteChatRoomMember won't check if user in the room automatically
await
this
.
bridge
.
WXDeleteChatRoomMember
(
roomId
,
contactId
)
await
this
.
padchatManager
.
WXDeleteChatRoomMember
(
roomId
,
contactId
)
}
}
public
async
roomQrcode
(
roomId
:
string
):
Promise
<
string
>
{
public
async
roomQrcode
(
roomId
:
string
):
Promise
<
string
>
{
...
@@ -914,7 +914,7 @@ export class PuppetPadchat extends Puppet {
...
@@ -914,7 +914,7 @@ export class PuppetPadchat extends Puppet {
):
Promise
<
void
>
{
):
Promise
<
void
>
{
log
.
verbose
(
'
PuppetPadchat
'
,
'
roomAdd(%s, %s)
'
,
roomId
,
contactId
)
log
.
verbose
(
'
PuppetPadchat
'
,
'
roomAdd(%s, %s)
'
,
roomId
,
contactId
)
if
(
!
this
.
bridge
)
{
if
(
!
this
.
padchatManager
)
{
throw
new
Error
(
'
no bridge
'
)
throw
new
Error
(
'
no bridge
'
)
}
}
...
@@ -922,13 +922,13 @@ export class PuppetPadchat extends Puppet {
...
@@ -922,13 +922,13 @@ export class PuppetPadchat extends Puppet {
// if n <= 40 then add() else invite() ?
// if n <= 40 then add() else invite() ?
try
{
try
{
log
.
verbose
(
'
PuppetPadchat
'
,
'
roomAdd(%s, %s) try to Add
'
,
roomId
,
contactId
)
log
.
verbose
(
'
PuppetPadchat
'
,
'
roomAdd(%s, %s) try to Add
'
,
roomId
,
contactId
)
await
this
.
bridge
.
WXAddChatRoomMember
(
roomId
,
contactId
)
await
this
.
padchatManager
.
WXAddChatRoomMember
(
roomId
,
contactId
)
}
catch
(
e
)
{
}
catch
(
e
)
{
// FIXME
// FIXME
console
.
error
(
e
)
console
.
error
(
e
)
log
.
warn
(
'
PuppetPadchat
'
,
'
roomAdd(%s, %s) Add exception: %s
'
,
e
)
log
.
warn
(
'
PuppetPadchat
'
,
'
roomAdd(%s, %s) Add exception: %s
'
,
e
)
log
.
verbose
(
'
PuppetPadchat
'
,
'
roomAdd(%s, %s) try to Invite
'
,
roomId
,
contactId
)
log
.
verbose
(
'
PuppetPadchat
'
,
'
roomAdd(%s, %s) try to Invite
'
,
roomId
,
contactId
)
await
this
.
bridge
.
WXInviteChatRoomMember
(
roomId
,
contactId
)
await
this
.
padchatManager
.
WXInviteChatRoomMember
(
roomId
,
contactId
)
}
}
}
}
...
@@ -946,11 +946,11 @@ export class PuppetPadchat extends Puppet {
...
@@ -946,11 +946,11 @@ export class PuppetPadchat extends Puppet {
return
payload
.
topic
return
payload
.
topic
}
}
if
(
!
this
.
bridge
)
{
if
(
!
this
.
padchatManager
)
{
throw
new
Error
(
'
no bridge
'
)
throw
new
Error
(
'
no bridge
'
)
}
}
await
this
.
bridge
.
WXSetChatroomName
(
roomId
,
topic
)
await
this
.
padchatManager
.
WXSetChatroomName
(
roomId
,
topic
)
return
return
}
}
...
@@ -961,12 +961,12 @@ export class PuppetPadchat extends Puppet {
...
@@ -961,12 +961,12 @@ export class PuppetPadchat extends Puppet {
):
Promise
<
string
>
{
):
Promise
<
string
>
{
log
.
verbose
(
'
PuppetPadchat
'
,
'
roomCreate(%s, %s)
'
,
contactIdList
,
topic
)
log
.
verbose
(
'
PuppetPadchat
'
,
'
roomCreate(%s, %s)
'
,
contactIdList
,
topic
)
if
(
!
this
.
bridge
)
{
if
(
!
this
.
padchatManager
)
{
throw
new
Error
(
'
no bridge
'
)
throw
new
Error
(
'
no bridge
'
)
}
}
// FIXME:
// FIXME:
const
roomId
=
await
this
.
bridge
.
WXCreateChatRoom
(
contactIdList
)
const
roomId
=
await
this
.
padchatManager
.
WXCreateChatRoom
(
contactIdList
)
const
roomPayload
=
await
Misc
.
retry
(
async
(
retry
,
attempt
)
=>
{
const
roomPayload
=
await
Misc
.
retry
(
async
(
retry
,
attempt
)
=>
{
log
.
verbose
(
'
PuppetPadchat
'
,
'
roomCreate() roomId=%s retry attempt=%d
'
,
roomId
,
attempt
)
log
.
verbose
(
'
PuppetPadchat
'
,
'
roomCreate() roomId=%s retry attempt=%d
'
,
roomId
,
attempt
)
...
@@ -994,11 +994,11 @@ export class PuppetPadchat extends Puppet {
...
@@ -994,11 +994,11 @@ export class PuppetPadchat extends Puppet {
public
async
roomQuit
(
roomId
:
string
):
Promise
<
void
>
{
public
async
roomQuit
(
roomId
:
string
):
Promise
<
void
>
{
log
.
verbose
(
'
PuppetPadchat
'
,
'
roomQuit(%s)
'
,
roomId
)
log
.
verbose
(
'
PuppetPadchat
'
,
'
roomQuit(%s)
'
,
roomId
)
if
(
!
this
.
bridge
)
{
if
(
!
this
.
padchatManager
)
{
throw
new
Error
(
'
no bridge
'
)
throw
new
Error
(
'
no bridge
'
)
}
}
await
this
.
bridge
.
WXQuitChatRoom
(
roomId
)
await
this
.
padchatManager
.
WXQuitChatRoom
(
roomId
)
}
}
public
async
roomAnnounce
(
roomId
:
string
)
:
Promise
<
string
>
public
async
roomAnnounce
(
roomId
:
string
)
:
Promise
<
string
>
...
@@ -1007,14 +1007,14 @@ export class PuppetPadchat extends Puppet {
...
@@ -1007,14 +1007,14 @@ export class PuppetPadchat extends Puppet {
public
async
roomAnnounce
(
roomId
:
string
,
text
?:
string
):
Promise
<
void
|
string
>
{
public
async
roomAnnounce
(
roomId
:
string
,
text
?:
string
):
Promise
<
void
|
string
>
{
log
.
verbose
(
'
PuppetPadchat
'
,
'
roomAnnounce(%s, %s)
'
,
roomId
,
text
?
text
:
''
)
log
.
verbose
(
'
PuppetPadchat
'
,
'
roomAnnounce(%s, %s)
'
,
roomId
,
text
?
text
:
''
)
if
(
!
this
.
bridge
)
{
if
(
!
this
.
padchatManager
)
{
throw
new
Error
(
'
no bridge
'
)
throw
new
Error
(
'
no bridge
'
)
}
}
if
(
text
)
{
if
(
text
)
{
await
this
.
bridge
.
WXSetChatroomAnnouncement
(
roomId
,
text
)
await
this
.
padchatManager
.
WXSetChatroomAnnouncement
(
roomId
,
text
)
}
else
{
}
else
{
return
await
this
.
bridge
.
WXGetChatroomAnnouncement
(
roomId
)
return
await
this
.
padchatManager
.
WXGetChatroomAnnouncement
(
roomId
)
}
}
}
}
...
@@ -1029,11 +1029,11 @@ export class PuppetPadchat extends Puppet {
...
@@ -1029,11 +1029,11 @@ export class PuppetPadchat extends Puppet {
):
Promise
<
void
>
{
):
Promise
<
void
>
{
log
.
verbose
(
'
PuppetPadchat
'
,
'
friendshipVerify(%s, %s)
'
,
contactId
,
hello
)
log
.
verbose
(
'
PuppetPadchat
'
,
'
friendshipVerify(%s, %s)
'
,
contactId
,
hello
)
if
(
!
this
.
bridge
)
{
if
(
!
this
.
padchatManager
)
{
throw
new
Error
(
'
no bridge
'
)
throw
new
Error
(
'
no bridge
'
)
}
}
const
rawSearchPayload
:
WXSearchContactType
=
await
this
.
bridge
.
WXSearchContact
(
contactId
)
const
rawSearchPayload
:
WXSearchContactType
=
await
this
.
padchatManager
.
WXSearchContact
(
contactId
)
/**
/**
* If the contact is not stranger, than ussing WXSearchContact can get user_name
* If the contact is not stranger, than ussing WXSearchContact can get user_name
...
@@ -1057,7 +1057,7 @@ export class PuppetPadchat extends Puppet {
...
@@ -1057,7 +1057,7 @@ export class PuppetPadchat extends Puppet {
// Issue #1252 : what's wrong here?, Trying to fix now...
// Issue #1252 : what's wrong here?, Trying to fix now...
await
this
.
bridge
.
WXAddUser
(
await
this
.
padchatManager
.
WXAddUser
(
strangerV1
||
''
,
strangerV1
||
''
,
strangerV2
||
''
,
strangerV2
||
''
,
WXSearchContactTypeStatus
.
WXID
,
// default
WXSearchContactTypeStatus
.
WXID
,
// default
...
@@ -1081,11 +1081,11 @@ export class PuppetPadchat extends Puppet {
...
@@ -1081,11 +1081,11 @@ export class PuppetPadchat extends Puppet {
throw
new
Error
(
'
no stranger
'
)
throw
new
Error
(
'
no stranger
'
)
}
}
if
(
!
this
.
bridge
)
{
if
(
!
this
.
padchatManager
)
{
throw
new
Error
(
'
no bridge
'
)
throw
new
Error
(
'
no bridge
'
)
}
}
await
this
.
bridge
.
WXAcceptUser
(
await
this
.
padchatManager
.
WXAcceptUser
(
payload
.
stranger
,
payload
.
stranger
,
payload
.
ticket
,
payload
.
ticket
,
)
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录