Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.Veneno.
wechaty
提交
39e5a8d5
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,发现更多精彩内容 >>
提交
39e5a8d5
编写于
11月 03, 2017
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
差异文件
merge
上级
5d05ef00
38ee4652
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
34 addition
and
28 deletion
+34
-28
Dockerfile
Dockerfile
+5
-1
Dockerfile.onbuild
Dockerfile.onbuild
+2
-4
bin/entrypoint.sh
bin/entrypoint.sh
+1
-1
example/ding-dong-bot.ts
example/ding-dong-bot.ts
+4
-4
package.json
package.json
+1
-1
src/contact.ts
src/contact.ts
+5
-9
src/io.ts
src/io.ts
+15
-7
src/room.ts
src/room.ts
+1
-1
未找到文件。
Dockerfile
浏览文件 @
39e5a8d5
FROM
ubuntu:17.10
LABEL
maintainer="Huan LI <zixia@zixia.net>"
ENV
NPM_CONFIG_LOGLEVEL warn
ENV
DEBIAN_FRONTEND noninteractive
ENV
LC_ALL C.UTF-8
ENV
NODE_ENV $NODE_ENV
ENV
NPM_CONFIG_LOGLEVEL warn
# Installing the 'apt-utils' package gets rid of the 'debconf: delaying package configuration, since apt-utils is not installed'
# error message when installing any other package with the apt-get package manager.
...
...
@@ -10,10 +12,12 @@ ENV DEBIAN_FRONTEND noninteractive
RUN
apt-get update
&&
apt-get
install
-y
--no-install-recommends
\
apt-utils
\
bash
\
build-essential
\
ca-certificates
\
curl
\
coreutils
\
figlet
\
git
\
jq
\
libav-tools
\
moreutils
\
...
...
Dockerfile.onbuild
浏览文件 @
39e5a8d5
FROM zixia/wechaty
RUN sudo mkdir /app/ \
&& sudo chown -R bot:bot /app/
WORKDIR /app/
ONBUILD ARG NODE_ENV
ONBUILD ENV NODE_ENV $NODE_ENV
ONBUILD WORKDIR /bot
ONBUILD COPY package.json .
ONBUILD RUN npm install && npm cache clean && rm -fr /tmp/* ~/.npm
ONBUILD COPY . .
...
...
bin/entrypoint.sh
浏览文件 @
39e5a8d5
...
...
@@ -119,7 +119,7 @@ function wechaty::runBot() {
# NPM module install will have problem in China.
# i.e. chromedriver need to visit a google host to download binarys.
#
echo
"Please make sure you had installed all the NPM modules which is depended
by
your bot script."
echo
"Please make sure you had installed all the NPM modules which is depended
on
your bot script."
# yarn < /dev/null || return $? # yarn will close stdin??? cause `read` command fail after yarn
}
...
...
example/ding-dong-bot.ts
浏览文件 @
39e5a8d5
...
...
@@ -50,13 +50,13 @@ const welcome = `
=============== Powered by Wechaty ===============
-------- https://github.com/chatie/wechaty --------
I'm a bot, my super
power is talk in Wechat.
I'm a bot, my superpower is talk in Wechat.
If you send me a 'ding', I will reply you a 'dong'!
__________________________________________________
Hope you like it, and you are very welcome to
upgrade me
for more super
powers!
upgrade me
to more super
powers!
Please wait... I'm trying to login in...
...
...
@@ -68,7 +68,7 @@ const bot = Wechaty.instance({ profile: config.default.DEFAULT_PROFILE })
bot
.
on
(
'
logout
'
,
user
=>
log
.
info
(
'
Bot
'
,
`
${
user
.
name
()}
logouted`
))
.
on
(
'
login
'
,
user
=>
{
log
.
info
(
'
Bot
'
,
`
${
user
.
name
()}
login
ed
`
)
log
.
info
(
'
Bot
'
,
`
${
user
.
name
()}
login`
)
bot
.
say
(
'
Wechaty login
'
).
catch
(
console
.
error
)
})
.
on
(
'
scan
'
,
(
url
,
code
)
=>
{
...
...
@@ -76,7 +76,7 @@ bot
const
loginUrl
=
url
.
replace
(
/
\/
qrcode
\/
/
,
'
/l/
'
)
QrcodeTerminal
.
generate
(
loginUrl
)
}
console
.
log
(
`
${
url
}
\n[
${
code
}
] Scan QR Code
in above url to log
in: `
)
console
.
log
(
`
${
url
}
\n[
${
code
}
] Scan QR Code
above url to log
in: `
)
})
.
on
(
'
message
'
,
async
m
=>
{
try
{
...
...
package.json
浏览文件 @
39e5a8d5
{
"name"
:
"wechaty"
,
"version"
:
"0.1
2
.3"
,
"version"
:
"0.1
3
.3"
,
"description"
:
"Wechat for Bot(Personal Account)"
,
"main"
:
"dist/index.js"
,
"types"
:
"dist/index.d.ts"
,
...
...
src/contact.ts
浏览文件 @
39e5a8d5
...
...
@@ -109,7 +109,7 @@ export class Contact implements Sayable {
private
static
pool
=
new
Map
<
string
,
Contact
>
()
public
obj
:
ContactObj
|
null
private
dirtyObj
:
ContactObj
|
null
//
private dirtyObj: ContactObj | null
private
rawObj
:
ContactRawObj
/**
...
...
@@ -564,11 +564,6 @@ export class Contact implements Sayable {
return
!!
(
this
.
obj
&&
this
.
obj
.
id
&&
this
.
obj
.
name
)
}
// public refresh() {
// log.warn('Contact', 'refresh() DEPRECATED. use reload() instead.')
// return this.reload()
// }
/**
* Force reload data for Contact
*
...
...
@@ -577,9 +572,10 @@ export class Contact implements Sayable {
* await contact.refresh()
*/
public
async
refresh
():
Promise
<
this
>
{
if
(
this
.
isReady
())
{
this
.
dirtyObj
=
this
.
obj
}
// TODO: make sure the contact.* works when we are refreshing the data
// if (this.isReady()) {
// this.dirtyObj = this.obj
// }
this
.
obj
=
null
return
this
.
ready
()
}
...
...
src/io.ts
浏览文件 @
39e5a8d5
...
...
@@ -253,12 +253,17 @@ export class Io {
const
payload
=
ioEvent
.
payload
if
(
payload
.
onMessage
)
{
const
script
=
payload
.
script
/* tslint:disable:no-eval */
const
fn
=
eval
(
script
)
if
(
typeof
fn
===
'
function
'
)
{
this
.
onMessage
=
fn
}
else
{
log
.
warn
(
'
Io
'
,
'
server pushed function is invalid
'
)
try
{
/* tslint:disable:no-eval */
const
fn
=
eval
(
script
)
if
(
typeof
fn
===
'
function
'
)
{
this
.
onMessage
=
fn
}
else
{
log
.
warn
(
'
Io
'
,
'
server pushed function is invalid
'
)
}
}
catch
(
e
)
{
log
.
warn
(
'
Io
'
,
'
server pushed function exception: %s
'
,
e
)
this
.
options
.
wechaty
.
emit
(
'
error
'
,
e
)
}
}
break
...
...
@@ -421,8 +426,11 @@ export class Io {
* Prepare to be overwriten by server setting
*
*/
private
ioMessage
(
m
)
{
private
async
ioMessage
(
m
):
Promise
<
void
>
{
log
.
silly
(
'
Io
'
,
'
ioMessage() is a nop function before be overwriten from cloud
'
)
if
(
typeof
this
.
onMessage
===
'
function
'
)
{
await
this
.
onMessage
(
m
)
}
}
}
...
...
src/room.ts
浏览文件 @
39e5a8d5
...
...
@@ -844,7 +844,7 @@ export class Room extends EventEmitter implements Sayable {
.
catch
(
e
=>
{
log
.
verbose
(
'
Room
'
,
'
findAll() rejected: %s
'
,
e
.
message
)
Raven
.
captureException
(
e
)
return
[]
// fail safe
return
[]
as
Room
[]
// fail safe
})
await
Promise
.
all
(
roomList
.
map
(
room
=>
room
.
ready
()))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录