Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.www.
wechaty
提交
4a37e649
W
wechaty
项目概览
.www.
/
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,发现更多精彩内容 >>
提交
4a37e649
编写于
10月 30, 2017
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactored Config
上级
add630c5
变更
17
显示空白变更内容
内联
并排
Showing
17 changed file
with
108 addition
and
160 deletion
+108
-160
bin/io-client.ts
bin/io-client.ts
+1
-1
example/api-ai-bot.ts
example/api-ai-bot.ts
+1
-1
example/contact-bot.ts
example/contact-bot.ts
+1
-1
example/ding-dong-bot.ts
example/ding-dong-bot.ts
+1
-1
example/friend-bot.ts
example/friend-bot.ts
+1
-1
example/gist-bot/index.ts
example/gist-bot/index.ts
+1
-1
example/media-file-bot.ts
example/media-file-bot.ts
+1
-1
example/room-bot.ts
example/room-bot.ts
+1
-1
example/speech-to-text-bot.ts
example/speech-to-text-bot.ts
+1
-1
example/tuling123-bot.ts
example/tuling123-bot.ts
+1
-1
src/config.spec.ts
src/config.spec.ts
+4
-4
src/config.ts
src/config.ts
+88
-140
src/io-client.ts
src/io-client.ts
+1
-1
src/io.ts
src/io.ts
+1
-1
src/profile.ts
src/profile.ts
+1
-1
src/wechaty.ts
src/wechaty.ts
+1
-1
test/wechaty.spec.ts
test/wechaty.spec.ts
+2
-2
未找到文件。
bin/io-client.ts
浏览文件 @
4a37e649
...
@@ -47,7 +47,7 @@ let token = config.token
...
@@ -47,7 +47,7 @@ let token = config.token
if
(
!
token
)
{
if
(
!
token
)
{
log
.
error
(
'
Client
'
,
'
token not found: please set WECHATY_TOKEN in environment before run io-client
'
)
log
.
error
(
'
Client
'
,
'
token not found: please set WECHATY_TOKEN in environment before run io-client
'
)
// process.exit(-1)
// process.exit(-1)
token
=
config
.
DEFAULT_TOKEN
token
=
config
.
default
.
DEFAULT_TOKEN
log
.
warn
(
'
Client
'
,
`set token to "
${
token
}
" for demo purpose`
)
log
.
warn
(
'
Client
'
,
`set token to "
${
token
}
" for demo purpose`
)
}
}
...
...
example/api-ai-bot.ts
浏览文件 @
4a37e649
...
@@ -56,7 +56,7 @@ import {
...
@@ -56,7 +56,7 @@ import {
const
APIAI_API_KEY
=
'
7217d7bce18c4bcfbe04ba7bdfaf9c08
'
const
APIAI_API_KEY
=
'
7217d7bce18c4bcfbe04ba7bdfaf9c08
'
const
brainApiAi
=
ApiAi
(
APIAI_API_KEY
)
const
brainApiAi
=
ApiAi
(
APIAI_API_KEY
)
const
bot
=
Wechaty
.
instance
({
profile
:
config
.
DEFAULT_PROFILE
})
const
bot
=
Wechaty
.
instance
({
profile
:
config
.
default
.
DEFAULT_PROFILE
})
console
.
log
(
`
console
.
log
(
`
Welcome to api.AI Wechaty Bot.
Welcome to api.AI Wechaty Bot.
...
...
example/contact-bot.ts
浏览文件 @
4a37e649
...
@@ -54,7 +54,7 @@ Please wait... I'm trying to login in...
...
@@ -54,7 +54,7 @@ Please wait... I'm trying to login in...
`
`
console
.
log
(
welcome
)
console
.
log
(
welcome
)
const
bot
=
Wechaty
.
instance
({
profile
:
config
.
DEFAULT_PROFILE
})
const
bot
=
Wechaty
.
instance
({
profile
:
config
.
default
.
DEFAULT_PROFILE
})
bot
bot
.
on
(
'
login
'
,
function
(
this
,
user
)
{
.
on
(
'
login
'
,
function
(
this
,
user
)
{
...
...
example/ding-dong-bot.ts
浏览文件 @
4a37e649
...
@@ -63,7 +63,7 @@ Please wait... I'm trying to login in...
...
@@ -63,7 +63,7 @@ Please wait... I'm trying to login in...
`
`
console
.
log
(
welcome
)
console
.
log
(
welcome
)
const
bot
=
Wechaty
.
instance
({
profile
:
config
.
DEFAULT_PROFILE
})
const
bot
=
Wechaty
.
instance
({
profile
:
config
.
default
.
DEFAULT_PROFILE
})
bot
bot
.
on
(
'
logout
'
,
user
=>
log
.
info
(
'
Bot
'
,
`
${
user
.
name
()}
logouted`
))
.
on
(
'
logout
'
,
user
=>
log
.
info
(
'
Bot
'
,
`
${
user
.
name
()}
logouted`
))
...
...
example/friend-bot.ts
浏览文件 @
4a37e649
...
@@ -57,7 +57,7 @@ Please wait... I'm trying to login in...
...
@@ -57,7 +57,7 @@ Please wait... I'm trying to login in...
`
`
console
.
log
(
welcome
)
console
.
log
(
welcome
)
const
bot
=
Wechaty
.
instance
({
profile
:
config
.
DEFAULT_PROFILE
})
const
bot
=
Wechaty
.
instance
({
profile
:
config
.
default
.
DEFAULT_PROFILE
})
bot
bot
.
on
(
'
login
'
,
user
=>
log
.
info
(
'
Bot
'
,
`
${
user
.
name
()}
logined`
))
.
on
(
'
login
'
,
user
=>
log
.
info
(
'
Bot
'
,
`
${
user
.
name
()}
logined`
))
...
...
example/gist-bot/index.ts
浏览文件 @
4a37e649
...
@@ -41,7 +41,7 @@ Please wait... I'm trying to login in...
...
@@ -41,7 +41,7 @@ Please wait... I'm trying to login in...
`
`
console
.
log
(
welcome
)
console
.
log
(
welcome
)
Wechaty
.
instance
({
profile
:
config
.
DEFAULT_PROFILE
})
Wechaty
.
instance
({
profile
:
config
.
default
.
DEFAULT_PROFILE
})
.
on
(
'
scan
'
,
(
url
,
code
)
=>
{
.
on
(
'
scan
'
,
(
url
,
code
)
=>
{
if
(
!
/201|200/
.
test
(
String
(
code
)))
{
if
(
!
/201|200/
.
test
(
String
(
code
)))
{
...
...
example/media-file-bot.ts
浏览文件 @
4a37e649
...
@@ -38,7 +38,7 @@ import {
...
@@ -38,7 +38,7 @@ import {
// MsgType,
// MsgType,
Wechaty
,
Wechaty
,
}
from
'
../
'
}
from
'
../
'
const
bot
=
Wechaty
.
instance
({
profile
:
config
.
DEFAULT_PROFILE
})
const
bot
=
Wechaty
.
instance
({
profile
:
config
.
default
.
DEFAULT_PROFILE
})
bot
bot
.
on
(
'
scan
'
,
(
url
,
code
)
=>
{
.
on
(
'
scan
'
,
(
url
,
code
)
=>
{
...
...
example/room-bot.ts
浏览文件 @
4a37e649
...
@@ -86,7 +86,7 @@ Please wait... I'm trying to login in...
...
@@ -86,7 +86,7 @@ Please wait... I'm trying to login in...
`
`
console
.
log
(
welcome
)
console
.
log
(
welcome
)
const
bot
=
Wechaty
.
instance
({
profile
:
config
.
DEFAULT_PROFILE
})
const
bot
=
Wechaty
.
instance
({
profile
:
config
.
default
.
DEFAULT_PROFILE
})
bot
bot
.
on
(
'
scan
'
,
(
url
,
code
)
=>
{
.
on
(
'
scan
'
,
(
url
,
code
)
=>
{
...
...
example/speech-to-text-bot.ts
浏览文件 @
4a37e649
...
@@ -42,7 +42,7 @@ import {
...
@@ -42,7 +42,7 @@ import {
Wechaty
,
Wechaty
,
}
from
'
../
'
}
from
'
../
'
const
bot
=
Wechaty
.
instance
({
profile
:
config
.
DEFAULT_PROFILE
})
const
bot
=
Wechaty
.
instance
({
profile
:
config
.
default
.
DEFAULT_PROFILE
})
bot
bot
.
on
(
'
scan
'
,
(
url
,
code
)
=>
{
.
on
(
'
scan
'
,
(
url
,
code
)
=>
{
...
...
example/tuling123-bot.ts
浏览文件 @
4a37e649
...
@@ -53,7 +53,7 @@ import {
...
@@ -53,7 +53,7 @@ import {
const
TULING123_API_KEY
=
'
18f25157e0446df58ade098479f74b21
'
const
TULING123_API_KEY
=
'
18f25157e0446df58ade098479f74b21
'
const
tuling
=
new
Tuling123
(
TULING123_API_KEY
)
const
tuling
=
new
Tuling123
(
TULING123_API_KEY
)
const
bot
=
Wechaty
.
instance
({
profile
:
config
.
DEFAULT_PROFILE
})
const
bot
=
Wechaty
.
instance
({
profile
:
config
.
default
.
DEFAULT_PROFILE
})
console
.
log
(
`
console
.
log
(
`
Welcome to Tuling Wechaty Bot.
Welcome to Tuling Wechaty Bot.
...
...
src/config.spec.ts
浏览文件 @
4a37e649
...
@@ -31,10 +31,10 @@ test('important variables', async t => {
...
@@ -31,10 +31,10 @@ test('important variables', async t => {
t
.
true
(
'
profile
'
in
config
,
'
should exist `profile` in Config
'
)
t
.
true
(
'
profile
'
in
config
,
'
should exist `profile` in Config
'
)
t
.
true
(
'
token
'
in
config
,
'
should exist `token` in Config
'
)
t
.
true
(
'
token
'
in
config
,
'
should exist `token` in Config
'
)
t
.
ok
(
config
.
DEFAULT_PUPPET
,
'
should export DEFAULT_PUPPET
'
)
t
.
ok
(
config
.
default
.
DEFAULT_PUPPET
,
'
should export DEFAULT_PUPPET
'
)
t
.
ok
(
config
.
DEFAULT_PROFILE
,
'
should export DEFAULT_PROFILE
'
)
t
.
ok
(
config
.
default
.
DEFAULT_PROFILE
,
'
should export DEFAULT_PROFILE
'
)
t
.
ok
(
config
.
DEFAULT_PROTOCOL
,
'
should export DEFAULT_PROTOCOL
'
)
t
.
ok
(
config
.
default
.
DEFAULT_PROTOCOL
,
'
should export DEFAULT_PROTOCOL
'
)
t
.
ok
(
config
.
DEFAULT_APIHOST
,
'
should export DEFAULT_APIHOST
'
)
t
.
ok
(
config
.
default
.
DEFAULT_APIHOST
,
'
should export DEFAULT_APIHOST
'
)
})
})
test
(
'
validApiHost()
'
,
async
t
=>
{
test
(
'
validApiHost()
'
,
async
t
=>
{
...
...
src/config.ts
浏览文件 @
4a37e649
...
@@ -21,6 +21,10 @@ import * as os from 'os'
...
@@ -21,6 +21,10 @@ import * as os from 'os'
import
*
as
path
from
'
path
'
import
*
as
path
from
'
path
'
import
*
as
readPkgUp
from
'
read-pkg-up
'
import
*
as
readPkgUp
from
'
read-pkg-up
'
import
*
as
Raven
from
'
raven
'
import
Brolog
from
'
brolog
'
import
Puppet
from
'
./puppet
'
const
pkg
=
readPkgUp
.
sync
({
cwd
:
__dirname
}).
pkg
const
pkg
=
readPkgUp
.
sync
({
cwd
:
__dirname
}).
pkg
export
const
VERSION
=
pkg
.
version
export
const
VERSION
=
pkg
.
version
...
@@ -28,7 +32,6 @@ export const VERSION = pkg.version
...
@@ -28,7 +32,6 @@ export const VERSION = pkg.version
/**
/**
* Raven.io
* Raven.io
*/
*/
import
*
as
Raven
from
'
raven
'
Raven
.
disableConsoleAlerts
()
Raven
.
disableConsoleAlerts
()
Raven
Raven
...
@@ -38,7 +41,7 @@ Raven
...
@@ -38,7 +41,7 @@ Raven
{
{
release
:
VERSION
,
release
:
VERSION
,
tags
:
{
tags
:
{
git_commit
:
'
c0deb10c4
'
,
git_commit
:
''
,
platform
:
!!
process
.
env
[
'
WECHATY_DOCKER
'
]
platform
:
!!
process
.
env
[
'
WECHATY_DOCKER
'
]
?
'
docker
'
?
'
docker
'
:
os
.
platform
(),
:
os
.
platform
(),
...
@@ -59,11 +62,7 @@ Raven.context(function () {
...
@@ -59,11 +62,7 @@ Raven.context(function () {
})
})
*/
*/
import
Brolog
from
'
brolog
'
export
const
log
=
new
Brolog
()
export
const
log
=
new
Brolog
()
import
{
Puppet
}
from
'
./puppet
'
const
logLevel
=
process
.
env
[
'
WECHATY_LOG
'
]
||
'
info
'
const
logLevel
=
process
.
env
[
'
WECHATY_LOG
'
]
||
'
info
'
if
(
logLevel
)
{
if
(
logLevel
)
{
log
.
level
(
logLevel
.
toLowerCase
()
as
any
)
log
.
level
(
logLevel
.
toLowerCase
()
as
any
)
...
@@ -73,14 +72,14 @@ if (logLevel) {
...
@@ -73,14 +72,14 @@ if (logLevel) {
/**
/**
* to handle unhandled exceptions
* to handle unhandled exceptions
*/
*/
if
(
/verbose|silly/i
.
test
(
log
Level
))
{
if
(
/verbose|silly/i
.
test
(
log
.
level
()
))
{
log
.
info
(
'
Config
'
,
'
registering process.on("unhandledRejection") for development/debug
'
)
log
.
info
(
'
Config
'
,
'
registering process.on("unhandledRejection") for development/debug
'
)
process
.
on
(
'
unhandledRejection
'
,
(
reason
,
promise
)
=>
{
process
.
on
(
'
unhandledRejection
'
,
(
reason
,
promise
)
=>
{
log
.
error
(
'
Config
'
,
'
###########################
'
)
log
.
error
(
'
Config
'
,
'
###########################
'
)
log
.
error
(
'
Config
'
,
'
unhandledRejection: %s %s
'
,
reason
,
promise
)
log
.
error
(
'
Config
'
,
'
unhandledRejection: %s %s
'
,
reason
,
promise
)
log
.
error
(
'
Config
'
,
'
###########################
'
)
log
.
error
(
'
Config
'
,
'
###########################
'
)
promise
.
catch
(
err
=>
{
promise
.
catch
(
err
=>
{
log
.
error
(
'
Config
'
,
'
unhandledRejection::
catch(%s)
'
,
err
.
message
)
log
.
error
(
'
Config
'
,
'
process.on(unhandledRejection) promise.
catch(%s)
'
,
err
.
message
)
console
.
error
(
'
Config
'
,
err
)
// I don't know if log.error has similar full trace print support like console.error
console
.
error
(
'
Config
'
,
err
)
// I don't know if log.error has similar full trace print support like console.error
})
})
})
})
...
@@ -90,104 +89,49 @@ export type PuppetName = 'web'
...
@@ -90,104 +89,49 @@ export type PuppetName = 'web'
|
'
android
'
|
'
android
'
|
'
ios
'
|
'
ios
'
export
interface
ConfigSetting
{
export
interface
DefaultSetting
{
DEFAULT_HEAD
:
number
,
DEFAULT_HEAD
:
number
,
DEFAULT_PORT
:
number
,
DEFAULT_PORT
:
number
,
DEFAULT_PUPPET
:
PuppetName
DEFAULT_PUPPET
:
PuppetName
,
DEFAULT_APIHOST
:
string
DEFAULT_APIHOST
:
string
,
DEFAULT_PROFILE
:
string
DEFAULT_PROFILE
:
string
,
DEFAULT_TOKEN
:
string
DEFAULT_TOKEN
:
string
,
DEFAULT_PROTOCOL
:
string
DEFAULT_PROTOCOL
:
string
,
profile
:
string
token
:
string
debug
:
boolean
head
:
boolean
puppet
:
PuppetName
apihost
:
string
validApiHost
:
(
host
:
string
)
=>
boolean
httpPort
:
number
_puppetInstance
:
Puppet
|
null
puppetInstance
():
Puppet
puppetInstance
(
empty
:
null
):
void
puppetInstance
(
instance
:
Puppet
):
void
puppetInstance
(
instance
?:
Puppet
|
null
):
Puppet
|
void
,
gitRevision
():
string
|
null
,
docker
:
boolean
,
}
}
/* tslint:disable:variable-name */
/* tslint:disable:variable-name */
/* tslint:disable:no-var-requires */
/* tslint:disable:no-var-requires */
export
const
config
:
ConfigSetting
=
pkg
.
wechaty
export
const
DEFAULT_SETTING
=
pkg
.
wechaty
as
DefaultSetting
/**
export
class
Config
{
* 1. ENVIRONMENT VARIABLES + PACKAGES.JSON (default)
public
default
=
DEFAULT_SETTING
*/
Object
.
assign
(
config
,
{
apihost
:
process
.
env
[
'
WECHATY_APIHOST
'
]
||
config
.
DEFAULT_APIHOST
,
head
:
(
'
WECHATY_HEAD
'
in
process
.
env
)
?
(
!!
process
.
env
[
'
WECHATY_HEAD
'
])
:
(
!!
(
config
.
DEFAULT_HEAD
)),
puppet
:
process
.
env
[
'
WECHATY_PUPPET
'
]
||
config
.
DEFAULT_PUPPET
,
validApiHost
,
})
function
validApiHost
(
apihost
:
string
):
boolean
{
public
apihost
=
process
.
env
[
'
WECHATY_APIHOST
'
]
||
DEFAULT_SETTING
.
DEFAULT_APIHOST
if
(
/^
[
a-zA-Z0-9
\.\-\_]
+:
?[
0-9
]
*$/
.
test
(
apihost
))
{
public
head
=
(
'
WECHATY_HEAD
'
in
process
.
env
)
?
(
!!
process
.
env
[
'
WECHATY_HEAD
'
])
:
(
!!
(
DEFAULT_SETTING
.
DEFAULT_HEAD
))
return
true
public
puppet
=
(
process
.
env
[
'
WECHATY_PUPPET
'
]
||
DEFAULT_SETTING
.
DEFAULT_PUPPET
)
as
PuppetName
}
throw
new
Error
(
'
validApiHost() fail for
'
+
apihost
)
}
validApiHost
(
config
.
apihost
)
/**
public
profile
=
process
.
env
[
'
WECHATY_PROFILE
'
]
||
null
// DO NOT set DEFAULT_PROFILE, because sometimes user do not want to save session
* 2. ENVIRONMENT VARIABLES (only)
public
token
=
process
.
env
[
'
WECHATY_TOKEN
'
]
||
null
// DO NOT set DEFAULT, because sometimes user do not want to connect to io cloud service
*/
public
debug
=
!!
(
process
.
env
[
'
WECHATY_DEBUG
'
])
Object
.
assign
(
config
,
{
// port: process.env['WECHATY_PORT'] || null, // 0 for disable port
profile
:
process
.
env
[
'
WECHATY_PROFILE
'
]
||
null
,
// DO NOT set DEFAULT_PROFILE, because sometimes user do not want to save session
token
:
process
.
env
[
'
WECHATY_TOKEN
'
]
||
null
,
// DO NOT set DEFAULT, because sometimes user do not want to connect to io cloud service
debug
:
!!
(
process
.
env
[
'
WECHATY_DEBUG
'
])
||
false
,
})
/**
public
httpPort
=
process
.
env
[
'
PORT
'
]
||
process
.
env
[
'
WECHATY_PORT
'
]
||
DEFAULT_SETTING
.
DEFAULT_PORT
* 3. Service Settings
public
docker
=
!!
(
process
.
env
[
'
WECHATY_DOCKER
'
])
*/
Object
.
assign
(
config
,
{
// get PORT form cloud service env, ie: heroku
httpPort
:
process
.
env
[
'
PORT
'
]
||
process
.
env
[
'
WECHATY_PORT
'
]
||
config
.
DEFAULT_PORT
,
})
/**
private
_puppetInstance
:
Puppet
|
null
=
null
* 4. Envioronment Identify
*/
Object
.
assign
(
config
,
{
docker
:
!!
process
.
env
[
'
WECHATY_DOCKER
'
],
isGlobal
:
isWechatyInstalledGlobal
(),
})
function
isWechatyInstalledGlobal
()
{
constructor
()
{
/**
log
.
verbose
(
'
Config
'
,
'
constructor()
'
)
* TODO:
this
.
validApiHost
(
this
.
apihost
)
* 1. check /node_modules/wechaty
}
* 2. return true if exists
* 3. otherwise return false
*/
return
false
}
/**
/**
* 5. live setting
* 5. live setting
*/
*/
function
puppetInstance
():
Puppet
public
puppetInstance
():
Puppet
function
puppetInstance
(
empty
:
null
):
void
public
puppetInstance
(
empty
:
null
):
void
function
puppetInstance
(
instance
:
Puppet
):
void
public
puppetInstance
(
instance
:
Puppet
):
void
function
puppetInstance
(
instance
?:
Puppet
|
null
):
Puppet
|
void
{
public
puppetInstance
(
instance
?:
Puppet
|
null
):
Puppet
|
void
{
if
(
typeof
instance
===
'
undefined
'
)
{
if
(
typeof
instance
===
'
undefined
'
)
{
if
(
!
this
.
_puppetInstance
)
{
if
(
!
this
.
_puppetInstance
)
{
...
@@ -205,9 +149,9 @@ function puppetInstance(instance?: Puppet | null): Puppet | void {
...
@@ -205,9 +149,9 @@ function puppetInstance(instance?: Puppet | null): Puppet | void {
this
.
_puppetInstance
=
instance
this
.
_puppetInstance
=
instance
return
return
}
}
function
gitVer
sion
():
string
|
null
{
public
gitRevi
sion
():
string
|
null
{
const
dotGitPath
=
path
.
join
(
__dirname
,
'
..
'
,
'
.git
'
)
// only for ts-node, not for dist
const
dotGitPath
=
path
.
join
(
__dirname
,
'
..
'
,
'
.git
'
)
// only for ts-node, not for dist
// const gitLogArgs = ['log', '--oneline', '-1']
// const gitLogArgs = ['log', '--oneline', '-1']
// TODO: use git rev-parse HEAD ?
// TODO: use git rev-parse HEAD ?
...
@@ -238,12 +182,15 @@ function gitVersion(): string | null {
...
@@ -238,12 +182,15 @@ function gitVersion(): string | null {
log
.
silly
(
'
Wechaty
'
,
'
version() form development environment is not availble: %s
'
,
e
.
message
)
log
.
silly
(
'
Wechaty
'
,
'
version() form development environment is not availble: %s
'
,
e
.
message
)
return
null
return
null
}
}
}
}
Object
.
assign
(
config
,
{
public
validApiHost
(
apihost
:
string
):
boolean
{
gitVersion
,
if
(
/^
[
a-zA-Z0-9
\.\-\_]
+:
?[
0-9
]
*$/
.
test
(
apihost
))
{
puppetInstance
,
return
true
})
}
throw
new
Error
(
'
validApiHost() fail for
'
+
apihost
)
}
}
export
interface
Sayable
{
export
interface
Sayable
{
say
(
content
:
string
,
replyTo
?:
any
|
any
[]):
Promise
<
boolean
>
say
(
content
:
string
,
replyTo
?:
any
|
any
[]):
Promise
<
boolean
>
...
@@ -257,4 +204,5 @@ export {
...
@@ -257,4 +204,5 @@ export {
Raven
,
Raven
,
}
}
export
const
config
=
new
Config
()
export
default
config
export
default
config
src/io-client.ts
浏览文件 @
4a37e649
...
@@ -47,7 +47,7 @@ export class IoClient {
...
@@ -47,7 +47,7 @@ export class IoClient {
)
{
)
{
log
.
verbose
(
'
IoClient
'
,
'
constructor({ token = %s})
'
,
options
.
token
)
log
.
verbose
(
'
IoClient
'
,
'
constructor({ token = %s})
'
,
options
.
token
)
options
.
token
=
options
.
token
||
config
.
token
||
config
.
DEFAULT_TOKEN
,
options
.
token
=
options
.
token
||
config
.
token
||
config
.
default
.
DEFAULT_TOKEN
options
.
wechaty
=
options
.
wechaty
||
Wechaty
.
instance
({
profile
:
this
.
options
.
token
})
options
.
wechaty
=
options
.
wechaty
||
Wechaty
.
instance
({
profile
:
this
.
options
.
token
})
this
.
io
=
new
Io
({
this
.
io
=
new
Io
({
...
...
src/io.ts
浏览文件 @
4a37e649
...
@@ -70,7 +70,7 @@ export class Io {
...
@@ -70,7 +70,7 @@ export class Io {
private
options
:
IoOptions
,
private
options
:
IoOptions
,
)
{
)
{
options
.
apihost
=
options
.
apihost
||
config
.
apihost
options
.
apihost
=
options
.
apihost
||
config
.
apihost
options
.
protocol
=
options
.
protocol
||
config
.
DEFAULT_PROTOCOL
options
.
protocol
=
options
.
protocol
||
config
.
default
.
DEFAULT_PROTOCOL
this
.
uuid
=
options
.
wechaty
.
uuid
this
.
uuid
=
options
.
wechaty
.
uuid
...
...
src/profile.ts
浏览文件 @
4a37e649
...
@@ -17,7 +17,7 @@ export class Profile {
...
@@ -17,7 +17,7 @@ export class Profile {
private
file
:
string
|
null
private
file
:
string
|
null
constructor
(
constructor
(
public
name
:
string
=
config
.
profile
,
public
name
=
config
.
profile
,
)
{
)
{
log
.
verbose
(
'
Profile
'
,
'
constructor(%s)
'
,
name
)
log
.
verbose
(
'
Profile
'
,
'
constructor(%s)
'
,
name
)
...
...
src/wechaty.ts
浏览文件 @
4a37e649
test/wechaty.spec.ts
浏览文件 @
4a37e649
...
@@ -59,7 +59,7 @@ test('Export of the Framework', async t => {
...
@@ -59,7 +59,7 @@ test('Export of the Framework', async t => {
test
(
'
Config setting
'
,
async
t
=>
{
test
(
'
Config setting
'
,
async
t
=>
{
t
.
ok
(
config
,
'
should export Config
'
)
t
.
ok
(
config
,
'
should export Config
'
)
t
.
ok
(
config
.
DEFAULT_PUPPET
,
'
should has DEFAULT_PUPPET
'
)
t
.
ok
(
config
.
default
.
DEFAULT_PUPPET
,
'
should has DEFAULT_PUPPET
'
)
})
})
test
(
'
event:start/stop
'
,
async
t
=>
{
test
(
'
event:start/stop
'
,
async
t
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录