├── .gitattributes ├── README.md ├── config ├── config.json └── sendNotify.js └── docs ├── _config.yml └── index.md /.gitattributes: -------------------------------------------------------------------------------- 1 | *.json linguist-language=Objective-C 2 | *.js linguist-language=Objective-C 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # imaotai 2 | i茅台app 每日自动预约 抢茅台 3 | 4 | 软件免费,无任何盈利 不要相信任何收费.唯一更新地址https://github.com/insoxin/imaotai/ 5 | 6 | 7 | 更新一下:近日很多朋友发邮件咨询新版不能用,旧版客户端提示让升级新版.这个不多说,在发出这个项目没多久就有贵州茅台的企业微信加了我,交流了很多.并且也受邀参观了一下,蹭了几顿饭.吃人嘴软拿人手短,所以后续也没在更新相关(原因之一).有相关学习研究的同学可以参考我博客历史文章已淘汰的算法. 8 | 9 | **再更新一下,我邮箱每周末一打开几百封邮件有点影响使用体验了,,建了微信讨论群,群内没有成品软件. 并且入群费两百,有需求的同学,备注留imaotai + 邮箱,看到发你入群邀请** 10 | 11 | ![image.png](https://raw.githubusercontent.com/insoxin/API/master/Sponsor.jpg) 12 | 13 | 14 | 15 | # 使用方法 16 | ## 1.拉取镜像 17 | ```docker 18 | docker pull insoxin/imaotai:latest 19 | ``` 20 | ## 2.创建容器 21 | 22 | ```docker 23 | docker run -dit --name imaotai -p 1499:1499 -v $PWD/imaotai/config:/go/src/imaotai/config --restart unless-stopped insoxin/imaotai:latest 24 | ``` 25 | 26 | ## 3.配置参数 27 | 28 | ### 配置config.json 29 | 下载下载https://github.com/insoxin/imaotai/blob/main/config/config.json 至本地 /root/imaotai/config/config.json 30 | 31 | 修改本地/root/imaotai/config/config.json参数 32 | 33 | User-Agent,Client_Secret,Cookie.必填 34 | 35 | 还有经纬度不要默认(APP数据以高德地图为准) 程序会就近预约最近距离店铺 36 | 若不想预约太远店铺,可设置GeoKM参数 默认0无限制 37 | 38 | 其他配置不懂的默认即可 39 | 40 | 默认每天九点执行(淘宝时间库),预约抢购页面获取到的前四个商品. 41 | 42 | ### 配置sendNotify.js 通知 43 | 44 | 下载https://github.com/insoxin/imaotai/blob/main/config/sendNotify.js 至本地/root/imaotai/config/sendNotify.js 45 | 46 | sendNotify.js是通知文件按需修改 47 | 48 | 49 | ```json 50 | { 51 | "Main": { 52 | "Title": "insoxin/imaotai", 53 | "Open": "1,2,3,4", 54 | "cron": "0 0 9 * * *", 55 | "Tzone": "http://api.m.taobao.com/rest/api3.do?api=mtop.common.getTimestamp", 56 | "MT-APP-Version": "1.0.0", 57 | "GeoN": "26.598194", 58 | "GeoE": "106.707410", 59 | "GeoKM":"0", 60 | "sendNotify": "/config/sendNotify.js", 61 | "oksendNotify": "true" 62 | }, 63 | "user": { 64 | "Cookie": "", 65 | "Origin": "https://h5.moutai519.com.cn", 66 | "Client_Secret": "aaa", 67 | "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 15_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 moutaiapp/1.0.6 device-id/insoxin/imaotai" 68 | }, 69 | "Notice": "通知中的标题" 70 | } 71 | 72 | 73 | MD5(2af72f100c356273d46284f6fd1dfc08+数据排序+时间戳) 74 | 75 | https://blog.isoyu.com/archives/imaotaimt-device-idmt-r-md5jiajiemi.html 76 | 77 | ``` 78 | ## 4.重启 imaotai 79 | 80 | 81 | ## 5.点个star 再进 https://github.com/insoxin/ 点follow 关注一下 项目被ban了 我会第一时间更新 新项目 82 | 83 | 84 | 85 | 86 | ![image.png](https://blog.isoyu.com/wp-content/uploads/2022/04/2022040300072260.jpg) 87 | 88 | -------------------------------------------------------------------------------- /config/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "Main": { 3 | "Title": "insoxin/imaotai", 4 | "Open": "1,2,3,4", 5 | "cron": "0 0 9 * * *", 6 | "Tzone": "http://api.m.taobao.com/rest/api3.do?api=mtop.common.getTimestamp", 7 | "MT-APP-Version": "1.0.0", 8 | "GeoN": "26.598194", 9 | "GeoE": "106.707410", 10 | "GeoKM":"0", 11 | "sendNotify": "/config/sendNotify.js", 12 | "oksendNotify": "true" 13 | }, 14 | "user": { 15 | "Cookie": "", 16 | "Origin": "https://h5.moutai519.com.cn", 17 | "Client_Secret": "aaa", 18 | "User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 15_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 moutaiapp/1.0.7 device-id/insoxin/imaotai" 19 | }, 20 | "Notice": "如果需要标题,请在此配置项里面些内容。不需要通知标题请此配置项留空" 21 | } 22 | -------------------------------------------------------------------------------- /config/sendNotify.js: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: insoxin https://github.com/insoxin/imaotai/ 3 | * @Last Modified by: insoxin 4 | * @Last Modified time: 2022-4-3 15:00:54 5 | * sendNotify 推送通知功能 6 | * @param text 通知头 7 | * @param desp 通知体 8 | * @param params 某些推送通知方式点击弹窗可跳转, 例:{ url: 'https://abc.com' } 9 | * @param author 作者仓库等信息 例:`本通知 By:https://github.com/insoxin/imaotai/` 10 | */ 11 | 12 | const querystring = require('querystring'); 13 | const $ = new Env(); 14 | const timeout = 15000; //超时时间(单位毫秒) 15 | // =======================================go-cqhttp通知设置区域=========================================== 16 | //gobot_url 填写请求地址http://127.0.0.1/send_private_msg 17 | //gobot_token 填写在go-cqhttp文件设置的访问密钥 18 | //gobot_qq 填写推送到个人QQ或者QQ群号 19 | //go-cqhttp相关API https://docs.go-cqhttp.org/api 20 | let GOBOT_URL = ''; // 推送到个人QQ: http://127.0.0.1/send_private_msg 群:http://127.0.0.1/send_group_msg 21 | let GOBOT_TOKEN = ''; //访问密钥 22 | let GOBOT_QQ = ''; // 如果GOBOT_URL设置 /send_private_msg 则需要填入 user_id=个人QQ 相反如果是 /send_group_msg 则需要填入 group_id=QQ群 23 | 24 | // =======================================微信server酱通知设置区域=========================================== 25 | //此处填你申请的SCKEY. 26 | //(环境变量名 PUSH_KEY) 27 | let SCKEY = ''; 28 | 29 | // =======================================Bark App通知设置区域=========================================== 30 | //此处填你BarkAPP的信息(IP/设备码,例如:https://api.day.app/XXXXXXXX) 31 | let BARK_PUSH = ''; 32 | //BARK app推送铃声,铃声列表去APP查看复制填写 33 | let BARK_SOUND = ''; 34 | //BARK app推送消息的分组, 默认为"QingLong" 35 | let BARK_GROUP = 'QingLong'; 36 | 37 | // =======================================telegram机器人通知设置区域=========================================== 38 | //此处填你telegram bot 的Token,telegram机器人通知推送必填项.例如:1077xxx4424:AAFjv0FcqxxxxxxgEMGfi22B4yh15R5uw 39 | //(环境变量名 TG_BOT_TOKEN) 40 | let TG_BOT_TOKEN = ''; 41 | //此处填你接收通知消息的telegram用户的id,telegram机器人通知推送必填项.例如:129xxx206 42 | //(环境变量名 TG_USER_ID) 43 | let TG_USER_ID = ''; 44 | //tg推送HTTP代理设置(不懂可忽略,telegram机器人通知推送功能中非必填) 45 | let TG_PROXY_HOST = ''; //例如:127.0.0.1(环境变量名:TG_PROXY_HOST) 46 | let TG_PROXY_PORT = ''; //例如:1080(环境变量名:TG_PROXY_PORT) 47 | let TG_PROXY_AUTH = ''; //tg代理配置认证参数 48 | //Telegram api自建的反向代理地址(不懂可忽略,telegram机器人通知推送功能中非必填),默认tg官方api(环境变量名:TG_API_HOST) 49 | let TG_API_HOST = 'api.telegram.org'; 50 | // =======================================钉钉机器人通知设置区域=========================================== 51 | //此处填你钉钉 bot 的webhook,例如:5a544165465465645d0f31dca676e7bd07415asdasd 52 | //(环境变量名 DD_BOT_TOKEN) 53 | let DD_BOT_TOKEN = ''; 54 | //密钥,机器人安全设置页面,加签一栏下面显示的SEC开头的字符串 55 | let DD_BOT_SECRET = ''; 56 | 57 | // =======================================企业微信机器人通知设置区域=========================================== 58 | //此处填你企业微信机器人的 webhook(详见文档 https://work.weixin.qq.com/api/doc/90000/90136/91770),例如:693a91f6-7xxx-4bc4-97a0-0ec2sifa5aaa 59 | //(环境变量名 QYWX_KEY) 60 | let QYWX_KEY = ''; 61 | 62 | // =======================================企业微信应用消息通知设置区域=========================================== 63 | /* 64 | 此处填你企业微信应用消息的值(详见文档 https://work.weixin.qq.com/api/doc/90000/90135/90236) 65 | 环境变量名 QYWX_AM依次填入 corpid,corpsecret,touser(注:多个成员ID使用|隔开),agentid,消息类型(选填,不填默认文本消息类型) 66 | 注意用,号隔开(英文输入法的逗号),例如:wwcff56746d9adwers,B-791548lnzXBE6_BWfxdf3kSTMJr9vFEPKAbh6WERQ,mingcheng,1000001,2COXgjH2UIfERF2zxrtUOKgQ9XklUqMdGSWLBoW_lSDAdafat 67 | 可选推送消息类型(推荐使用图文消息(mpnews)): 68 | - 文本卡片消息: 0 (数字零) 69 | - 文本消息: 1 (数字一) 70 | - 图文消息(mpnews): 素材库图片id, 可查看此教程(http://note.youdao.com/s/HMiudGkb)或者(https://note.youdao.com/ynoteshare1/index.html?id=1a0c8aff284ad28cbd011b29b3ad0191&type=note) 71 | */ 72 | let QYWX_AM = ''; 73 | 74 | // =======================================iGot聚合推送通知设置区域=========================================== 75 | //此处填您iGot的信息(推送key,例如:https://push.hellyw.com/XXXXXXXX) 76 | let IGOT_PUSH_KEY = ''; 77 | 78 | // =======================================push+设置区域======================================= 79 | //官方文档:http://www.pushplus.plus/ 80 | //PUSH_PLUS_TOKEN:微信扫码登录后一对一推送或一对多推送下面的token(您的Token),不提供PUSH_PLUS_USER则默认为一对一推送 81 | //PUSH_PLUS_USER: 一对多推送的“群组编码”(一对多推送下面->您的群组(如无则新建)->群组编码,如果您是创建群组人。也需点击“查看二维码”扫描绑定,否则不能接受群组消息推送) 82 | let PUSH_PLUS_TOKEN = ''; 83 | let PUSH_PLUS_USER = ''; 84 | 85 | //==========================云端环境变量的判断与接收========================= 86 | if (process.env.GOBOT_URL) { 87 | GOBOT_URL = process.env.GOBOT_URL; 88 | } 89 | if (process.env.GOBOT_TOKEN) { 90 | GOBOT_TOKEN = process.env.GOBOT_TOKEN; 91 | } 92 | if (process.env.GOBOT_QQ) { 93 | GOBOT_QQ = process.env.GOBOT_QQ; 94 | } 95 | 96 | if (process.env.PUSH_KEY) { 97 | SCKEY = process.env.PUSH_KEY; 98 | } 99 | 100 | if (process.env.QQ_SKEY) { 101 | QQ_SKEY = process.env.QQ_SKEY; 102 | } 103 | 104 | if (process.env.QQ_MODE) { 105 | QQ_MODE = process.env.QQ_MODE; 106 | } 107 | 108 | if (process.env.BARK_PUSH) { 109 | if ( 110 | process.env.BARK_PUSH.indexOf('https') > -1 || 111 | process.env.BARK_PUSH.indexOf('http') > -1 112 | ) { 113 | //兼容BARK自建用户 114 | BARK_PUSH = process.env.BARK_PUSH; 115 | } else { 116 | BARK_PUSH = `https://api.day.app/${process.env.BARK_PUSH}`; 117 | } 118 | if (process.env.BARK_SOUND) { 119 | BARK_SOUND = process.env.BARK_SOUND; 120 | } 121 | if (process.env.BARK_GROUP) { 122 | BARK_GROUP = process.env.BARK_GROUP; 123 | } 124 | } else { 125 | if ( 126 | BARK_PUSH && 127 | BARK_PUSH.indexOf('https') === -1 && 128 | BARK_PUSH.indexOf('http') === -1 129 | ) { 130 | //兼容BARK本地用户只填写设备码的情况 131 | BARK_PUSH = `https://api.day.app/${BARK_PUSH}`; 132 | } 133 | } 134 | if (process.env.TG_BOT_TOKEN) { 135 | TG_BOT_TOKEN = process.env.TG_BOT_TOKEN; 136 | } 137 | if (process.env.TG_USER_ID) { 138 | TG_USER_ID = process.env.TG_USER_ID; 139 | } 140 | if (process.env.TG_PROXY_AUTH) TG_PROXY_AUTH = process.env.TG_PROXY_AUTH; 141 | if (process.env.TG_PROXY_HOST) TG_PROXY_HOST = process.env.TG_PROXY_HOST; 142 | if (process.env.TG_PROXY_PORT) TG_PROXY_PORT = process.env.TG_PROXY_PORT; 143 | if (process.env.TG_API_HOST) TG_API_HOST = process.env.TG_API_HOST; 144 | 145 | if (process.env.DD_BOT_TOKEN) { 146 | DD_BOT_TOKEN = process.env.DD_BOT_TOKEN; 147 | if (process.env.DD_BOT_SECRET) { 148 | DD_BOT_SECRET = process.env.DD_BOT_SECRET; 149 | } 150 | } 151 | 152 | if (process.env.QYWX_KEY) { 153 | QYWX_KEY = process.env.QYWX_KEY; 154 | } 155 | 156 | if (process.env.QYWX_AM) { 157 | QYWX_AM = process.env.QYWX_AM; 158 | } 159 | 160 | if (process.env.IGOT_PUSH_KEY) { 161 | IGOT_PUSH_KEY = process.env.IGOT_PUSH_KEY; 162 | } 163 | 164 | if (process.env.PUSH_PLUS_TOKEN) { 165 | PUSH_PLUS_TOKEN = process.env.PUSH_PLUS_TOKEN; 166 | } 167 | if (process.env.PUSH_PLUS_USER) { 168 | PUSH_PLUS_USER = process.env.PUSH_PLUS_USER; 169 | } 170 | //==========================云端环境变量的判断与接收========================= 171 | 172 | /** 173 | * sendNotify 推送通知功能 174 | * @param text 通知头 175 | * @param desp 通知体 176 | * @param params 某些推送通知方式点击弹窗可跳转, 例:{ url: 'https://abc.com' } 177 | * @param author 作者仓库等信息 例:`本通知 By:https://github.com/insoxin/imaotai/` 178 | * @returns {Promise} 179 | */ 180 | async function sendNotify( 181 | text, 182 | desp, 183 | params = {}, 184 | author = '\n\n本通知 By:https://github.com/insoxin/imaotai/', 185 | ) { 186 | //提供6种通知 187 | desp += author; //增加作者信息,防止被贩卖等 188 | await Promise.all([ 189 | serverNotify(text, desp), //微信server酱 190 | pushPlusNotify(text, desp), //pushplus(推送加) 191 | ]); 192 | //由于上述两种微信通知需点击进去才能查看到详情,故text(标题内容)携带了账号序号以及昵称信息,方便不点击也可知道是哪个京东哪个活动 193 | text = text.match(/.*?(?=\s?-)/g) ? text.match(/.*?(?=\s?-)/g)[0] : text; 194 | await Promise.all([ 195 | BarkNotify(text, desp, params), //iOS Bark APP 196 | tgBotNotify(text, desp), //telegram 机器人 197 | ddBotNotify(text, desp), //钉钉机器人 198 | qywxBotNotify(text, desp), //企业微信机器人 199 | qywxamNotify(text, desp), //企业微信应用消息推送 200 | iGotNotify(text, desp, params), //iGot 201 | gobotNotify(text, desp),//go-cqhttp 202 | ]); 203 | } 204 | 205 | function gobotNotify(text, desp, time = 2100) { 206 | return new Promise((resolve) => { 207 | if (GOBOT_URL) { 208 | const options = { 209 | url: `${GOBOT_URL}?access_token=${GOBOT_TOKEN}&${GOBOT_QQ}`, 210 | json: {message:`${text}\n${desp}`}, 211 | headers: { 212 | 'Content-Type': 'application/json', 213 | }, 214 | timeout, 215 | }; 216 | setTimeout(() => { 217 | $.post(options, (err, resp, data) => { 218 | try { 219 | if (err) { 220 | console.log('发送go-cqhttp通知调用API失败!!\n'); 221 | console.log(err); 222 | } else { 223 | data = JSON.parse(data); 224 | if (data.retcode === 0) { 225 | console.log('go-cqhttp发送通知消息成功🎉\n'); 226 | } else if (data.retcode === 100) { 227 | console.log(`go-cqhttp发送通知消息异常: ${data.errmsg}\n`); 228 | } else { 229 | console.log( 230 | `go-cqhttp发送通知消息异常\n${JSON.stringify(data)}`, 231 | ); 232 | } 233 | } 234 | } catch (e) { 235 | $.logErr(e, resp); 236 | } finally { 237 | resolve(data); 238 | } 239 | }); 240 | }, time); 241 | } else { 242 | resolve(); 243 | } 244 | }); 245 | } 246 | 247 | function serverNotify(text, desp, time = 2100) { 248 | return new Promise((resolve) => { 249 | if (SCKEY) { 250 | //微信server酱推送通知一个\n不会换行,需要两个\n才能换行,故做此替换 251 | desp = desp.replace(/[\n\r]/g, '\n\n'); 252 | const options = { 253 | url: SCKEY.includes('SCT') 254 | ? `https://sctapi.ftqq.com/${SCKEY}.send` 255 | : `https://sc.ftqq.com/${SCKEY}.send`, 256 | body: `text=${text}&desp=${desp}`, 257 | headers: { 258 | 'Content-Type': 'application/x-www-form-urlencoded', 259 | }, 260 | timeout, 261 | }; 262 | setTimeout(() => { 263 | $.post(options, (err, resp, data) => { 264 | try { 265 | if (err) { 266 | console.log('发送通知调用API失败!!\n'); 267 | console.log(err); 268 | } else { 269 | data = JSON.parse(data); 270 | //server酱和Server酱·Turbo版的返回json格式不太一样 271 | if (data.errno === 0 || data.data.errno === 0) { 272 | console.log('server酱发送通知消息成功🎉\n'); 273 | } else if (data.errno === 1024) { 274 | // 一分钟内发送相同的内容会触发 275 | console.log(`server酱发送通知消息异常: ${data.errmsg}\n`); 276 | } else { 277 | console.log( 278 | `server酱发送通知消息异常\n${JSON.stringify(data)}`, 279 | ); 280 | } 281 | } 282 | } catch (e) { 283 | $.logErr(e, resp); 284 | } finally { 285 | resolve(data); 286 | } 287 | }); 288 | }, time); 289 | } else { 290 | resolve(); 291 | } 292 | }); 293 | } 294 | 295 | function CoolPush(text, desp) { 296 | return new Promise((resolve) => { 297 | if (QQ_SKEY) { 298 | let options = { 299 | url: `https://push.xuthus.cc/${QQ_MODE}/${QQ_SKEY}`, 300 | headers: { 301 | 'Content-Type': 'application/json', 302 | }, 303 | }; 304 | 305 | // 已知敏感词 306 | text = text.replace(/京豆/g, '豆豆'); 307 | desp = desp.replace(/京豆/g, ''); 308 | desp = desp.replace(/🐶/g, ''); 309 | desp = desp.replace(/红包/g, 'H包'); 310 | 311 | switch (QQ_MODE) { 312 | case 'email': 313 | options.json = { 314 | t: text, 315 | c: desp, 316 | }; 317 | break; 318 | default: 319 | options.body = `${text}\n\n${desp}`; 320 | } 321 | 322 | let pushMode = function (t) { 323 | switch (t) { 324 | case 'send': 325 | return '个人'; 326 | case 'group': 327 | return 'QQ群'; 328 | case 'wx': 329 | return '微信'; 330 | case 'ww': 331 | return '企业微信'; 332 | case 'email': 333 | return '邮件'; 334 | default: 335 | return '未知方式'; 336 | } 337 | }; 338 | 339 | $.post(options, (err, resp, data) => { 340 | try { 341 | if (err) { 342 | console.log(`发送${pushMode(QQ_MODE)}通知调用API失败!!\n`); 343 | console.log(err); 344 | } else { 345 | data = JSON.parse(data); 346 | if (data.code === 200) { 347 | console.log(`酷推发送${pushMode(QQ_MODE)}通知消息成功🎉\n`); 348 | } else if (data.code === 400) { 349 | console.log( 350 | `QQ酷推(Cool Push)发送${pushMode(QQ_MODE)}推送失败:${ 351 | data.msg 352 | }\n`, 353 | ); 354 | } else if (data.code === 503) { 355 | console.log(`QQ酷推出错,${data.message}:${data.data}\n`); 356 | } else { 357 | console.log(`酷推推送异常: ${JSON.stringify(data)}`); 358 | } 359 | } 360 | } catch (e) { 361 | $.logErr(e, resp); 362 | } finally { 363 | resolve(data); 364 | } 365 | }); 366 | } else { 367 | resolve(); 368 | } 369 | }); 370 | } 371 | 372 | function BarkNotify(text, desp, params = {}) { 373 | return new Promise((resolve) => { 374 | if (BARK_PUSH) { 375 | const options = { 376 | url: `${BARK_PUSH}/${encodeURIComponent(text)}/${encodeURIComponent( 377 | desp, 378 | )}?sound=${BARK_SOUND}&group=${BARK_GROUP}&${querystring.stringify(params)}`, 379 | headers: { 380 | 'Content-Type': 'application/x-www-form-urlencoded', 381 | }, 382 | timeout, 383 | }; 384 | $.get(options, (err, resp, data) => { 385 | try { 386 | if (err) { 387 | console.log('Bark APP发送通知调用API失败!!\n'); 388 | console.log(err); 389 | } else { 390 | data = JSON.parse(data); 391 | if (data.code === 200) { 392 | console.log('Bark APP发送通知消息成功🎉\n'); 393 | } else { 394 | console.log(`${data.message}\n`); 395 | } 396 | } 397 | } catch (e) { 398 | $.logErr(e, resp); 399 | } finally { 400 | resolve(); 401 | } 402 | }); 403 | } else { 404 | resolve(); 405 | } 406 | }); 407 | } 408 | 409 | function tgBotNotify(text, desp) { 410 | return new Promise((resolve) => { 411 | if (TG_BOT_TOKEN && TG_USER_ID) { 412 | const options = { 413 | url: `https://${TG_API_HOST}/bot${TG_BOT_TOKEN}/sendMessage`, 414 | body: `chat_id=${TG_USER_ID}&text=${text}\n\n${desp}&disable_web_page_preview=true`, 415 | headers: { 416 | 'Content-Type': 'application/x-www-form-urlencoded', 417 | }, 418 | timeout, 419 | }; 420 | if (TG_PROXY_HOST && TG_PROXY_PORT) { 421 | const tunnel = require('tunnel'); 422 | const agent = { 423 | https: tunnel.httpsOverHttp({ 424 | proxy: { 425 | host: TG_PROXY_HOST, 426 | port: TG_PROXY_PORT * 1, 427 | proxyAuth: TG_PROXY_AUTH, 428 | }, 429 | }), 430 | }; 431 | Object.assign(options, { agent }); 432 | } 433 | $.post(options, (err, resp, data) => { 434 | try { 435 | if (err) { 436 | console.log('telegram发送通知消息失败!!\n'); 437 | console.log(err); 438 | } else { 439 | data = JSON.parse(data); 440 | if (data.ok) { 441 | console.log('Telegram发送通知消息成功🎉。\n'); 442 | } else if (data.error_code === 400) { 443 | console.log( 444 | '请主动给bot发送一条消息并检查接收用户ID是否正确。\n', 445 | ); 446 | } else if (data.error_code === 401) { 447 | console.log('Telegram bot token 填写错误。\n'); 448 | } 449 | } 450 | } catch (e) { 451 | $.logErr(e, resp); 452 | } finally { 453 | resolve(data); 454 | } 455 | }); 456 | } else { 457 | resolve(); 458 | } 459 | }); 460 | } 461 | function ddBotNotify(text, desp) { 462 | return new Promise((resolve) => { 463 | const options = { 464 | url: `https://oapi.dingtalk.com/robot/send?access_token=${DD_BOT_TOKEN}`, 465 | json: { 466 | msgtype: 'text', 467 | text: { 468 | content: ` ${text}\n\n${desp}`, 469 | }, 470 | }, 471 | headers: { 472 | 'Content-Type': 'application/json', 473 | }, 474 | timeout, 475 | }; 476 | if (DD_BOT_TOKEN && DD_BOT_SECRET) { 477 | const crypto = require('crypto'); 478 | const dateNow = Date.now(); 479 | const hmac = crypto.createHmac('sha256', DD_BOT_SECRET); 480 | hmac.update(`${dateNow}\n${DD_BOT_SECRET}`); 481 | const result = encodeURIComponent(hmac.digest('base64')); 482 | options.url = `${options.url}×tamp=${dateNow}&sign=${result}`; 483 | $.post(options, (err, resp, data) => { 484 | try { 485 | if (err) { 486 | console.log('钉钉发送通知消息失败!!\n'); 487 | console.log(err); 488 | } else { 489 | data = JSON.parse(data); 490 | if (data.errcode === 0) { 491 | console.log('钉钉发送通知消息成功🎉。\n'); 492 | } else { 493 | console.log(`${data.errmsg}\n`); 494 | } 495 | } 496 | } catch (e) { 497 | $.logErr(e, resp); 498 | } finally { 499 | resolve(data); 500 | } 501 | }); 502 | } else if (DD_BOT_TOKEN) { 503 | $.post(options, (err, resp, data) => { 504 | try { 505 | if (err) { 506 | console.log('钉钉发送通知消息失败!!\n'); 507 | console.log(err); 508 | } else { 509 | data = JSON.parse(data); 510 | if (data.errcode === 0) { 511 | console.log('钉钉发送通知消息完成。\n'); 512 | } else { 513 | console.log(`${data.errmsg}\n`); 514 | } 515 | } 516 | } catch (e) { 517 | $.logErr(e, resp); 518 | } finally { 519 | resolve(data); 520 | } 521 | }); 522 | } else { 523 | resolve(); 524 | } 525 | }); 526 | } 527 | 528 | function qywxBotNotify(text, desp) { 529 | return new Promise((resolve) => { 530 | const options = { 531 | url: `https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=${QYWX_KEY}`, 532 | json: { 533 | msgtype: 'text', 534 | text: { 535 | content: ` ${text}\n\n${desp}`, 536 | }, 537 | }, 538 | headers: { 539 | 'Content-Type': 'application/json', 540 | }, 541 | timeout, 542 | }; 543 | if (QYWX_KEY) { 544 | $.post(options, (err, resp, data) => { 545 | try { 546 | if (err) { 547 | console.log('企业微信发送通知消息失败!!\n'); 548 | console.log(err); 549 | } else { 550 | data = JSON.parse(data); 551 | if (data.errcode === 0) { 552 | console.log('企业微信发送通知消息成功🎉。\n'); 553 | } else { 554 | console.log(`${data.errmsg}\n`); 555 | } 556 | } 557 | } catch (e) { 558 | $.logErr(e, resp); 559 | } finally { 560 | resolve(data); 561 | } 562 | }); 563 | } else { 564 | resolve(); 565 | } 566 | }); 567 | } 568 | 569 | function ChangeUserId(desp) { 570 | const QYWX_AM_AY = QYWX_AM.split(','); 571 | if (QYWX_AM_AY[2]) { 572 | const userIdTmp = QYWX_AM_AY[2].split('|'); 573 | let userId = ''; 574 | for (let i = 0; i < userIdTmp.length; i++) { 575 | const count = '账号' + (i + 1); 576 | const count2 = '签到号 ' + (i + 1); 577 | if (desp.match(count2)) { 578 | userId = userIdTmp[i]; 579 | } 580 | } 581 | if (!userId) userId = QYWX_AM_AY[2]; 582 | return userId; 583 | } else { 584 | return '@all'; 585 | } 586 | } 587 | 588 | function qywxamNotify(text, desp) { 589 | return new Promise((resolve) => { 590 | if (QYWX_AM) { 591 | const QYWX_AM_AY = QYWX_AM.split(','); 592 | const options_accesstoken = { 593 | url: `https://qyapi.weixin.qq.com/cgi-bin/gettoken`, 594 | json: { 595 | corpid: `${QYWX_AM_AY[0]}`, 596 | corpsecret: `${QYWX_AM_AY[1]}`, 597 | }, 598 | headers: { 599 | 'Content-Type': 'application/json', 600 | }, 601 | timeout, 602 | }; 603 | $.post(options_accesstoken, (err, resp, data) => { 604 | html = desp.replace(/\n/g, '
'); 605 | var json = JSON.parse(data); 606 | accesstoken = json.access_token; 607 | let options; 608 | 609 | switch (QYWX_AM_AY[4]) { 610 | case '0': 611 | options = { 612 | msgtype: 'textcard', 613 | textcard: { 614 | title: `${text}`, 615 | description: `${desp}`, 616 | url: 'https://github.com/insoxin/imaotai/', 617 | btntxt: '更多', 618 | }, 619 | }; 620 | break; 621 | 622 | case '1': 623 | options = { 624 | msgtype: 'text', 625 | text: { 626 | content: `${text}\n\n${desp}`, 627 | }, 628 | }; 629 | break; 630 | 631 | default: 632 | options = { 633 | msgtype: 'mpnews', 634 | mpnews: { 635 | articles: [ 636 | { 637 | title: `${text}`, 638 | thumb_media_id: `${QYWX_AM_AY[4]}`, 639 | author: `智能助手`, 640 | content_source_url: ``, 641 | content: `${html}`, 642 | digest: `${desp}`, 643 | }, 644 | ], 645 | }, 646 | }; 647 | } 648 | if (!QYWX_AM_AY[4]) { 649 | //如不提供第四个参数,则默认进行文本消息类型推送 650 | options = { 651 | msgtype: 'text', 652 | text: { 653 | content: `${text}\n\n${desp}`, 654 | }, 655 | }; 656 | } 657 | options = { 658 | url: `https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=${accesstoken}`, 659 | json: { 660 | touser: `${ChangeUserId(desp)}`, 661 | agentid: `${QYWX_AM_AY[3]}`, 662 | safe: '0', 663 | ...options, 664 | }, 665 | headers: { 666 | 'Content-Type': 'application/json', 667 | }, 668 | }; 669 | 670 | $.post(options, (err, resp, data) => { 671 | try { 672 | if (err) { 673 | console.log( 674 | '成员ID:' + 675 | ChangeUserId(desp) + 676 | '企业微信应用消息发送通知消息失败!!\n', 677 | ); 678 | console.log(err); 679 | } else { 680 | data = JSON.parse(data); 681 | if (data.errcode === 0) { 682 | console.log( 683 | '成员ID:' + 684 | ChangeUserId(desp) + 685 | '企业微信应用消息发送通知消息成功🎉。\n', 686 | ); 687 | } else { 688 | console.log(`${data.errmsg}\n`); 689 | } 690 | } 691 | } catch (e) { 692 | $.logErr(e, resp); 693 | } finally { 694 | resolve(data); 695 | } 696 | }); 697 | }); 698 | } else { 699 | resolve(); 700 | } 701 | }); 702 | } 703 | 704 | function iGotNotify(text, desp, params = {}) { 705 | return new Promise((resolve) => { 706 | if (IGOT_PUSH_KEY) { 707 | // 校验传入的IGOT_PUSH_KEY是否有效 708 | const IGOT_PUSH_KEY_REGX = new RegExp('^[a-zA-Z0-9]{24}$'); 709 | if (!IGOT_PUSH_KEY_REGX.test(IGOT_PUSH_KEY)) { 710 | console.log('您所提供的IGOT_PUSH_KEY无效\n'); 711 | resolve(); 712 | return; 713 | } 714 | const options = { 715 | url: `https://push.hellyw.com/${IGOT_PUSH_KEY.toLowerCase()}`, 716 | body: `title=${text}&content=${desp}&${querystring.stringify(params)}`, 717 | headers: { 718 | 'Content-Type': 'application/x-www-form-urlencoded', 719 | }, 720 | timeout, 721 | }; 722 | $.post(options, (err, resp, data) => { 723 | try { 724 | if (err) { 725 | console.log('发送通知调用API失败!!\n'); 726 | console.log(err); 727 | } else { 728 | if (typeof data === 'string') data = JSON.parse(data); 729 | if (data.ret === 0) { 730 | console.log('iGot发送通知消息成功🎉\n'); 731 | } else { 732 | console.log(`iGot发送通知消息失败:${data.errMsg}\n`); 733 | } 734 | } 735 | } catch (e) { 736 | $.logErr(e, resp); 737 | } finally { 738 | resolve(data); 739 | } 740 | }); 741 | } else { 742 | resolve(); 743 | } 744 | }); 745 | } 746 | 747 | function pushPlusNotify(text, desp) { 748 | return new Promise((resolve) => { 749 | if (PUSH_PLUS_TOKEN) { 750 | desp = desp.replace(/[\n\r]/g, '
'); // 默认为html, 不支持plaintext 751 | const body = { 752 | token: `${PUSH_PLUS_TOKEN}`, 753 | title: `${text}`, 754 | content: `${desp}`, 755 | topic: `${PUSH_PLUS_USER}`, 756 | }; 757 | const options = { 758 | url: `https://www.pushplus.plus/send`, 759 | body: JSON.stringify(body), 760 | headers: { 761 | 'Content-Type': ' application/json', 762 | }, 763 | timeout, 764 | }; 765 | $.post(options, (err, resp, data) => { 766 | try { 767 | if (err) { 768 | console.log( 769 | `push+发送${ 770 | PUSH_PLUS_USER ? '一对多' : '一对一' 771 | }通知消息失败!!\n`, 772 | ); 773 | console.log(err); 774 | } else { 775 | data = JSON.parse(data); 776 | if (data.code === 200) { 777 | console.log( 778 | `push+发送${ 779 | PUSH_PLUS_USER ? '一对多' : '一对一' 780 | }通知消息完成。\n`, 781 | ); 782 | } else { 783 | console.log( 784 | `push+发送${ 785 | PUSH_PLUS_USER ? '一对多' : '一对一' 786 | }通知消息失败:${data.msg}\n`, 787 | ); 788 | } 789 | } 790 | } catch (e) { 791 | $.logErr(e, resp); 792 | } finally { 793 | resolve(data); 794 | } 795 | }); 796 | } else { 797 | resolve(); 798 | } 799 | }); 800 | } 801 | 802 | module.exports = { 803 | sendNotify, 804 | BARK_PUSH, 805 | }; 806 | 807 | // prettier-ignore 808 | function Env(t,s){return new class{constructor(t,s){this.name=t,this.data=null,this.dataFile="box.dat",this.logs=[],this.logSeparator="\n",this.startTime=(new Date).getTime(),Object.assign(this,s),this.log("",`\ud83d\udd14${this.name}, \u5f00\u59cb!`)}isNode(){return"undefined"!=typeof module&&!!module.exports}isQuanX(){return"undefined"!=typeof $task}isSurge(){return"undefined"!=typeof $httpClient&&"undefined"==typeof $loon}isLoon(){return"undefined"!=typeof $loon}getScript(t){return new Promise(s=>{$.get({url:t},(t,e,i)=>s(i))})}runScript(t,s){return new Promise(e=>{let i=this.getdata("@chavy_boxjs_userCfgs.httpapi");i=i?i.replace(/\n/g,"").trim():i;let o=this.getdata("@chavy_boxjs_userCfgs.httpapi_timeout");o=o?1*o:20,o=s&&s.timeout?s.timeout:o;const[h,a]=i.split("@"),r={url:`http://${a}/v1/scripting/evaluate`,body:{script_text:t,mock_type:"cron",timeout:o},headers:{"X-Key":h,Accept:"*/*"}};$.post(r,(t,s,i)=>e(i))}).catch(t=>this.logErr(t))}loaddata(){if(!this.isNode())return{};{this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),s=this.path.resolve(process.cwd(),this.dataFile),e=this.fs.existsSync(t),i=!e&&this.fs.existsSync(s);if(!e&&!i)return{};{const i=e?t:s;try{return JSON.parse(this.fs.readFileSync(i))}catch(t){return{}}}}}writedata(){if(this.isNode()){this.fs=this.fs?this.fs:require("fs"),this.path=this.path?this.path:require("path");const t=this.path.resolve(this.dataFile),s=this.path.resolve(process.cwd(),this.dataFile),e=this.fs.existsSync(t),i=!e&&this.fs.existsSync(s),o=JSON.stringify(this.data);e?this.fs.writeFileSync(t,o):i?this.fs.writeFileSync(s,o):this.fs.writeFileSync(t,o)}}lodash_get(t,s,e){const i=s.replace(/\[(\d+)\]/g,".$1").split(".");let o=t;for(const t of i)if(o=Object(o)[t],void 0===o)return e;return o}lodash_set(t,s,e){return Object(t)!==t?t:(Array.isArray(s)||(s=s.toString().match(/[^.[\]]+/g)||[]),s.slice(0,-1).reduce((t,e,i)=>Object(t[e])===t[e]?t[e]:t[e]=Math.abs(s[i+1])>>0==+s[i+1]?[]:{},t)[s[s.length-1]]=e,t)}getdata(t){let s=this.getval(t);if(/^@/.test(t)){const[,e,i]=/^@(.*?)\.(.*?)$/.exec(t),o=e?this.getval(e):"";if(o)try{const t=JSON.parse(o);s=t?this.lodash_get(t,i,""):s}catch(t){s=""}}return s}setdata(t,s){let e=!1;if(/^@/.test(s)){const[,i,o]=/^@(.*?)\.(.*?)$/.exec(s),h=this.getval(i),a=i?"null"===h?null:h||"{}":"{}";try{const s=JSON.parse(a);this.lodash_set(s,o,t),e=this.setval(JSON.stringify(s),i)}catch(s){const h={};this.lodash_set(h,o,t),e=this.setval(JSON.stringify(h),i)}}else e=$.setval(t,s);return e}getval(t){return this.isSurge()||this.isLoon()?$persistentStore.read(t):this.isQuanX()?$prefs.valueForKey(t):this.isNode()?(this.data=this.loaddata(),this.data[t]):this.data&&this.data[t]||null}setval(t,s){return this.isSurge()||this.isLoon()?$persistentStore.write(t,s):this.isQuanX()?$prefs.setValueForKey(t,s):this.isNode()?(this.data=this.loaddata(),this.data[s]=t,this.writedata(),!0):this.data&&this.data[s]||null}initGotEnv(t){this.got=this.got?this.got:require("got"),this.cktough=this.cktough?this.cktough:require("tough-cookie"),this.ckjar=this.ckjar?this.ckjar:new this.cktough.CookieJar,t&&(t.headers=t.headers?t.headers:{},void 0===t.headers.Cookie&&void 0===t.cookieJar&&(t.cookieJar=this.ckjar))}get(t,s=(()=>{})){t.headers&&(delete t.headers["Content-Type"],delete t.headers["Content-Length"]),this.isSurge()||this.isLoon()?$httpClient.get(t,(t,e,i)=>{!t&&e&&(e.body=i,e.statusCode=e.status),s(t,e,i)}):this.isQuanX()?$task.fetch(t).then(t=>{const{statusCode:e,statusCode:i,headers:o,body:h}=t;s(null,{status:e,statusCode:i,headers:o,body:h},h)},t=>s(t)):this.isNode()&&(this.initGotEnv(t),this.got(t).on("redirect",(t,s)=>{try{const e=t.headers["set-cookie"].map(this.cktough.Cookie.parse).toString();this.ckjar.setCookieSync(e,null),s.cookieJar=this.ckjar}catch(t){this.logErr(t)}}).then(t=>{const{statusCode:e,statusCode:i,headers:o,body:h}=t;s(null,{status:e,statusCode:i,headers:o,body:h},h)},t=>s(t)))}post(t,s=(()=>{})){if(t.body&&t.headers&&!t.headers["Content-Type"]&&(t.headers["Content-Type"]="application/x-www-form-urlencoded"),delete t.headers["Content-Length"],this.isSurge()||this.isLoon())$httpClient.post(t,(t,e,i)=>{!t&&e&&(e.body=i,e.statusCode=e.status),s(t,e,i)});else if(this.isQuanX())t.method="POST",$task.fetch(t).then(t=>{const{statusCode:e,statusCode:i,headers:o,body:h}=t;s(null,{status:e,statusCode:i,headers:o,body:h},h)},t=>s(t));else if(this.isNode()){this.initGotEnv(t);const{url:e,...i}=t;this.got.post(e,i).then(t=>{const{statusCode:e,statusCode:i,headers:o,body:h}=t;s(null,{status:e,statusCode:i,headers:o,body:h},h)},t=>s(t))}}time(t){let s={"M+":(new Date).getMonth()+1,"d+":(new Date).getDate(),"H+":(new Date).getHours(),"m+":(new Date).getMinutes(),"s+":(new Date).getSeconds(),"q+":Math.floor(((new Date).getMonth()+3)/3),S:(new Date).getMilliseconds()};/(y+)/.test(t)&&(t=t.replace(RegExp.$1,((new Date).getFullYear()+"").substr(4-RegExp.$1.length)));for(let e in s)new RegExp("("+e+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?s[e]:("00"+s[e]).substr((""+s[e]).length)));return t}msg(s=t,e="",i="",o){const h=t=>!t||!this.isLoon()&&this.isSurge()?t:"string"==typeof t?this.isLoon()?t:this.isQuanX()?{"open-url":t}:void 0:"object"==typeof t&&(t["open-url"]||t["media-url"])?this.isLoon()?t["open-url"]:this.isQuanX()?t:void 0:void 0;$.isMute||(this.isSurge()||this.isLoon()?$notification.post(s,e,i,h(o)):this.isQuanX()&&$notify(s,e,i,h(o))),this.logs.push("","==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============="),this.logs.push(s),e&&this.logs.push(e),i&&this.logs.push(i)}log(...t){t.length>0?this.logs=[...this.logs,...t]:console.log(this.logs.join(this.logSeparator))}logErr(t,s){const e=!this.isSurge()&&!this.isQuanX()&&!this.isLoon();e?$.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t.stack):$.log("",`\u2757\ufe0f${this.name}, \u9519\u8bef!`,t)}wait(t){return new Promise(s=>setTimeout(s,t))}done(t={}){const s=(new Date).getTime(),e=(s-this.startTime)/1e3;this.log("",`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${e} \u79d2`),this.log(),(this.isSurge()||this.isQuanX()||this.isLoon())&&$done(t)}}(t,s)} 809 | -------------------------------------------------------------------------------- /docs/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | ## Welcome to GitHub Pages 2 | 3 | You can use the [editor on GitHub](https://github.com/imaotai/imaotai/edit/main/docs/index.md) to maintain and preview the content for your website in Markdown files. 4 | 5 | Whenever you commit to this repository, GitHub Pages will run [Jekyll](https://jekyllrb.com/) to rebuild the pages in your site, from the content in your Markdown files. 6 | 7 | ### Markdown 8 | 9 | Markdown is a lightweight and easy-to-use syntax for styling your writing. It includes conventions for 10 | 11 | ```markdown 12 | Syntax highlighted code block 13 | 14 | # Header 1 15 | ## Header 2 16 | ### Header 3 17 | 18 | - Bulleted 19 | - List 20 | 21 | 1. Numbered 22 | 2. List 23 | 24 | **Bold** and _Italic_ and `Code` text 25 | 26 | [Link](url) and ![Image](src) 27 | ``` 28 | 29 | For more details see [Basic writing and formatting syntax](https://docs.github.com/en/github/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax). 30 | 31 | ### Jekyll Themes 32 | 33 | Your Pages site will use the layout and styles from the Jekyll theme you have selected in your [repository settings](https://github.com/imaotai/imaotai/settings/pages). The name of this theme is saved in the Jekyll `_config.yml` configuration file. 34 | 35 | ### Support or Contact 36 | 37 | Having trouble with Pages? Check out our [documentation](https://docs.github.com/categories/github-pages-basics/) or [contact support](https://support.github.com/contact) and we’ll help you sort it out. 38 | --------------------------------------------------------------------------------