zhuzhiqing 2 years ago
parent
commit
ee2347dc26
  1. 57
      qianpiao/dyh_chengdu.js

57
qianpiao/dyh_chengdu.js

@ -9,7 +9,7 @@ cron: 0,10 * * * *
//涵 //涵
process.env.dyh = "111"; process.env.dyh = "111";
// process.env.PUSH_KEY = 'SCT46897TQDkm3LUOZdiklUhe1wyLhhfa' // process.env.PUSH_KEY = 'SCT46897TQDkm3LUOZdiklUhe1wyLhhfa'
let DD_BOT_TOKEN,SCKEY; let DD_BOT_TOKEN, SCKEY;
if (process.env.DD_BOT_TOKEN) { if (process.env.DD_BOT_TOKEN) {
DD_BOT_TOKEN = process.env.DD_BOT_TOKEN; DD_BOT_TOKEN = process.env.DD_BOT_TOKEN;
if (process.env.DD_BOT_SECRET) { if (process.env.DD_BOT_SECRET) {
@ -31,7 +31,7 @@ let userIdx = 0
let userCount = 0 let userCount = 0
let baseUrl = 'http://423n669m71.no-ip.org:9000/api/endpoints/2'; let baseUrl = 'http://423n669m71.no-ip.org:9000/api/endpoints/2';
let apiKey = "ptr_oQzrYfeDBfuGSbaK2qOM83zN94RyEZfO8v+DdUJwccA=" let apiKey = "ptr_oQzrYfeDBfuGSbaK2qOM83zN94RyEZfO8v+DdUJwccA="
let keys=['篮球',"田径","羽毛球","排球"] let keys = ['篮球', "羽毛球", "排球"]
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
class UserInfo { class UserInfo {
@ -182,7 +182,7 @@ class UserInfo {
const key = keys[index]; const key = keys[index];
await this.getRace(key); await this.getRace(key);
} }
} catch (e) { } catch (e) {
console.log(e) console.log(e)
} finally { } finally {
@ -485,7 +485,7 @@ function Env (name, env) {
} }
async showmsg () { async showmsg () {
if (!this.notifyStr) return; if (!this.notifyStr) return;
let notifyBody =this.notifyStr let notifyBody = this.notifyStr
if ($.isNode()) { if ($.isNode()) {
var notify = require('./sendNotify'); var notify = require('./sendNotify');
console.log('\n============== 推送 ==============') console.log('\n============== 推送 ==============')
@ -610,7 +610,7 @@ async function sendNotify (text, desp, params = {}, author = '\n\n仅供用于
//由于上述两种微信通知需点击进去才能查看到详情,故text(标题内容)携带了账号序号以及昵称信息,方便不点击也可知道是哪个京东哪个活动 //由于上述两种微信通知需点击进去才能查看到详情,故text(标题内容)携带了账号序号以及昵称信息,方便不点击也可知道是哪个京东哪个活动
text = text.match(/.*?(?=\s?-)/g) ? text.match(/.*?(?=\s?-)/g)[0] : text; text = text.match(/.*?(?=\s?-)/g) ? text.match(/.*?(?=\s?-)/g)[0] : text;
await Promise.all([ await Promise.all([
wxmmmm(text,desp), wxmmmm(text, desp),
ddBotNotify(text, desp),//钉钉机器人 ddBotNotify(text, desp),//钉钉机器人
]) ])
} }
@ -673,13 +673,13 @@ async function ddBotNotify (text, desp, time = 2100) {
} }
} }
async function getToken() { async function getToken () {
const params = { const params = {
grant_type: 'client_credential', grant_type: 'client_credential',
appid: 'wx78d0fd108ab26b67', // 你的appid 1 appid: 'wx78d0fd108ab26b67', // 你的appid 1
secret: '86e3801eb4518af21082e640e4f29473', // 你的secret 2 secret: '86e3801eb4518af21082e640e4f29473', // 你的secret 2
}; };
let pp=$.json2str(params,"&"); let pp = $.json2str(params, "&");
const options = { const options = {
url: `https://api.weixin.qq.com/cgi-bin/token?${pp}`, url: `https://api.weixin.qq.com/cgi-bin/token?${pp}`,
headers: { headers: {
@ -690,29 +690,29 @@ async function getToken() {
await httpRequest('get', options) await httpRequest('get', options)
res = httpResult; res = httpResult;
return res.access_token; return res.access_token;
} }
async function templateMessageSend(title,context) { async function templateMessageSend (title, context) {
const token = await getToken(); const token = await getToken();
const url = 'https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=' + token; const url = 'https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=' + token;
const params = { const params = {
"touser": 'oTHpRuGEWxCYqCPMOidO7vWXjrww', // 用户openid 3 "touser": 'oTHpRuGEWxCYqCPMOidO7vWXjrww', // 用户openid 3
"template_id": 'K5YpydwHeNbr6R1dUna4rYs2xhjvZmqR8KrkRFqhFwY', // 模板id 4 "template_id": 'K5YpydwHeNbr6R1dUna4rYs2xhjvZmqR8KrkRFqhFwY', // 模板id 4
// url: 'http://www.baidu.com', // url: 'http://www.baidu.com',
"topcolor": '#FF0000', "topcolor": '#FF0000',
"data": { "data": {
"title": { "title": {
"value": title "value": title + "JD"
},
"content": {
"value": context
},
}, },
"content": {
"value": context
},
},
}; };
const options = { const options = {
url: url, url: url,
body:JSON.stringify(params), body: JSON.stringify(params),
headers: { headers: {
'Content-Type': 'application/json;charset=utf-8' 'Content-Type': 'application/json;charset=utf-8'
} }
@ -720,12 +720,11 @@ async function getToken() {
await httpRequest('post', options) await httpRequest('post', options)
res = httpResult; res = httpResult;
console.log('res: ', res); console.log('res: ', res);
} }
async function wxmmmm(title,context) async function wxmmmm (title, context) {
{
const wxmpy = require('wxmnode'); const wxmpy = require('wxmnode');
let res = await wxmpy.sendMsgToUser("45741299", "871333",title,context,"") let res = await wxmpy.sendMsgToUser("45741299", "871333", title, context, "")
console.log('res: ', res); console.log('res: ', res);
} }

Loading…
Cancel
Save