Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.www.
wechaty
提交
014f5781
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,发现更多精彩内容 >>
提交
014f5781
编写于
11月 03, 2016
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
require module at the begining of code
上级
580a71f1
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
58 addition
and
10 deletion
+58
-10
example/api-ai-bot.ts
example/api-ai-bot.ts
+9
-1
example/contact-bot.ts
example/contact-bot.ts
+5
-1
example/ding-dong-bot.ts
example/ding-dong-bot.ts
+5
-1
example/friend-bot.ts
example/friend-bot.ts
+5
-1
example/image-bot.ts
example/image-bot.ts
+9
-1
example/roger-bot.ts
example/roger-bot.ts
+9
-1
example/room-bot.ts
example/room-bot.ts
+9
-2
example/tuling123-bot.ts
example/tuling123-bot.ts
+7
-2
未找到文件。
example/api-ai-bot.ts
浏览文件 @
014f5781
...
...
@@ -10,6 +10,10 @@
* Wechaty - https://github.com/zixia/wechaty
*
*/
/* tslint:disable:variable-name */
const
QrcodeTerminal
=
require
(
'
qrcode-terminal
'
)
import
{
Brolog
as
log
}
from
'
brolog
'
/* tslint:disable:no-var-requires */
const
co
=
require
(
'
co
'
)
...
...
@@ -47,7 +51,11 @@ Loading... please wait for QrCode Image Url and then scan to login.
bot
.
on
(
'
scan
'
,
(
url
,
code
)
=>
{
console
.
log
(
`[
${
code
}
]Scan QR Code in url to login:\n
${
url
}
`
)
if
(
!
/201|200/
.
test
(
String
(
code
)))
{
let
loginUrl
=
url
.
replace
(
/
\/
qrcode
\/
/
,
'
/l/
'
)
QrcodeTerminal
.
generate
(
loginUrl
)
}
console
.
log
(
`
${
url
}
\n[
${
code
}
] Scan QR Code in above url to login: `
)
})
.
on
(
'
login
'
,
user
=>
log
.
info
(
'
Bot
'
,
`bot login:
${
user
}
`
))
.
on
(
'
logout
'
,
e
=>
log
.
info
(
'
Bot
'
,
'
bot logout.
'
))
...
...
example/contact-bot.ts
浏览文件 @
014f5781
...
...
@@ -6,6 +6,10 @@
* https://github.com/wechaty/wechaty
*
*/
/* tslint:disable:variable-name */
const
QrcodeTerminal
=
require
(
'
qrcode-terminal
'
)
import
{
Config
,
Contact
...
...
@@ -51,7 +55,7 @@ bot
.
on
(
'
scan
'
,
(
url
,
code
)
=>
{
if
(
!
/201|200/
.
test
(
String
(
code
)))
{
let
loginUrl
=
url
.
replace
(
/
\/
qrcode
\/
/
,
'
/l/
'
)
require
(
'
qrcode-terminal
'
)
.
generate
(
loginUrl
)
QrcodeTerminal
.
generate
(
loginUrl
)
}
console
.
log
(
`
${
url
}
\n[
${
code
}
] Scan QR Code in above url to login: `
)
})
...
...
example/ding-dong-bot.ts
浏览文件 @
014f5781
...
...
@@ -6,6 +6,10 @@
* https://github.com/wechaty/wechaty
*
*/
/* tslint:disable:variable-name */
const
QrcodeTerminal
=
require
(
'
qrcode-terminal
'
)
import
{
Wechaty
,
Config
...
...
@@ -45,7 +49,7 @@ bot
.
on
(
'
scan
'
,
(
url
,
code
)
=>
{
if
(
!
/201|200/
.
test
(
String
(
code
)))
{
let
loginUrl
=
url
.
replace
(
/
\/
qrcode
\/
/
,
'
/l/
'
)
require
(
'
qrcode-terminal
'
)
.
generate
(
loginUrl
)
QrcodeTerminal
.
generate
(
loginUrl
)
}
console
.
log
(
`
${
url
}
\n[
${
code
}
] Scan QR Code in above url to login: `
)
})
...
...
example/friend-bot.ts
浏览文件 @
014f5781
...
...
@@ -6,6 +6,10 @@
* https://github.com/wechaty/wechaty
*
*/
/* tslint:disable:variable-name */
const
QrcodeTerminal
=
require
(
'
qrcode-terminal
'
)
import
{
Wechaty
,
Message
...
...
@@ -47,7 +51,7 @@ bot
.
on
(
'
scan
'
,
(
url
,
code
)
=>
{
if
(
!
/201|200/
.
test
(
String
(
code
)))
{
let
loginUrl
=
url
.
replace
(
/
\/
qrcode
\/
/
,
'
/l/
'
)
require
(
'
qrcode-terminal
'
)
.
generate
(
loginUrl
)
QrcodeTerminal
.
generate
(
loginUrl
)
}
console
.
log
(
`
${
url
}
\n[
${
code
}
] Scan QR Code in above url to login: `
)
})
...
...
example/image-bot.ts
浏览文件 @
014f5781
...
...
@@ -6,6 +6,10 @@
* https://github.com/wechaty/wechaty
*
*/
/* tslint:disable:variable-name */
const
QrcodeTerminal
=
require
(
'
qrcode-terminal
'
)
import
{
Message
,
Wechaty
...
...
@@ -14,7 +18,11 @@ const bot = Wechaty.instance({ profile: 'example-bot.wechaty.json' })
bot
.
on
(
'
scan
'
,
(
url
,
code
)
=>
{
console
.
log
(
`Use Wechat to Scan QR Code in url to login:
${
code
}
\n
${
url
}
`
)
if
(
!
/201|200/
.
test
(
String
(
code
)))
{
let
loginUrl
=
url
.
replace
(
/
\/
qrcode
\/
/
,
'
/l/
'
)
QrcodeTerminal
.
generate
(
loginUrl
)
}
console
.
log
(
`
${
url
}
\n[
${
code
}
] Scan QR Code in above url to login: `
)
})
.
on
(
'
message
'
,
m
=>
{
console
.
log
(
`RECV:
${
m
}
`
)
...
...
example/roger-bot.ts
浏览文件 @
014f5781
...
...
@@ -6,12 +6,20 @@
* https://github.com/wechaty/wechaty
*
*/
/* tslint:disable:variable-name */
const
QrcodeTerminal
=
require
(
'
qrcode-terminal
'
)
import
{
Wechaty
}
from
'
../
'
const
bot
=
Wechaty
.
instance
(
/* no profile here because roger bot is too noisy */
)
bot
.
on
(
'
scan
'
,
(
url
,
code
)
=>
{
console
.
log
(
`Use Wechat to Scan QR Code in url to login:
${
code
}
\n
${
url
}
`
)
if
(
!
/201|200/
.
test
(
String
(
code
)))
{
let
loginUrl
=
url
.
replace
(
/
\/
qrcode
\/
/
,
'
/l/
'
)
QrcodeTerminal
.
generate
(
loginUrl
)
}
console
.
log
(
`
${
url
}
\n[
${
code
}
] Scan QR Code in above url to login: `
)
})
.
on
(
'
message
'
,
m
=>
{
if
(
bot
.
self
(
m
))
{
return
}
...
...
example/room-bot.ts
浏览文件 @
014f5781
...
...
@@ -34,6 +34,9 @@ const HELPER_CONTACT_NAME = 'Bruce LEE'
*
*/
/* tslint:disable:variable-name */
const
QrcodeTerminal
=
require
(
'
qrcode-terminal
'
)
import
{
Config
,
Contact
...
...
@@ -71,8 +74,12 @@ console.log(welcome)
const
bot
=
Wechaty
.
instance
({
profile
:
Config
.
DEFAULT_PROFILE
})
bot
.
on
(
'
scan
'
,
function
(
url
,
code
)
{
console
.
log
(
`Use Wechat to Scan QR Code in url to login:
${
code
}
\n
${
url
}
`
)
.
on
(
'
scan
'
,
(
url
,
code
)
=>
{
if
(
!
/201|200/
.
test
(
String
(
code
)))
{
let
loginUrl
=
url
.
replace
(
/
\/
qrcode
\/
/
,
'
/l/
'
)
QrcodeTerminal
.
generate
(
loginUrl
)
}
console
.
log
(
`
${
url
}
\n[
${
code
}
] Scan QR Code in above url to login: `
)
})
.
on
(
'
logout
'
,
user
=>
log
.
info
(
'
Bot
'
,
`
${
user
.
name
()}
logouted`
))
.
on
(
'
error
'
,
e
=>
log
.
info
(
'
Bot
'
,
'
error: %s
'
,
e
))
...
...
example/tuling123-bot.ts
浏览文件 @
014f5781
...
...
@@ -12,7 +12,8 @@
*/
/* tslint:disable:no-var-requires */
/* tslint:disable:variable-name */
const
Tuling123
=
require
(
'
tuling123-client
'
)
const
QrcodeTerminal
=
require
(
'
qrcode-terminal
'
)
const
Tuling123
=
require
(
'
tuling123-client
'
)
import
{
EventEmitter
}
from
'
events
'
...
...
@@ -50,7 +51,11 @@ bot
.
on
(
'
login
'
,
user
=>
log
.
info
(
'
Bot
'
,
`bot login:
${
user
}
`
))
.
on
(
'
logout
'
,
e
=>
log
.
info
(
'
Bot
'
,
'
bot logout.
'
))
.
on
(
'
scan
'
,
(
url
,
code
)
=>
{
console
.
log
(
`Scan QR Code in url to login:
${
code
}
\n
${
url
}
`
)
if
(
!
/201|200/
.
test
(
String
(
code
)))
{
let
loginUrl
=
url
.
replace
(
/
\/
qrcode
\/
/
,
'
/l/
'
)
QrcodeTerminal
.
generate
(
loginUrl
)
}
console
.
log
(
`
${
url
}
\n[
${
code
}
] Scan QR Code in above url to login: `
)
})
.
on
(
'
message
'
,
async
m
=>
{
if
(
m
.
self
())
return
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录