Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ios and Android
Xdd 优化NodeJS微信机器人
提交
202366db
X
Xdd 优化NodeJS微信机器人
项目概览
ios and Android
/
Xdd 优化NodeJS微信机器人
与 Fork 源项目一致
Fork自
inscode / NodeJS
通知
1
Star
0
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xdd 优化NodeJS微信机器人
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
202366db
编写于
2月 15, 2024
作者:
Q
qq_21051503
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Thu Feb 15 16:53:00 CST 2024 inscode
上级
34484e4b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
257 addition
and
257 deletion
+257
-257
index.js
index.js
+257
-257
未找到文件。
index.js
浏览文件 @
202366db
...
@@ -4,286 +4,286 @@
...
@@ -4,286 +4,286 @@
//1、微信扫码(17年注册的微信可以直接扫,17年后注册的微信自己要绑定手机号和个人认证下,我记得还要开通收付款。)
//1、微信扫码(17年注册的微信可以直接扫,17年后注册的微信自己要绑定手机号和个人认证下,我记得还要开通收付款。)
//2、本机器人只适用于微信群聊时触发,私聊无法触发
//2、本机器人只适用于微信群聊时触发,私聊无法触发
//3、扫码之后,在群里@小白+关键字(比如@小白抽签,或者小白厦门天气,所有关键字在)
//3、扫码之后,在群里@小白+关键字(比如@小白抽签,或者小白厦门天气,所有关键字在)
process
.
on
(
'
uncaughtException
'
,
function
(
err
)
{
process
.
on
(
'
uncaughtException
'
,
function
(
err
)
{
console
.
log
(
'
Caught exception:
'
+
err
);
console
.
log
(
'
Caught exception:
'
+
err
);
});
});
import
{
FileBox
}
from
'
file-box
'
import
{
FileBox
}
from
'
file-box
'
import
QrcodeTerminal
from
'
qrcode-terminal
'
import
QrcodeTerminal
from
'
qrcode-terminal
'
import
axios
from
"
axios
"
import
axios
from
"
axios
"
import
{
WechatyBuilder
}
from
'
wechaty
'
import
{
WechatyBuilder
}
from
'
wechaty
'
const
ajax
=
async
(
url
,
param
,
type
)
=>
{
const
ajax
=
async
(
url
,
param
,
type
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
var
axiosOption
=
{
var
axiosOption
=
{
method
:
type
?
type
:
"
get
"
,
method
:
type
?
type
:
"
get
"
,
url
:
url
,
url
:
url
,
data
:
param
,
data
:
param
,
timeout
:
0
,
// 10秒
timeout
:
0
,
// 10秒
headers
:
{
headers
:
{
'
Content-Type
'
:
'
application/json;charset=utf-8
'
'
Content-Type
'
:
'
application/json;charset=utf-8
'
}
}
}
}
axios
(
axiosOption
).
then
(
function
(
res
)
{
axios
(
axiosOption
).
then
(
function
(
res
)
{
resolve
(
res
)
resolve
(
res
)
}).
catch
(
error
=>
{
}).
catch
(
error
=>
{
console
.
log
(
error
)
console
.
log
(
error
)
})
})
})
})
}
}
const
page
=
{
const
page
=
{
data
:
{
data
:
{
// qunArr:[
// qunArr:[
// "北京web前后端、ui交流群",
// "北京web前后端、ui交流群",
// "公众号:程序员野区群",
// "公众号:程序员野区群",
// "小程序:程序员实用资源群",
// "小程序:程序员实用资源群",
// "视频号:程序员整活日常群",
// "视频号:程序员整活日常群",
// ],
// ],
token
:
"
bwT9c8eYI6AHu23EYofE8HOPZ7meY7
"
,
token
:
"
bwT9c8eYI6AHu23EYofE8HOPZ7meY7
"
,
signature
:
null
,
signature
:
null
,
wechaty
:
null
wechaty
:
null
},
},
async
mounted
()
{
async
mounted
()
{
let
m
=
this
;
let
m
=
this
;
await
m
.
methods
.
wxjqrInit
();
await
m
.
methods
.
wxjqrInit
();
this
.
methods
.
wechatyInit
();
this
.
methods
.
wechatyInit
();
},
},
methods
:
{
methods
:
{
//微信机器人登录
//微信机器人登录
wxjqrInit
()
{
wxjqrInit
()
{
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
let
res
=
await
ajax
(
"
https://chatbot.weixin.qq.com/openapi/sign/
"
+
page
.
data
.
token
,
{
let
res
=
await
ajax
(
"
https://chatbot.weixin.qq.com/openapi/sign/
"
+
page
.
data
.
token
,
{
userid
:
1
userid
:
1
},
"
post
"
)
},
"
post
"
)
page
.
data
.
signature
=
res
.
data
.
signature
;
page
.
data
.
signature
=
res
.
data
.
signature
;
resolve
()
resolve
()
});
});
},
},
async
wechatyInit
()
{
async
wechatyInit
()
{
page
.
data
.
wechaty
=
WechatyBuilder
.
build
()
page
.
data
.
wechaty
=
WechatyBuilder
.
build
()
page
.
data
.
wechaty
.
on
(
'
scan
'
,
(
qrcode
,
status
)
=>
{
page
.
data
.
wechaty
.
on
(
'
scan
'
,
(
qrcode
,
status
)
=>
{
console
.
log
(
"
开发教程地址:https://mp.weixin.qq.com/mp/appmsgalbum?__biz=MzI1NjAxODkzMg==&action=getalbum&album_id=3102070220246171651&scene=173&from_msgid=2572037584&from_itemidx=1&count=3&nolastread=1&uin=&key=&devicetype=Windows+10+x64&version=6309071d&lang=zh_CN&ascene=0
"
)
console
.
log
(
"
开发教程地址:https://mp.weixin.qq.com/mp/appmsgalbum?__biz=MzI1NjAxODkzMg==&action=getalbum&album_id=3102070220246171651&scene=173&from_msgid=2572037584&from_itemidx=1&count=3&nolastread=1&uin=&key=&devicetype=Windows+10+x64&version=6309071d&lang=zh_CN&ascene=0
"
)
console
.
log
(
`目前关键字有["抽签", "天气", "讲笑话", "讲情话", "梦到", "解第", "动漫图", "去水印-", "历史今天", "星座-", "答案", "转语音-", "黄历"]`
)
console
.
log
(
`目前关键字有["抽签", "天气", "讲笑话", "讲情话", "梦到", "解第", "动漫图", "去水印-", "历史今天", "星座-", "答案", "转语音-", "黄历"]`
)
console
.
log
(
"
1、微信扫码(17年注册的微信可以直接扫,17年后注册的微信自己要绑定手机号和个人认证下,我记得还要开通收付款。)
\n
2、把自己的的机器人拉个群聊
\n
3、你发送@小白抽签、@小白厦门天气、@小白动漫图
"
);
console
.
log
(
"
1、微信扫码(17年注册的微信可以直接扫,17年后注册的微信自己要绑定手机号和个人认证下,我记得还要开通收付款。)
\n
2、把自己的的机器人拉个群聊
\n
3、你发送@小白抽签、@小白厦门天气、@小白动漫图
"
);
QrcodeTerminal
.
generate
(
qrcode
,
{
QrcodeTerminal
.
generate
(
qrcode
,
{
small
:
true
small
:
true
})
})
})
.
on
(
'
login
'
,
user
=>
{
})
console
.
log
(
'
登录成功:
'
+
user
)
.
on
(
'
login
'
,
user
=>
{
})
console
.
log
(
'
登录成功:
'
+
user
)
.
on
(
'
message
'
,
async
msg
=>
{
})
page
.
methods
.
message
(
msg
,
false
,
1
)
.
on
(
'
message
'
,
async
msg
=>
{
})
page
.
methods
.
message
(
msg
,
false
,
1
)
.
start
()
})
},
.
start
()
async
message
(
msg
,
isTest
,
role
)
{
},
async
message
(
msg
,
isTest
,
role
)
{
// msg是 接收到的信息、
// msg是 接收到的信息、
//isTest其实原来有测试的PuppetMock 可以参考博主 博主写的这篇https://mp.weixin.qq.com/s/nhchTzEcxramFTS_0CyU1g
//isTest其实原来有测试的PuppetMock 可以参考博主 博主写的这篇https://mp.weixin.qq.com/s/nhchTzEcxramFTS_0CyU1g
//role是为了你一次性启动多个机器人预留的 参考博主这篇https://mp.weixin.qq.com/s/r75D51GUXKgPSLCub38OfA
//role是为了你一次性启动多个机器人预留的 参考博主这篇https://mp.weixin.qq.com/s/r75D51GUXKgPSLCub38OfA
let
text
=
msg
.
text
()
//获取聊天内容
let
text
=
msg
.
text
()
//获取聊天内容
let
room
=
msg
.
room
()
//获取房间信息
let
room
=
msg
.
room
()
//获取房间信息
let
userNice
=
msg
.
talker
();
let
userNice
=
msg
.
talker
();
let
msgType
=
msg
.
type
()
//7 是文本 6是图片 8是视频 https://wechaty.js.org/zh/docs/api/message
let
msgType
=
msg
.
type
()
//7 是文本 6是图片 8是视频 https://wechaty.js.org/zh/docs/api/message
if
(
text
.
length
==
0
||
!
room
)
{
if
(
text
.
length
==
0
||
!
room
)
{
return
;
return
;
}
}
if
(
isTest
)
{
if
(
isTest
)
{
var
topic
=
await
room
.
topic
()
//房间名
var
topic
=
await
room
.
topic
()
//房间名
text
=
text
.
replace
(
/
\s
*/g
,
''
).
replace
(
/@小白/g
,
''
);
text
=
text
.
replace
(
/
\s
*/g
,
''
).
replace
(
/@小白/g
,
''
);
userEvent
.
init
(
room
,
text
);
userEvent
.
init
(
room
,
text
);
return
;
return
;
}
}
if
(
room
&&
text
.
length
>
0
)
{
if
(
room
&&
text
.
length
>
0
)
{
var
topic
=
await
room
.
topic
()
//房间名
var
topic
=
await
room
.
topic
()
//房间名
// if (page.data.qunArr.indexOf(topic)!=-1 ) {
// if (page.data.qunArr.indexOf(topic)!=-1 ) {
switch
(
role
)
{
switch
(
role
)
{
case
1
:
case
1
:
if
(
text
.
indexOf
(
"
@小白
"
)
!=
-
1
)
{
//这里可以定义你的触发条件,比如 @小白你好啊 识别到小白,才触发机器人的自动回复
if
(
text
.
indexOf
(
"
@小白
"
)
!=
-
1
)
{
//这里可以定义你的触发条件,比如 @小白你好啊 识别到小白,才触发机器人的自动回复
text
=
text
.
replace
(
/
\s
*/g
,
''
).
replace
(
/@小白/g
,
''
);
//这里可以定义你的触发条件,比如 @小白你好啊 识别到小白,才触发机器人的自动回复
text
=
text
.
replace
(
/
\s
*/g
,
''
).
replace
(
/@小白/g
,
''
);
//这里可以定义你的触发条件,比如 @小白你好啊 识别到小白,才触发机器人的自动回复
userEvent
.
init
(
room
,
text
)
//注意,每次有接收到群消息都会回复
userEvent
.
init
(
room
,
text
)
//注意,每次有接收到群消息都会回复
}
}
break
;
break
;
}
}
// }//这里是给你过滤 触发回复信息的 房间名,为了方便大家测试,所以我这边先备注掉,记住,
// }//这里是给你过滤 触发回复信息的 房间名,为了方便大家测试,所以我这边先备注掉,记住,
}
}
}
}
}
}
}
}
page
.
mounted
();
page
.
mounted
();
//用户事件处理
//用户事件处理
var
wechatyplay
=
null
var
wechatyplay
=
null
const
userEvent
=
{
const
userEvent
=
{
setSize
:
0
,
setSize
:
0
,
async
init
(
room
,
msg
)
{
async
init
(
room
,
msg
)
{
let
m
=
this
;
let
m
=
this
;
//更多api 可以在公众号教程里找到https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=MzI1NjAxODkzMg==
//更多api 可以在公众号教程里找到https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=MzI1NjAxODkzMg==
let
arr
=
[
"
抽签
"
,
"
天气
"
,
"
讲笑话
"
,
"
讲情话
"
,
"
梦到
"
,
"
解第
"
,
"
动漫图
"
,
"
去水印-
"
,
"
历史今天
"
,
"
星座-
"
,
"
答案
"
,
"
转语音-
"
,
"
黄历
"
]
//
let
arr
=
[
"
抽签
"
,
"
天气
"
,
"
讲笑话
"
,
"
讲情话
"
,
"
梦到
"
,
"
解第
"
,
"
动漫图
"
,
"
去水印-
"
,
"
历史今天
"
,
"
星座-
"
,
"
答案
"
,
"
转语音-
"
,
"
黄历
"
]
//
let
arrIndex
=
-
1
let
arrIndex
=
-
1
let
text
=
""
let
text
=
""
arr
.
some
((
v
,
i
)
=>
{
arr
.
some
((
v
,
i
)
=>
{
let
isTrue
=
msg
.
indexOf
(
v
)
!=
-
1
let
isTrue
=
msg
.
indexOf
(
v
)
!=
-
1
if
(
isTrue
)
{
if
(
isTrue
)
{
arrIndex
=
i
;
arrIndex
=
i
;
text
=
msg
.
replace
(
new
RegExp
(
v
,
"
g
"
),
''
)
text
=
msg
.
replace
(
new
RegExp
(
v
,
"
g
"
),
''
)
}
}
return
isTrue
return
isTrue
})
})
switch
(
arrIndex
)
{
case
0
:
case
1
:
case
2
:
case
3
:
case
4
:
case
5
:
m
.
weixinChatbot
(
room
,
msg
);
break
;
case
6
:
m
.
animationPic
(
room
,
text
);
break
;
case
7
:
m
.
qsy
(
room
,
text
);
break
;
case
8
:
m
.
history
(
room
);
break
;
case
9
:
m
.
constellation
(
room
,
text
);
break
;
case
10
:
m
.
answer
(
room
,
text
);
break
;
case
11
:
m
.
toVoice
(
room
,
text
);
break
;
case
12
:
m
.
naming
(
room
,
text
);
break
;
case
13
:
m
.
hli
(
room
,
text
);
break
;
}
},
//黄历
async
hli
(
room
,
text
)
{
let
m
=
this
;
let
msg
=
await
m
.
ajax
(
`https://api.lolimi.cn/API/huang/api.php`
,
{},
"
get
"
)
await
room
.
say
(
msg
.
data
.
text
+
m
.
sayEnd
)
},
//微信机器人人
async
weixinChatbot
(
room
,
text
)
{
let
m
=
this
;
let
msg
=
await
m
.
ajax
(
"
https://chatbot.weixin.qq.com/openapi/aibot/
"
+
page
.
data
.
token
,
{
signature
:
page
.
data
.
signature
,
query
:
text
,
},
"
post
"
)
if
(
msg
?.
data
?.
errcode
==
1005
)
{
await
page
.
methods
.
wxjqrInit
();
msg
=
await
m
.
ajax
(
"
https://chatbot.weixin.qq.com/openapi/aibot/
"
+
page
.
data
.
token
,
{
signature
:
page
.
data
.
signature
,
query
:
text
,
},
"
post
"
)
}
let
answer
=
msg
.
data
.
answer
if
(
msg
.
data
.
status
==
"
FAQ_RECOMMEND
"
)
{
answer
=
"
请问你是不是想问:
"
+
msg
.
data
.
options
[
0
].
title
}
if
(
text
.
indexOf
(
"
解第
"
)
!=
-
1
)
{
answer
=
JSON
.
parse
(
answer
).
multimsg
[
0
]
}
await
room
.
say
(
answer
+
m
.
sayEnd
)
},
//取名
async
naming
(
room
,
text
)
{
let
m
=
this
;
var
thisArr
=
text
.
split
(
"
-
"
);
var
sex
=
thisArr
[
1
]
if
(
sex
==
"
男
"
)
{
sex
=
1
}
else
if
(
sex
==
"
女
"
)
{
sex
=
2
}
else
{
sex
=
3
}
let
res
=
await
m
.
ajax
(
"
https://api.qqsuu.cn/api/dm-cname?apiKey=f6f30d68538bb04dd816e4b4edef8f9f&sex=
"
+
sex
+
"
&wordnum=2&num=10
"
,
null
,
"
get
"
)
var
str
=
""
res
.
data
.
data
.
list
.
forEach
(
v
=>
{
str
+=
v
.
naming
+
"
,
"
})
str
=
str
.
substr
(
0
,
str
.
length
-
1
)
await
room
.
say
(
str
+
m
.
sayEnd
)
},
//转语言
async
toVoice
(
room
,
text
)
{
let
m
=
this
;
var
text
=
text
.
split
(
"
-
"
);
m
.
sayMP3
(
text
[
0
],
room
,
text
[
1
])
},
//答案
async
answer
(
room
,
text
)
{
let
m
=
this
;
let
res
=
await
m
.
ajax
(
"
https://api.wer.plus/api/bay
"
,
null
,
"
get
"
)
m
.
sayMP3
(
res
.
data
.
data
.
comment
.
split
(
"
|
"
)[
0
],
room
)
},
//星座
async
constellation
(
room
,
text
)
{
let
m
=
this
;
let
res
=
await
this
.
ajax
(
"
https://v.api.aa1.cn/api/xingzuo/?msg=
"
+
text
,
null
,
"
get
"
)
await
room
.
say
(
'
星座:
'
+
res
.
data
.
xz
+
"
\n
贵人方位:
"
+
res
.
data
.
grfw
+
"
\n
贵人星座:
"
+
res
.
data
.
grxz
+
"
\n
幸运数字:
"
+
res
.
data
.
xyys
+
"
\n
爱情运势:
"
+
res
.
data
.
aqys
+
"
\n
财富运势:
"
+
res
.
data
.
cfys
+
"
\n
事业运势:
"
+
res
.
data
.
syys
+
"
\n
整体运势:
"
+
res
.
data
.
ztys
+
"
提示:
"
+
res
.
data
.
ts
)
},
//历史今天
async
history
(
room
)
{
let
res
=
await
this
.
ajax
(
"
https://api.oick.cn/lishi/api.php
"
,
null
,
"
get
"
)
var
radomArr
=
res
.
data
.
result
var
randomIndex
=
Math
.
floor
(
Math
.
random
()
*
radomArr
.
length
)
var
obj
=
radomArr
[
randomIndex
];
await
room
.
say
(
obj
.
date
+
"
:
"
+
obj
.
title
+
m
.
sayEnd
)
},
//去水印 1
async
qsy
(
room
,
text
)
{
if
(
text
.
indexOf
(
"
v.douyin.com
"
)
!=
-
1
)
{
// let url=await douyin.init(text);
// await room.say(url)
let
res
=
await
this
.
ajax
(
"
http://api.xn--7gqa009h.top/api/dy_jx?a=
"
+
text
,
{},
"
get
"
)
console
.
log
(
res
.
data
.
url
)
await
room
.
say
(
text
+
"
解析后下载地址:
"
+
res
.
data
.
url
+
m
.
sayEnd
)
switch
(
arrIndex
)
{
}
case
0
:
},
case
1
:
//动漫图 0
case
2
:
async
animationPic
(
room
,
text
)
{
case
3
:
let
res
=
await
this
.
ajax
(
"
https://api.oick.cn/random/api.php?type=pc
"
,
{},
"
get
"
)
case
4
:
this
.
sayImg
(
room
,
res
.
request
.
protocol
+
"
//
"
+
res
.
request
.
host
+
res
.
request
.
path
)
case
5
:
m
.
weixinChatbot
(
room
,
msg
);
break
;
case
6
:
m
.
animationPic
(
room
,
text
);
break
;
case
7
:
m
.
qsy
(
room
,
text
);
break
;
case
8
:
m
.
history
(
room
);
break
;
case
9
:
m
.
constellation
(
room
,
text
);
break
;
case
10
:
m
.
answer
(
room
,
text
);
break
;
case
11
:
m
.
toVoice
(
room
,
text
);
break
;
case
12
:
m
.
naming
(
room
,
text
);
break
;
case
13
:
m
.
hli
(
room
,
text
);
break
;
}
},
//黄历
async
hli
(
room
,
text
)
{
let
m
=
this
;
let
msg
=
await
m
.
ajax
(
`https://api.lolimi.cn/API/huang/api.php`
,
{},
"
get
"
)
await
room
.
say
(
msg
.
data
.
text
+
m
.
sayEnd
)
},
//微信机器人人
async
weixinChatbot
(
room
,
text
)
{
let
m
=
this
;
let
msg
=
await
m
.
ajax
(
"
https://chatbot.weixin.qq.com/openapi/aibot/
"
+
page
.
data
.
token
,
{
signature
:
page
.
data
.
signature
,
query
:
text
,
},
"
post
"
)
if
(
msg
?.
data
?.
errcode
==
1005
)
{
await
page
.
methods
.
wxjqrInit
();
msg
=
await
m
.
ajax
(
"
https://chatbot.weixin.qq.com/openapi/aibot/
"
+
page
.
data
.
token
,
{
signature
:
page
.
data
.
signature
,
query
:
text
,
},
"
post
"
)
}
let
answer
=
msg
.
data
.
answer
if
(
msg
.
data
.
status
==
"
FAQ_RECOMMEND
"
)
{
answer
=
"
请问你是不是想问:
"
+
msg
.
data
.
options
[
0
].
title
}
if
(
text
.
indexOf
(
"
解第
"
)
!=
-
1
)
{
answer
=
JSON
.
parse
(
answer
).
multimsg
[
0
]
}
await
room
.
say
(
answer
+
m
.
sayEnd
)
},
//取名
async
naming
(
room
,
text
)
{
let
m
=
this
;
var
thisArr
=
text
.
split
(
"
-
"
);
var
sex
=
thisArr
[
1
]
if
(
sex
==
"
男
"
)
{
sex
=
1
}
else
if
(
sex
==
"
女
"
)
{
sex
=
2
}
else
{
sex
=
3
}
let
res
=
await
m
.
ajax
(
"
https://api.qqsuu.cn/api/dm-cname?apiKey=f6f30d68538bb04dd816e4b4edef8f9f&sex=
"
+
sex
+
"
&wordnum=2&num=10
"
,
null
,
"
get
"
)
var
str
=
""
res
.
data
.
data
.
list
.
forEach
(
v
=>
{
str
+=
v
.
naming
+
"
,
"
})
str
=
str
.
substr
(
0
,
str
.
length
-
1
)
await
room
.
say
(
str
+
m
.
sayEnd
)
},
//转语言
async
toVoice
(
room
,
text
)
{
let
m
=
this
;
var
text
=
text
.
split
(
"
-
"
);
m
.
sayMP3
(
text
[
0
],
room
,
text
[
1
])
},
//答案
async
answer
(
room
,
text
)
{
let
m
=
this
;
let
res
=
await
m
.
ajax
(
"
https://api.wer.plus/api/bay
"
,
null
,
"
get
"
)
m
.
sayMP3
(
res
.
data
.
data
.
comment
.
split
(
"
|
"
)[
0
],
room
)
},
//星座
async
constellation
(
room
,
text
)
{
let
m
=
this
;
let
res
=
await
this
.
ajax
(
"
https://v.api.aa1.cn/api/xingzuo/?msg=
"
+
text
,
null
,
"
get
"
)
await
room
.
say
(
'
星座:
'
+
res
.
data
.
xz
+
"
\n
贵人方位:
"
+
res
.
data
.
grfw
+
"
\n
贵人星座:
"
+
res
.
data
.
grxz
+
"
\n
幸运数字:
"
+
res
.
data
.
xyys
+
"
\n
爱情运势:
"
+
res
.
data
.
aqys
+
"
\n
财富运势:
"
+
res
.
data
.
cfys
+
"
\n
事业运势:
"
+
res
.
data
.
syys
+
"
\n
整体运势:
"
+
res
.
data
.
ztys
+
"
提示:
"
+
res
.
data
.
ts
)
},
//历史今天
async
history
(
room
)
{
let
res
=
await
this
.
ajax
(
"
https://api.oick.cn/lishi/api.php
"
,
null
,
"
get
"
)
var
radomArr
=
res
.
data
.
result
var
randomIndex
=
Math
.
floor
(
Math
.
random
()
*
radomArr
.
length
)
var
obj
=
radomArr
[
randomIndex
];
await
room
.
say
(
obj
.
date
+
"
:
"
+
obj
.
title
+
m
.
sayEnd
)
},
//去水印 1
async
qsy
(
room
,
text
)
{
if
(
text
.
indexOf
(
"
v.douyin.com
"
)
!=
-
1
)
{
// let url=await douyin.init(text);
// await room.say(url)
let
res
=
await
this
.
ajax
(
"
http://api.xn--7gqa009h.top/api/dy_jx?a=
"
+
text
,
{},
"
get
"
)
console
.
log
(
res
.
data
.
url
)
await
room
.
say
(
text
+
"
解析后下载地址:
"
+
res
.
data
.
url
+
m
.
sayEnd
)
}
},
//动漫图 0
async
animationPic
(
room
,
text
)
{
let
res
=
await
this
.
ajax
(
"
https://api.oick.cn/random/api.php?type=pc
"
,
{},
"
get
"
)
this
.
sayImg
(
room
,
res
.
request
.
protocol
+
"
//
"
+
res
.
request
.
host
+
res
.
request
.
path
)
await
room
.
say
(
m
.
sayEnd
)
await
room
.
say
(
m
.
sayEnd
)
},
},
ajax
:
ajax
,
ajax
:
ajax
,
async
sayImg
(
room
,
url
)
{
async
sayImg
(
room
,
url
)
{
let
m
=
this
;
let
m
=
this
;
let
fileBox
=
FileBox
.
fromUrl
(
url
);
let
fileBox
=
FileBox
.
fromUrl
(
url
);
await
room
.
say
(
fileBox
)
await
room
.
say
(
fileBox
)
},
},
//文字转语音
//文字转语音
async
sayMP3
(
text
,
room
,
roleName
)
{
async
sayMP3
(
text
,
room
,
roleName
)
{
let
m
=
this
;
let
m
=
this
;
roleName
=
roleName
?
roleName
:
"
雷电将军
"
roleName
=
roleName
?
roleName
:
"
雷电将军
"
let
fileBox
=
null
;
//语音、文件
let
fileBox
=
null
;
//语音、文件
let
res
=
await
m
.
ajax
(
"
http://api.lolimi.cn/API/yyhc/y.php?&msg=
"
+
text
+
"
&speaker=
"
+
roleName
,
let
res
=
await
m
.
ajax
(
"
http://api.lolimi.cn/API/yyhc/y.php?&msg=
"
+
text
+
"
&speaker=
"
+
roleName
,
null
,
"
get
"
)
null
,
"
get
"
)
fileBox
=
FileBox
.
fromUrl
(
res
.
data
.
music
);
fileBox
=
FileBox
.
fromUrl
(
res
.
data
.
music
);
await
room
.
say
(
fileBox
)
await
room
.
say
(
fileBox
)
await
room
.
say
(
m
.
sayEnd
)
await
room
.
say
(
m
.
sayEnd
)
},
},
sayEnd
:
"
\n
----------------
\n
来至公众号:'程序员野区'的作者雪狼之夜的开源项目,
\n
公众号地址
\n
https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=MzI1NjAxODkzMg==
\n
开源项目地址:https://inscode.csdn.net/@xuelang532777032/NodeJS
"
sayEnd
:
"
\n
----------------
\n
来至公众号:'程序员野区'的作者雪狼之夜的开源项目,
\n
公众号地址
\n
https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=MzI1NjAxODkzMg==
\n
开源项目地址:https://inscode.csdn.net/@xuelang532777032/NodeJS
"
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录