Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wechaty
wechaty
提交
e64f0e70
W
wechaty
项目概览
wechaty
/
wechaty
上一次同步 接近 3 年
通知
298
Star
10499
Fork
6
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
152
列表
看板
标记
里程碑
合并请求
1
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
W
wechaty
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
152
Issue
152
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
e64f0e70
编写于
6月 10, 2018
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename qrCode to qrcode
上级
f9bf6d8a
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
41 addition
and
41 deletion
+41
-41
examples/ding-dong-bot.ts
examples/ding-dong-bot.ts
+2
-2
examples/self-testing-bot.ts
examples/self-testing-bot.ts
+3
-3
src/contact.ts
src/contact.ts
+1
-1
src/puppet-mock/puppet-mock.ts
src/puppet-mock/puppet-mock.ts
+2
-2
src/puppet-padchat/bridge.ts
src/puppet-padchat/bridge.ts
+17
-17
src/puppet-padchat/puppet-padchat.ts
src/puppet-padchat/puppet-padchat.ts
+2
-2
src/puppet-puppeteer/puppet-puppeteer.ts
src/puppet-puppeteer/puppet-puppeteer.ts
+2
-2
src/puppet-wechat4u/puppet-wechat4u.ts
src/puppet-wechat4u/puppet-wechat4u.ts
+2
-2
src/puppet/puppet.spec.ts
src/puppet/puppet.spec.ts
+2
-2
src/puppet/puppet.ts
src/puppet/puppet.ts
+4
-4
src/wechaty.ts
src/wechaty.ts
+4
-4
未找到文件。
examples/ding-dong-bot.ts
浏览文件 @
e64f0e70
...
...
@@ -73,8 +73,8 @@ bot
log
.
info
(
'
Bot
'
,
`
${
user
.
name
()}
login`
)
bot
.
say
(
'
Wechaty login
'
).
catch
(
console
.
error
)
})
.
on
(
'
scan
'
,
(
qr
Data
,
status
,
data
)
=>
{
QrcodeTerminal
.
generate
(
qr
Data
,
{
small
:
true
},
(
asciiArt
:
string
)
=>
{
.
on
(
'
scan
'
,
(
qr
code
,
status
,
data
)
=>
{
QrcodeTerminal
.
generate
(
qr
code
,
{
small
:
true
},
(
asciiArt
:
string
)
=>
{
console
.
log
(
asciiArt
)
console
.
log
(
`[
${
status
}
] Scan QR Code above url to log in: `
)
if
(
data
)
{
...
...
examples/self-testing-bot.ts
浏览文件 @
e64f0e70
...
...
@@ -75,9 +75,9 @@ bot
log
.
info
(
'
Bot
'
,
`
${
user
.
name
()}
login`
)
bot
.
say
(
'
Wechaty login
'
).
catch
(
console
.
error
)
})
.
on
(
'
scan
'
,
(
qr
Data
,
status
,
data
)
=>
{
QrcodeTerminal
.
generate
(
qr
Data
,
{
small
:
true
},
(
asciiA
rt
:
string
)
=>
{
console
.
log
(
ascii
A
rt
)
.
on
(
'
scan
'
,
(
qr
code
,
status
,
data
)
=>
{
QrcodeTerminal
.
generate
(
qr
code
,
{
small
:
true
},
(
asciia
rt
:
string
)
=>
{
console
.
log
(
ascii
a
rt
)
console
.
log
(
`[
${
status
}
] Scan QR Code above url to log in: `
)
if
(
data
)
{
console
.
log
(
data
)
...
...
src/contact.ts
浏览文件 @
e64f0e70
...
...
@@ -637,7 +637,7 @@ export class ContactSelf extends Contact {
throw
new
Error
(
'
only can get qrcode for the login userself
'
)
}
return
await
this
.
puppet
.
contactQr
C
ode
(
this
.
id
)
return
await
this
.
puppet
.
contactQr
c
ode
(
this
.
id
)
}
}
...
...
src/puppet-mock/puppet-mock.ts
浏览文件 @
e64f0e70
...
...
@@ -153,7 +153,7 @@ export class PuppetMock extends Puppet {
return
[]
}
public
async
contactQr
C
ode
(
contactId
:
string
):
Promise
<
string
>
{
public
async
contactQr
c
ode
(
contactId
:
string
):
Promise
<
string
>
{
if
(
contactId
!==
this
.
selfId
())
{
throw
new
Error
(
'
can not set avatar for others
'
)
}
...
...
@@ -352,7 +352,7 @@ export class PuppetMock extends Puppet {
log
.
verbose
(
'
PuppetMock
'
,
'
roomQuit(%s)
'
,
roomId
)
}
public
async
roomQr
C
ode
(
roomId
:
string
):
Promise
<
string
>
{
public
async
roomQr
c
ode
(
roomId
:
string
):
Promise
<
string
>
{
return
roomId
+
'
mock qrcode
'
}
...
...
src/puppet-padchat/bridge.ts
浏览文件 @
e64f0e70
...
...
@@ -45,7 +45,7 @@ export class Bridge extends PadchatRpc {
// private readonly padchatRpc : PadchatRpc
private
autoData
:
AutoDataType
private
loginScanQr
C
ode
?
:
string
private
loginScanQr
c
ode
?
:
string
private
loginScanStatus
?
:
number
private
loginTimer
?:
NodeJS
.
Timer
...
...
@@ -189,7 +189,7 @@ export class Bridge extends PadchatRpc {
this
.
releaseCache
()
this
.
selfId
=
undefined
this
.
loginScanQr
C
ode
=
undefined
this
.
loginScanQr
c
ode
=
undefined
this
.
state
.
off
(
true
)
}
...
...
@@ -231,7 +231,7 @@ export class Bridge extends PadchatRpc {
clearTimeout
(
this
.
loginTimer
)
this
.
loginTimer
=
undefined
}
this
.
loginScanQr
C
ode
=
undefined
this
.
loginScanQr
c
ode
=
undefined
this
.
loginScanStatus
=
undefined
}
...
...
@@ -257,11 +257,11 @@ export class Bridge extends PadchatRpc {
// const result = await this.padchatRpc.WXCheckQRCode()
const
result
=
await
this
.
WXCheckQRCode
()
if
(
this
.
loginScanStatus
!==
result
.
status
&&
this
.
loginScanQr
C
ode
)
{
if
(
this
.
loginScanStatus
!==
result
.
status
&&
this
.
loginScanQr
c
ode
)
{
this
.
loginScanStatus
=
result
.
status
this
.
emit
(
'
scan
'
,
this
.
loginScanQr
C
ode
,
this
.
loginScanQr
c
ode
,
this
.
loginScanStatus
,
)
}
...
...
@@ -269,7 +269,7 @@ export class Bridge extends PadchatRpc {
if
(
result
.
expired_time
&&
result
.
expired_time
<
10
)
{
// result.expire_time is second
// emit new qrcode before the old one expired
this
.
loginScanQr
C
ode
=
undefined
this
.
loginScanQr
c
ode
=
undefined
this
.
loginScanStatus
=
undefined
waitUserResponse
=
false
continue
...
...
@@ -311,21 +311,21 @@ export class Bridge extends PadchatRpc {
case
WXCheckQRCodeStatus
.
Timeout
:
log
.
silly
(
'
PuppetPadchatBridge
'
,
'
checkQrcode: Timeout
'
)
this
.
loginScanQr
C
ode
=
undefined
this
.
loginScanQr
c
ode
=
undefined
this
.
loginScanStatus
=
undefined
waitUserResponse
=
false
break
case
WXCheckQRCodeStatus
.
Cancel
:
log
.
silly
(
'
PuppetPadchatBridge
'
,
'
user cancel
'
)
this
.
loginScanQr
C
ode
=
undefined
this
.
loginScanQr
c
ode
=
undefined
this
.
loginScanStatus
=
undefined
waitUserResponse
=
false
break
default
:
log
.
warn
(
'
PadchatBridge
'
,
'
startLogin() unknown WXCheckQRCodeStatus:
'
+
result
.
status
)
this
.
loginScanQr
C
ode
=
undefined
this
.
loginScanQr
c
ode
=
undefined
this
.
loginScanStatus
=
undefined
waitUserResponse
=
false
break
...
...
@@ -334,7 +334,7 @@ export class Bridge extends PadchatRpc {
await
new
Promise
(
r
=>
setTimeout
(
r
,
1000
))
}
await
this
.
emitLoginQr
C
ode
()
await
this
.
emitLoginQr
c
ode
()
this
.
loginTimer
=
setTimeout
(()
=>
{
this
.
loginTimer
=
undefined
this
.
startLogin
()
...
...
@@ -401,7 +401,7 @@ export class Bridge extends PadchatRpc {
/**
* 1. No Auto Login, emit QrCode for scan
*/
await
this
.
emitLoginQr
C
ode
()
await
this
.
emitLoginQr
c
ode
()
return
false
}
...
...
@@ -423,7 +423,7 @@ export class Bridge extends PadchatRpc {
/**
* 3.1 Login Request Not Valid, emit QrCode for scan.
*/
await
this
.
emitLoginQr
C
ode
()
await
this
.
emitLoginQr
c
ode
()
return
false
}
else
{
...
...
@@ -435,10 +435,10 @@ export class Bridge extends PadchatRpc {
}
}
protected
async
emitLoginQr
C
ode
():
Promise
<
void
>
{
protected
async
emitLoginQr
c
ode
():
Promise
<
void
>
{
log
.
verbose
(
'
PuppetPadchatBridge
'
,
`emitLoginQrCode()`
)
if
(
this
.
loginScanQr
C
ode
)
{
if
(
this
.
loginScanQr
c
ode
)
{
throw
new
Error
(
'
qrcode exist
'
)
}
...
...
@@ -450,17 +450,17 @@ export class Bridge extends PadchatRpc {
await
this
.
WXInitialize
()
// wait 1 second and try again
await
new
Promise
(
r
=>
setTimeout
(
r
,
1000
))
return
await
this
.
emitLoginQr
C
ode
()
return
await
this
.
emitLoginQr
c
ode
()
}
const
qrCodeText
=
await
pfHelper
.
imageBase64ToQrCode
(
result
.
qr_code
)
this
.
loginScanQr
C
ode
=
qrCodeText
this
.
loginScanQr
c
ode
=
qrCodeText
this
.
loginScanStatus
=
WXCheckQRCodeStatus
.
WaitScan
this
.
emit
(
'
scan
'
,
this
.
loginScanQr
C
ode
,
this
.
loginScanQr
c
ode
,
this
.
loginScanStatus
,
)
...
...
src/puppet-padchat/puppet-padchat.ts
浏览文件 @
e64f0e70
...
...
@@ -348,7 +348,7 @@ export class PuppetPadchat extends Puppet {
return
fileBox
}
public
async
contactQr
C
ode
(
contactId
:
string
):
Promise
<
string
>
{
public
async
contactQr
c
ode
(
contactId
:
string
):
Promise
<
string
>
{
if
(
contactId
!==
this
.
selfId
())
{
throw
new
Error
(
'
can not set avatar for others
'
)
}
...
...
@@ -570,7 +570,7 @@ export class PuppetPadchat extends Puppet {
await
this
.
bridge
.
WXDeleteChatRoomMember
(
roomId
,
contactId
)
}
public
async
roomQr
C
ode
(
roomId
:
string
):
Promise
<
string
>
{
public
async
roomQr
c
ode
(
roomId
:
string
):
Promise
<
string
>
{
log
.
verbose
(
'
PuppetPadchat
'
,
'
roomQrCode(%s)
'
,
roomId
)
// TODO
...
...
src/puppet-puppeteer/puppet-puppeteer.ts
浏览文件 @
e64f0e70
...
...
@@ -775,7 +775,7 @@ export class PuppetPuppeteer extends Puppet {
}
}
public
async
contactQr
C
ode
(
contactId
:
string
):
Promise
<
string
>
{
public
async
contactQr
c
ode
(
contactId
:
string
):
Promise
<
string
>
{
if
(
contactId
!==
this
.
selfId
())
{
throw
new
Error
(
'
can not set avatar for others
'
)
}
...
...
@@ -1088,7 +1088,7 @@ export class PuppetPuppeteer extends Puppet {
log
.
warn
(
'
PuppetPuppeteer
'
,
'
roomQuit(%s) not supported by Web API
'
,
roomId
)
}
public
async
roomQr
C
ode
(
roomId
:
string
):
Promise
<
string
>
{
public
async
roomQr
c
ode
(
roomId
:
string
):
Promise
<
string
>
{
throw
new
Error
(
'
not support
'
+
roomId
)
}
...
...
src/puppet-wechat4u/puppet-wechat4u.ts
浏览文件 @
e64f0e70
...
...
@@ -316,7 +316,7 @@ export class PuppetWechat4u extends Puppet {
return
idList
}
public
async
contactQr
C
ode
(
contactId
:
string
):
Promise
<
string
>
{
public
async
contactQr
c
ode
(
contactId
:
string
):
Promise
<
string
>
{
if
(
contactId
!==
this
.
selfId
())
{
throw
new
Error
(
'
can not set avatar for others
'
)
}
...
...
@@ -830,7 +830,7 @@ export class PuppetWechat4u extends Puppet {
log
.
verbose
(
'
PuppetWechat4u
'
,
'
roomQuit(%s)
'
,
roomId
)
}
public
async
roomQr
C
ode
(
roomId
:
string
):
Promise
<
string
>
{
public
async
roomQr
c
ode
(
roomId
:
string
):
Promise
<
string
>
{
throw
new
Error
(
'
not support
'
+
roomId
)
}
...
...
src/puppet/puppet.spec.ts
浏览文件 @
e64f0e70
...
...
@@ -58,7 +58,7 @@ class PuppetTest extends Puppet {
public
async
contactAvatar
(
contactId
:
string
,
file
?:
FileBox
)
:
Promise
<
void
|
FileBox
>
{
return
{
contactId
,
file
}
as
any
}
public
async
contactList
()
:
Promise
<
string
[]
>
{
return
{}
as
any
}
public
async
contactQr
C
ode
(
contactId
:
string
)
:
Promise
<
string
>
{
return
{
contactId
}
as
any
}
public
async
contactQr
c
ode
(
contactId
:
string
)
:
Promise
<
string
>
{
return
{
contactId
}
as
any
}
public
async
contactRawPayload
(
id
:
string
)
:
Promise
<
any
>
{
return
{
id
}
as
any
}
public
async
contactRawPayloadParser
(
rawPayload
:
any
)
:
Promise
<
ContactPayload
>
{
return
{
rawPayload
}
as
any
}
...
...
@@ -101,7 +101,7 @@ class PuppetTest extends Puppet {
public
async
roomCreate
(
contactIdList
:
string
[],
topic
?:
string
)
:
Promise
<
string
>
{
return
{
contactIdList
,
topic
}
as
any
}
public
async
roomDel
(
roomId
:
string
,
contactId
:
string
)
:
Promise
<
void
>
{
return
{
roomId
,
contactId
}
as
any
}
public
async
roomQuit
(
roomId
:
string
)
:
Promise
<
void
>
{
return
{
roomId
}
as
any
}
public
async
roomQr
C
ode
(
roomId
:
string
)
:
Promise
<
string
>
{
return
{
roomId
}
as
any
}
public
async
roomQr
c
ode
(
roomId
:
string
)
:
Promise
<
string
>
{
return
{
roomId
}
as
any
}
public
async
roomTopic
(
roomId
:
string
)
:
Promise
<
string
>
public
async
roomTopic
(
roomId
:
string
,
topic
:
string
)
:
Promise
<
void
>
...
...
src/puppet/puppet.ts
浏览文件 @
e64f0e70
...
...
@@ -181,7 +181,7 @@ export abstract class Puppet extends EventEmitter implements Sayable {
public
emit
(
event
:
'
room-join
'
,
roomId
:
string
,
inviteeIdList
:
string
[],
inviterId
:
string
)
:
boolean
public
emit
(
event
:
'
room-leave
'
,
roomId
:
string
,
leaverIdList
:
string
[],
remover
?:
string
)
:
boolean
public
emit
(
event
:
'
room-topic
'
,
roomId
:
string
,
topic
:
string
,
oldTopic
:
string
,
changerId
:
string
)
:
boolean
public
emit
(
event
:
'
scan
'
,
qr
C
ode
:
string
,
status
:
number
,
data
?:
string
)
:
boolean
public
emit
(
event
:
'
scan
'
,
qr
c
ode
:
string
,
status
:
number
,
data
?:
string
)
:
boolean
public
emit
(
event
:
'
start
'
)
:
boolean
public
emit
(
event
:
'
stop
'
)
:
boolean
// Internal Usage: watchdog
...
...
@@ -211,7 +211,7 @@ export abstract class Puppet extends EventEmitter implements Sayable {
public
on
(
event
:
'
room-join
'
,
listener
:
(
roomId
:
string
,
inviteeIdList
:
string
[],
inviterId
:
string
)
=>
void
)
:
this
public
on
(
event
:
'
room-leave
'
,
listener
:
(
roomId
:
string
,
leaverIdList
:
string
[],
removerId
?:
string
)
=>
void
)
:
this
public
on
(
event
:
'
room-topic
'
,
listener
:
(
roomId
:
string
,
topic
:
string
,
oldTopic
:
string
,
changerId
:
string
)
=>
void
)
:
this
public
on
(
event
:
'
scan
'
,
listener
:
(
qr
C
ode
:
string
,
status
:
number
,
data
?:
string
)
=>
void
)
:
this
public
on
(
event
:
'
scan
'
,
listener
:
(
qr
c
ode
:
string
,
status
:
number
,
data
?:
string
)
=>
void
)
:
this
public
on
(
event
:
'
start
'
,
listener
:
()
=>
void
)
:
this
public
on
(
event
:
'
stop
'
,
listener
:
()
=>
void
)
:
this
// Internal Usage: watchdog
...
...
@@ -361,7 +361,7 @@ export abstract class Puppet extends EventEmitter implements Sayable {
public
abstract
async
contactList
()
:
Promise
<
string
[]
>
public
abstract
async
contactQr
C
ode
(
contactId
:
string
)
:
Promise
<
string
>
public
abstract
async
contactQr
c
ode
(
contactId
:
string
)
:
Promise
<
string
>
public
abstract
async
contactRawPayload
(
contactId
:
string
)
:
Promise
<
any
>
public
abstract
async
contactRawPayloadParser
(
rawPayload
:
any
)
:
Promise
<
ContactPayload
>
...
...
@@ -634,7 +634,7 @@ export abstract class Puppet extends EventEmitter implements Sayable {
public
abstract
async
roomTopic
(
roomId
:
string
,
topic
:
string
)
:
Promise
<
void
>
public
abstract
async
roomTopic
(
roomId
:
string
,
topic
?:
string
)
:
Promise
<
string
|
void
>
public
abstract
async
roomQr
C
ode
(
roomId
:
string
)
:
Promise
<
string
>
public
abstract
async
roomQr
c
ode
(
roomId
:
string
)
:
Promise
<
string
>
public
abstract
async
roomList
()
:
Promise
<
string
[]
>
public
abstract
async
roomMemberList
(
roomId
:
string
)
:
Promise
<
string
[]
>
...
...
src/wechaty.ts
浏览文件 @
e64f0e70
...
...
@@ -254,7 +254,7 @@ export class Wechaty extends Accessory implements Sayable {
public
emit
(
event
:
'
room-join
'
,
room
:
Room
,
inviteeList
:
Contact
[],
inviter
:
Contact
)
:
boolean
public
emit
(
event
:
'
room-leave
'
,
room
:
Room
,
leaverList
:
Contact
[],
remover
?
:
Contact
)
:
boolean
public
emit
(
event
:
'
room-topic
'
,
room
:
Room
,
topic
:
string
,
oldTopic
:
string
,
changer
:
Contact
)
:
boolean
public
emit
(
event
:
'
scan
'
,
qr
Data
:
string
,
status
:
number
,
data
?:
string
)
:
boolean
public
emit
(
event
:
'
scan
'
,
qr
code
:
string
,
status
:
number
,
data
?:
string
)
:
boolean
public
emit
(
event
:
'
start
'
)
:
boolean
public
emit
(
event
:
'
stop
'
)
:
boolean
...
...
@@ -277,7 +277,7 @@ export class Wechaty extends Accessory implements Sayable {
public
on
(
event
:
'
room-join
'
,
listener
:
string
|
((
this
:
Wechaty
,
room
:
Room
,
inviteeList
:
Contact
[],
inviter
:
Contact
)
=>
void
))
:
this
public
on
(
event
:
'
room-leave
'
,
listener
:
string
|
((
this
:
Wechaty
,
room
:
Room
,
leaverList
:
Contact
[],
remover
?:
Contact
)
=>
void
))
:
this
public
on
(
event
:
'
room-topic
'
,
listener
:
string
|
((
this
:
Wechaty
,
room
:
Room
,
topic
:
string
,
oldTopic
:
string
,
changer
:
Contact
)
=>
void
))
:
this
public
on
(
event
:
'
scan
'
,
listener
:
string
|
((
this
:
Wechaty
,
qr
Data
:
string
,
status
:
number
,
data
?:
string
)
=>
void
))
:
this
public
on
(
event
:
'
scan
'
,
listener
:
string
|
((
this
:
Wechaty
,
qr
code
:
string
,
status
:
number
,
data
?:
string
)
=>
void
))
:
this
public
on
(
event
:
'
start
'
,
listener
:
string
|
((
this
:
Wechaty
)
=>
void
))
:
this
public
on
(
event
:
'
stop
'
,
listener
:
string
|
((
this
:
Wechaty
)
=>
void
))
:
this
...
...
@@ -643,8 +643,8 @@ export class Wechaty extends Accessory implements Sayable {
case
'
scan
'
:
puppet
.
removeAllListeners
(
'
scan
'
)
puppet
.
on
(
'
scan
'
,
async
(
qr
Code
,
statusCode
,
data
)
=>
{
this
.
emit
(
'
scan
'
,
qr
Code
,
statusCode
,
data
)
puppet
.
on
(
'
scan
'
,
async
(
qr
code
,
status
,
data
)
=>
{
this
.
emit
(
'
scan
'
,
qr
code
,
status
,
data
)
})
break
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录