Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wechaty
wechaty
提交
e0431163
W
wechaty
项目概览
wechaty
/
wechaty
上一次同步 大约 3 年
通知
305
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,发现更多精彩内容 >>
提交
e0431163
编写于
10月 13, 2016
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#40
all files passed tsc compile
上级
2c245792
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
43 addition
and
25 deletion
+43
-25
example/ding-dong-bot.ts
example/ding-dong-bot.ts
+1
-1
example/friend-bot.ts
example/friend-bot.ts
+1
-1
example/tuling123-bot.ts
example/tuling123-bot.ts
+1
-1
src/config.ts
src/config.ts
+9
-0
src/message.ts
src/message.ts
+8
-2
src/puppet-web/firer.spec.ts
src/puppet-web/firer.spec.ts
+7
-5
src/puppet-web/firer.ts
src/puppet-web/firer.ts
+5
-1
src/puppet-web/friend-request.spec.ts
src/puppet-web/friend-request.spec.ts
+4
-2
src/puppet-web/friend-request.ts
src/puppet-web/friend-request.ts
+7
-12
未找到文件。
example/ding-dong-bot.ts
浏览文件 @
e0431163
...
...
@@ -43,7 +43,7 @@ bot
.
on
(
'
logout
'
,
user
=>
log
.
info
(
'
Bot
'
,
`
${
user
.
name
()}
logouted`
))
.
on
(
'
error
'
,
e
=>
log
.
info
(
'
Bot
'
,
'
error: %s
'
,
e
))
.
on
(
'
scan
'
,
(
url
,
code
)
=>
{
if
(
!
/201|200/
.
test
(
code
))
{
if
(
!
/201|200/
.
test
(
String
(
code
)
))
{
let
loginUrl
=
url
.
replace
(
/
\/
qrcode
\/
/
,
'
/l/
'
)
require
(
'
qrcode-terminal
'
).
generate
(
loginUrl
)
}
...
...
example/friend-bot.ts
浏览文件 @
e0431163
...
...
@@ -45,7 +45,7 @@ bot
.
on
(
'
logout
'
,
user
=>
log
.
info
(
'
Bot
'
,
`
${
user
.
name
()}
logouted`
))
.
on
(
'
error
'
,
e
=>
log
.
info
(
'
Bot
'
,
'
error: %s
'
,
e
))
.
on
(
'
scan
'
,
(
url
,
code
)
=>
{
if
(
!
/201|200/
.
test
(
code
))
{
if
(
!
/201|200/
.
test
(
String
(
code
)
))
{
let
loginUrl
=
url
.
replace
(
/
\/
qrcode
\/
/
,
'
/l/
'
)
require
(
'
qrcode-terminal
'
).
generate
(
loginUrl
)
}
...
...
example/tuling123-bot.ts
浏览文件 @
e0431163
...
...
@@ -50,7 +50,7 @@ Loading...
bot
.
on
(
'
login
'
,
user
=>
log
.
info
(
'
Bot
'
,
`bot login:
${
user
}
`
))
.
on
(
'
logout
'
,
e
=>
log
.
info
(
'
Bot
'
,
'
bot logout.
'
))
.
on
(
'
scan
'
,
(
{
url
,
code
}
)
=>
{
.
on
(
'
scan
'
,
(
url
,
code
)
=>
{
console
.
log
(
`Scan QR Code in url to login:
${
code
}
\n
${
url
}
`
)
})
.
on
(
'
message
'
,
async
m
=>
{
...
...
src/config.ts
浏览文件 @
e0431163
...
...
@@ -143,11 +143,20 @@ type ScanInfo = {
code
:
number
}
type
RecommendInfo
=
{
UserName
:
string
NickName
:
string
Content
:
string
// request message
Ticket
:
string
// a pass token
VerifyFlag
:
number
}
export
default
Config
export
{
Config
,
HeadType
,
PuppetType
,
RecommendInfo
,
ScanInfo
,
WatchdogFood
,
WechatyEventName
...
...
src/message.ts
浏览文件 @
e0431163
...
...
@@ -6,7 +6,11 @@
* https://github.com/wechaty/wechaty
*
*/
import
Config
from
'
./config
'
import
{
Config
,
RecommendInfo
}
from
'
./config
'
import
Contact
from
'
./contact
'
import
Room
from
'
./room
'
import
UtilLib
from
'
./util-lib
'
...
...
@@ -21,6 +25,8 @@ type MessageRawObj = {
Status
:
string
MMDigest
:
string
MMDisplayTime
:
string
// Javascript timestamp of milliseconds
RecommendInfo
?:
RecommendInfo
}
type
MessageObj
=
{
...
...
@@ -73,7 +79,7 @@ class Message {
throw
Error
(
'
abstract method
'
)
}
constructor
(
p
rivate
rawObj
?:
MessageRawObj
)
{
constructor
(
p
ublic
rawObj
?:
MessageRawObj
)
{
Message
.
counter
++
if
(
typeof
rawObj
===
'
string
'
)
{
...
...
src/puppet-web/firer.spec.ts
浏览文件 @
e0431163
...
...
@@ -60,14 +60,15 @@ test('Firer.checkRoomJoin', t => {
let
result
contentList
.
forEach
(([
content
,
inviter
,
inviteeList
])
=>
{
result
=
Firer
.
checkRoomJoin
(
content
)
result
=
Firer
.
checkRoomJoin
(
content
as
string
)
t
.
truthy
(
result
,
'
should check room join message right for
'
+
content
)
t
.
deepEqual
(
result
[
0
],
inviteeList
,
'
should get inviteeList right
'
)
t
.
is
(
result
[
1
],
inviter
,
'
should get inviter right
'
)
})
result
=
Firer
.
checkRoomJoin
(
'
fsadfsadfsdfsdfs
'
)
t
.
false
(
result
,
'
should get false if message is not expected
'
)
t
.
throws
(()
=>
{
Firer
.
checkRoomJoin
(
'
fsadfsadfsdfsdfs
'
)
},
'
should throws if message is not expected
'
)
})
test
(
'
Firer.checkRoomLeave
'
,
t
=>
{
...
...
@@ -81,8 +82,9 @@ test('Firer.checkRoomLeave', t => {
t
.
truthy
(
leaver
,
'
should get leaver for leave message
'
)
t
.
is
(
leaver
,
data
[
1
],
'
should get leaver name right
'
)
leaver
=
Firer
.
checkRoomLeave
(
'
fafdsfsdfafa
'
)
t
.
false
(
leaver
,
'
should get false if message is not expected
'
)
t
.
throws
(()
=>
{
Firer
.
checkRoomLeave
(
'
fafdsfsdfafa
'
)
},
'
should throw if message is not expected
'
)
})
test
(
'
Firer.checkRoomTopic
'
,
t
=>
{
...
...
src/puppet-web/firer.ts
浏览文件 @
e0431163
...
...
@@ -20,6 +20,10 @@
/* tslint:disable:no-var-requires */
const
retryPromise
=
require
(
'
retry-promise
'
).
default
import
{
// RecommendInfo
}
from
'
../config
'
import
Contact
from
'
../contact
'
import
Message
from
'
../message
'
import
log
from
'
../brolog-env
'
...
...
@@ -53,7 +57,7 @@ const regexConfig = {
,
roomTopic
:
/^"
?(
.+
?)
"
?
changed the group name to "
(
.+
)
"$/
}
async
function
fireFriendRequest
(
m
)
{
async
function
fireFriendRequest
(
m
:
Message
)
{
const
info
=
m
.
rawObj
.
RecommendInfo
log
.
verbose
(
'
PuppetWebFirer
'
,
'
fireFriendRequest(%s)
'
,
info
)
...
...
src/puppet-web/friend-request.spec.ts
浏览文件 @
e0431163
...
...
@@ -3,10 +3,12 @@ import { test } from 'ava'
import
Config
from
'
../config
'
import
Contact
from
'
../contact
'
import
Message
from
'
../message
'
import
Puppet
from
'
../puppet
'
import
PuppetWebFriendRequest
from
'
./friend-request
'
Config
.
puppetInstance
({})
Config
.
puppetInstance
({
userId
:
'
xxx
'
}
as
Puppet
)
test
(
'
PuppetWebFriendRequest.receive smoking test
'
,
t
=>
{
/* tslint:disable:max-line-length */
...
...
src/puppet-web/friend-request.ts
浏览文件 @
e0431163
...
...
@@ -19,18 +19,13 @@
/* tslint:disable:no-var-requires */
const
retryPromise
=
require
(
'
retry-promise
'
).
default
import
Contact
from
'
../contact
'
import
Config
from
'
../config
'
import
FriendRequest
from
'
../friend-request
'
import
log
from
'
../brolog-env
'
type
RecommendInfo
=
{
UserName
:
string
NickName
:
string
Content
:
string
// request message
Ticket
:
string
// a pass token
VerifyFlag
:
number
}
import
Contact
from
'
../contact
'
import
{
Config
,
RecommendInfo
}
from
'
../config
'
import
FriendRequest
from
'
../friend-request
'
import
log
from
'
../brolog-env
'
class
PuppetWebFriendRequest
extends
FriendRequest
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录