Commit c209fe6f by trace

update showing mode, add release update

parent 46a84a67
let version = '1.0'
let release = `<div><br/>
<br/>1. <br/>
加入对贷超 MGT 的支持. 支持点击"<贷超名MGT>"打开贷超对应管理系统, 点击包名 ID 打开 GooglePlay<br/>
<br/>2. <br/>
在线列表上下线颜色区分. 上线: 绿色, 下线: 红色.<br/>
<br/>other:<br/>
当监控中有上下线变化才会发送邮件, 并且会带上当前在线下线列表<br/>
上下线通知邮件中第一行, "《》" 中的是 VTPM 本次监控情况涉及 APP 数量, "【】" 中是本次监控通知中贷超 APP 涉及数量<br/>
<div/>
<br/>
<br/>
<br/>
`
// 依赖
var gplay = require('google-play-scraper')
var nodemailer = require('nodemailer')
// 工具
var fs = require('fs')
var username = require('os').userInfo().username
var request = require('request')
var util = require('util')
var getPromiss = util.promisify(request.get)
// 地址
let subApi = "https://git.starwin.tech/nongyingchen/AppMonitorSubscriber/raw/master/subscriber.json"
log(`当前奔跑在:${username}`)
let ding = 'https://oapi.dingtalk.com/robot/send?access_token='
let debugDingding = `${ding}bf03c69128b771107b8715911b8a76db61a55cbd8b00e1a2c955578c2a3da719`
let notifyDingding = `${ding}61403ec65efd7a9e40cb6d490e1bfab8aff28800696918a23ec4dffdf5aa1315`
let daichao = `admin/loan/listactive?current=0&size=10000&descs%5B0%5D=priority&packageId=10002`
let daichaoRegion = [
'http://admin.uuang.co.id/',
'http://admin.ph.g-cashing.com/',
'http://admin.a.vaylaco.com/'
]
let daichaoRegion = {
'http://admin.uuang.co.id/': '印尼贷超',
'http://admin.ph.g-cashing.com/': '菲律宾贷超',
'http://admin.a.vaylaco.com/': '越南贷超'
}
// Config ------------------------------------------------------------
let sec = 1000;
......@@ -130,6 +150,7 @@ let permissionChange = {} // 权限变化
let failedApps = [] // 获取失败的
let newTopMonitorNames = {}
let errorLog = [] // 错误记录
let newDeploy = true
log('log 打开')
......@@ -141,13 +162,16 @@ if (isTest()) {
startMonitor()
}
sendEmail(`爬虫部署成功, 开始监控-----------------------`)
sendEmail(`开始监控-----------------------`)
async function startMonitor() {
log('开始监控')
while (start) {
log(`抓取一圈`)
await getConfig()
.then(() => { // 部署通知, 更新说明
sendEmail(`<div>爬虫部署版本: ${version}</div>更新说明: ${release}`)
})
.then(getDaichao)
.then(getTop100)
.then(() => fs.writeFileSync(monitorApps, JSON.stringify(monitorNames))) // 保存到本地
......@@ -218,8 +242,9 @@ function generateDailyOnlineReport() {
async function getDaichao() {
let allRegionDaichaoApps = []
for (index in daichaoRegion) {
let region = daichaoRegion[index]
for (region in daichaoRegion) {
// for (index in Object.keys(daichaoRegion)) {
// let region = daichaoRegion[index]
daichaoApiUrl = region + daichao
log(` 贷超 url: ${daichaoApiUrl}`)
await getPromiss(daichaoApiUrl)
......@@ -238,7 +263,8 @@ async function getDaichao() {
daichaoAppInfoes[app.packageName] = {
name: app.name,
daichaoId: app.id,
mgt: `${region}#/loan/`
mgt: `${region}#/loan/`,
region: daichaoRegion[region]
}
}
if (isTest()) {
......@@ -662,6 +688,8 @@ function genMail() {
}
// 有变化也发送当前监控在线情况
emailContent += '<br/><br/><br/>'
emailContent += '在线/下线 情况:'
emailContent += generateDailyOnlineReport()
emailContent += nowGenerate
......@@ -675,14 +703,14 @@ function genMail() {
errorLog = []
newTopMonitorNames = {}
return `<div>${firstLine}</div><br/>${emailContent}`
return `<div>${firstLine}</div><br/>${emailContent}<br/>version: ${version}`
}
function isOurs(name, countOurs) {
let prefix = ''
if (daichaoApps.includes(name)) {
prefix = `<a href="${daichaoAppInfoes[name].mgt}${daichaoAppInfoes[name] &&
daichaoAppInfoes[name].daichaoId || ''}">🏦(贷超 [${daichaoAppInfoes[name].daichaoId}] _ < ${daichaoAppInfoes[name].name} >(->MGT)) | </a>`
prefix = `🏦(贷超.${daichaoAppInfoes[name].region}[${daichaoAppInfoes[name].daichaoId}]__<a href="${daichaoAppInfoes[name].mgt}${daichaoAppInfoes[name] &&
daichaoAppInfoes[name].daichaoId || ''}"> < ${daichaoAppInfoes[name].name} >(->MGT)) | </a>`
}
if (ourAppIds.includes(name)) {
if (prefix != '') {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment