Guest User

Untitled

a guest
Jul 13th, 2022
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 38.88 KB | None | 0 0
  1. /*
  2. * @Author: AsVow
  3. * @LastMod: 2022-01-20 20:43:14
  4. *
  5. 无忧行签到脚本
  6. 脚本兼容: QuantumultX, Surge4, Loon, Node.js
  7. ⚠️更新说明: 移除失效活动.
  8.  
  9. Cookie说明:分为四部分「 accountid|mobile|token|userid 」
  10. 1.打开无忧行点击「 我的 」然后点击「 我的客服 」👉 通知成功写入「 accountid & mobile 」, 点击「 无忧币商城 」 👉 通知成功写入「 token & userid 」.
  11. 2.上述步骤完成后, 通知「 Cookie完整 」, 则可使用此签到脚本.
  12. 3.「 token 」失效时,重新点击「 无忧币商城 」 👉 通知更新「 token 」成功.
  13. ‼️‼️退出登录「 token 」即时失效, 因此添加多账号Cookie需删除APP重新下载, 再登录另一账号, 然后按照上述步骤重新获取.
  14. 4.获取Cookie后, 请将Cookie脚本禁用并移除主机名, 以免产生不必要的MITM.
  15.  
  16. Node.js用户说明:
  17. 1.请自行设置AsVow环境参数, 参考格式:
  18. export AsVow='[{accountid:账号1,mobile:账号1,token:账号1,userid:账号1},{accountid:账号2,mobile:账号2,token:账号2,userid:账号2}]'
  19. 2.在环境中或脚本内「 SetVariable 」函数里设置通知参数, 参考文档「 https://asvow.com/param 」.
  20.  
  21. **********************
  22. QuantumultX 脚本配置:
  23. **********************
  24. [task_local]
  25. # Tasks: JegoTrip
  26. 0 9 * * * https://ooxx.be/js/jegotrip.js, tag=无忧行, img-url=https://ooxx.be/own/icon/jegotrip.png, enabled=true
  27.  
  28. [rewrite_local]
  29. # JegoTrip Cookie
  30. https?:\/\/app\.jegotrip\.com\.cn\/.*(call_phone|logonFree) url script-response-body https://ooxx.be/js/jegotrip.js
  31.  
  32. [mitm]
  33. hostname= app.jegotrip.com.cn
  34.  
  35. **********************
  36. Surge 4.2.0+ 脚本配置:
  37. **********************
  38. [Script]
  39. Tasks: JegoTrip = type=cron,cronexp=0 9 * * *,script-path=https://ooxx.be/js/jegotrip.js
  40.  
  41. JegoTrip Cookie = type=http-response,pattern=https?:\/\/app\.jegotrip\.com\.cn\/.*(call_phone|logonFree),script-path=https://ooxx.be/js/jegotrip.js, requires-body=true
  42. [MITM]
  43. hostname= app.jegotrip.com.cn
  44.  
  45. ************************
  46. Loon 2.1.0+ 脚本配置:
  47. ************************
  48.  
  49. [Script]
  50. # Tasks: JegoTrip
  51. cron "0 9 * * *" script-path=https://ooxx.be/js/jegotrip.js
  52.  
  53. # JegoTrip Cookie
  54. http-response https?:\/\/app\.jegotrip\.com\.cn\/.*(call_phone|logonFree) script-path=https://ooxx.be/js/jegotrip.js, requires-body=true
  55.  
  56. [Mitm]
  57. hostname= app.jegotrip.com.cn
  58.  
  59. */
  60. const $ = API('无忧行');
  61. const { isNode } = ENV();
  62. const headers = {
  63. 'Accept-Encoding': 'gzip, deflate, br',
  64. 'Origin': '\u0068\u0074\u0074\u0070\u003a\u002f\u002f\u0074\u0061\u0073\u006b\u002e\u006a\u0065\u0067\u006f\u0074\u0072\u0069\u0070\u002e\u0063\u006f\u006d\u002e\u0063\u006e\u003a\u0038\u0030\u0038\u0030',
  65. 'Accept': 'application/json, text/plain, */*',
  66. 'Content-Type': 'application/json;charset=utf-8',
  67. 'Connection': 'keep-alive',
  68. 'Host': '\u0074\u0061\u0073\u006b\u002e\u006a\u0065\u0067\u006f\u0074\u0072\u0069\u0070\u002e\u0063\u006f\u006d\u002e\u0063\u006e\u003a\u0038\u0030\u0038\u0030',
  69. 'Accept-Language': 'en-us',
  70. 'Referer': '\u0068\u0074\u0074\u0070\u003a\u002f\u002f\u0074\u0061\u0073\u006b\u002e\u006a\u0065\u0067\u006f\u0074\u0072\u0069\u0070\u002e\u0063\u006f\u006d\u002e\u0063\u006e\u003a\u0038\u0030\u0038\u0030\u002f\u0074\u0061\u0073\u006b\u002f\u0069\u006e\u0064\u0065\u0078\u002e\u0068\u0074\u006d\u006c'
  71. };
  72. // $.delete('AsVow'); //取消本条注释删除所有Cookie
  73. var AsVow = isNode ? process.env.AsVow : $.read('AsVow');
  74. var info = '';
  75.  
  76. // 多平台通知参数设置
  77. function SetVariable () {
  78. // 微信server酱
  79. $.SCKEY = '';
  80. // pushplus(推送加)
  81. $.PUSH_PLUS_TOKEN = '';
  82. $.PUSH_PLUS_USER = '';
  83. // iOS Bark APP(兼容Bark自建用户)
  84. $.BARK_PUSH = '';
  85. $.BARK_SOUND = '';
  86. $.BARK_GROUP = '';
  87. // Telegram 机器人
  88. $.TG_BOT_TOKEN = '';
  89. $.TG_USER_ID = '';
  90. $.TG_PROXY_HOST = '';
  91. $.TG_PROXY_PORT = '';
  92. $.TG_PROXY_AUTH = '';
  93. $.TG_API_HOST = '';
  94. // 钉钉机器人
  95. $.DD_BOT_TOKEN = '';
  96. $.DD_BOT_SECRET = '';
  97. // 企业微信机器人
  98. $.QYWX_KEY = '';
  99. // 企业微信应用消息推送
  100. $.QYWX_AM = '';
  101. // iGot
  102. $.IGOT_PUSH_KEY = '';
  103. // go-cqhttp
  104. $.GOBOT_URL = '';
  105. $.GOBOT_TOKEN = '';
  106. $.GOBOT_QQ = '';
  107. }
  108.  
  109. !(async () => {
  110. if (typeof $request != 'undefined') {
  111. GetCookie();
  112. } else if (AsVow) {
  113. if (isNode) {
  114. await SetVariable ();
  115. AsVow = $.toObj(AsVow.replace(/(['"])?(\w+)(['"])?/g, '"$2"'));
  116. }
  117. for (i in AsVow) {
  118. accountid = AsVow[i].accountid;
  119. mobile = AsVow[i].mobile;
  120. token = AsVow[i].token;
  121. userid = AsVow[i].userid;
  122. invalid = false;
  123. if (accountid && mobile && token && userid) {
  124. star = '';
  125. for(x in [...Array(mobile.length-6).keys()]) star += '*';
  126. _mobile = mobile.slice(0,3);
  127. mobile_ = mobile.slice(-3);
  128. _mobile_ = _mobile + star + mobile_;
  129. head = `=== 账号${(+i)+1}:${_mobile_} ===\n`;
  130. info += `\n${head}`;
  131. headers['User-Agent'] = GetRandomUA();
  132. await QuerySign();
  133. if (invalid) {
  134. info += 'Token已失效‼️\n\n';
  135. continue;
  136. }
  137. 11 == mobile.length ? await QueryVideoTask() : info += '视频任务:+86号码专属‼️\n';
  138. await Total();
  139. } else {
  140. INC_Cookie = $.toStr(AsVow[i]);
  141. AsVow = $.toObj($.toStr(AsVow).replace(INC_Cookie,'').replace(/,]*$/, ']'));
  142. $.write(AsVow,'AsVow');
  143. $.error(`⚠️自动删除不完整的Cookie\n ${INC_Cookie}`);
  144. }
  145. }
  146. $.notify($.name, '', info);
  147. } else {
  148. info = '签到失败:请先获取Cookie⚠️';
  149. $.notify($.name, '', info);
  150. }
  151. })().finally(() => {
  152. $.done();
  153. });
  154.  
  155.  
  156. function Total() {
  157. const url = '\u0068\u0074\u0074\u0070\u0073\u003a\u002f\u002f\u0061\u0070\u0070\u002e\u006a\u0065\u0067\u006f\u0074\u0072\u0069\u0070\u002e\u0063\u006f\u006d\u002e\u0063\u006e\u002f\u0061\u0070\u0069\u002f\u0073\u0065\u0072\u0076\u0069\u0063\u0065\u002f\u0075\u0073\u0065\u0072\u002f\u0076\u0031\u002f\u0067\u0065\u0074\u0055\u0073\u0065\u0072\u0041\u0073\u0073\u0065\u0074\u0073\u003f\u006c\u0061\u006e\u0067\u003d\u007a\u0068\u005f\u0063\u006e\u0026\u0074\u006f\u006b\u0065\u006e\u003d' + token;
  158. const body = `{"token":"${token}"}`;
  159. headers['Host'] = '\u0061\u0070\u0070\u002e\u006a\u0065\u0067\u006f\u0074\u0072\u0069\u0070\u002e\u0063\u006f\u006d\u002e\u0063\u006e';
  160. headers['Referer'] = '\u0068\u0074\u0074\u0070\u003a\u002f\u002f\u0074\u0061\u0073\u006b\u002e\u006a\u0065\u0067\u006f\u0074\u0072\u0069\u0070\u002e\u0063\u006f\u006d\u002e\u0063\u006e\u003a\u0038\u0030\u0038\u0030\u002f';
  161. const request = {
  162. url: url,
  163. headers: headers,
  164. body: body
  165. };
  166. return new Promise(resolve => {
  167. $.http.post(request)
  168. .then((resp) => {
  169. $.log(`\nTotal body: \n${$.toStr(resp)}`);
  170. data = $.toObj(resp.body);
  171. total = data.body.tripCoins;
  172. info += `无忧币总计:${total}💰\n`;
  173. })
  174. .catch((err) => {
  175. const error = '账号信息获取失败⚠️';
  176. $.error(error + '\n' + err);
  177. $.notify($.name, '', `${head+error}请查看日志‼️`);
  178. })
  179. .finally(() => {
  180. resolve();
  181. });
  182. });
  183. }
  184.  
  185.  
  186. function QuerySign() {
  187. const url = '\u0068\u0074\u0074\u0070\u0073\u003a\u002f\u002f\u0061\u0070\u0070\u002e\u006a\u0065\u0067\u006f\u0074\u0072\u0069\u0070\u002e\u0063\u006f\u006d\u002e\u0063\u006e\u002f\u0061\u0070\u0069\u002f\u0073\u0065\u0072\u0076\u0069\u0063\u0065\u002f\u0076\u0031\u002f\u006d\u0069\u0073\u0073\u0069\u006f\u006e\u002f\u0073\u0069\u0067\u006e\u002f\u0071\u0075\u0065\u0072\u0079\u0053\u0069\u0067\u006e\u003f\u0074\u006f\u006b\u0065\u006e\u003d' + token;
  188. headers['Origin'] = '\u0068\u0074\u0074\u0070\u0073\u003a\u002f\u002f\u0063\u0064\u006e\u002e\u006a\u0065\u0067\u006f\u0074\u0072\u0069\u0070\u002e\u0063\u006f\u006d\u002e\u0063\u006e';
  189. headers['Host'] = '\u0061\u0070\u0070\u002e\u006a\u0065\u0067\u006f\u0074\u0072\u0069\u0070\u002e\u0063\u006f\u006d\u002e\u0063\u006e';
  190. headers['User-Agent'] = 'Mozilla/4.0 MDN Example';
  191. headers['Referer'] = '\u0068\u0074\u0074\u0070\u0073\u003a\u002f\u002f\u0063\u0064\u006e\u002e\u006a\u0065\u0067\u006f\u0074\u0072\u0069\u0070\u002e\u0063\u006f\u006d\u002e\u0063\u006e\u002f';
  192. const request = {
  193. url: url,
  194. headers: headers
  195. };
  196. return new Promise(resolve => {
  197. $.http.post(request)
  198. .then(async (resp) => {
  199. $.log(`\nQuerySign body: \n${resp}`);
  200. data = resp.body;
  201. if (data.includes('成功')) {
  202. data = $.toObj(data);
  203. list = data.body.reverse();
  204. for (var i in list) {
  205. isSign = list[i].isSign;
  206. if (isSign == '3') {
  207. info += '签到失败:今日已签到‼️\n';
  208. break;
  209. } else if (isSign == '2') {
  210. id = list[i].id;
  211. rewardCoin = list[i].rewardCoin;
  212. await UserSign(headers);
  213. break;
  214. }
  215. }
  216. } else if (data.includes('不正确')) {
  217. invalid = true;
  218. $.notify($.name, '', `${head}\nToken已失效‼️`);
  219. }
  220. })
  221. .catch((err) => {
  222. const error = '签到状态获取失败⚠️';
  223. $.error(error + '\n' + err);
  224. $.notify($.name, '', `${head+error}请查看日志‼️`);
  225. })
  226. .finally(() => {
  227. resolve();
  228. });
  229. });
  230. }
  231.  
  232.  
  233. function UserSign(headers) {
  234. const url = '\u0068\u0074\u0074\u0070\u0073\u003a\u002f\u002f\u0061\u0070\u0070\u002e\u006a\u0065\u0067\u006f\u0074\u0072\u0069\u0070\u002e\u0063\u006f\u006d\u002e\u0063\u006e\u002f\u0061\u0070\u0069\u002f\u0073\u0065\u0072\u0076\u0069\u0063\u0065\u002f\u0076\u0031\u002f\u006d\u0069\u0073\u0073\u0069\u006f\u006e\u002f\u0073\u0069\u0067\u006e\u002f\u0075\u0073\u0065\u0072\u0053\u0069\u0067\u006e\u003f\u0074\u006f\u006b\u0065\u006e\u003d' + token;
  235. const body = `{"signConfigId":"${id}"}`;
  236. const request = {
  237. url: url,
  238. headers: headers,
  239. body: body
  240. };
  241. return new Promise(resolve => {
  242. $.http.post(request)
  243. .then((resp) => {
  244. $.log(`\nUserSign body: \n${resp}`);
  245. data = resp.body;
  246. if (data.includes('成功')) {
  247. info += `签到成功:无忧币 +${rewardCoin}🎉\n`;
  248. }
  249. })
  250. .catch((err) => {
  251. const error = '签到失败⚠️';
  252. $.error(error + '\n' + err);
  253. $.notify($.name, '', `${head+error}请查看日志‼️`);
  254. })
  255. .finally(() => {
  256. resolve();
  257. });
  258. });
  259. }
  260.  
  261.  
  262. function QueryVideoTask() {
  263. const url = '\u0068\u0074\u0074\u0070\u0073\u003a\u002f\u002f\u0075\u0064\u0073\u002d\u0069\u002e\u0063\u006d\u0069\u0073\u0068\u006f\u0077\u002e\u0063\u006f\u006d\u003a\u0031\u0034\u0034\u0033\u002f\u0075\u0064\u0073\u002f\u0063\u006c\u006f\u0075\u0064\u002f\u0077\u0061\u0074\u0063\u0068\u002f\u006c\u0069\u0073\u0074\u003f\u0076\u0065\u0072\u0073\u0069\u006f\u006e\u003d\u0031';
  264. headers['Origin'] = '\u0068\u0074\u0074\u0070\u0073\u003a\u002f\u002f\u0069\u0073\u0068\u006f\u0077\u002e\u006a\u0065\u0067\u006f\u0074\u0072\u0069\u0070\u002e\u0063\u006f\u006d\u002e\u0063\u006e';
  265. headers['Host'] = '\u0075\u0064\u0073\u002d\u0069\u002e\u0063\u006d\u0069\u0073\u0068\u006f\u0077\u002e\u0063\u006f\u006d\u003a\u0031\u0034\u0034\u0033';
  266. headers['Referer'] = '\u0068\u0074\u0074\u0070\u0073\u003a\u002f\u002f\u0069\u0073\u0068\u006f\u0077\u002e\u006a\u0065\u0067\u006f\u0074\u0072\u0069\u0070\u002e\u0063\u006f\u006d\u002e\u0063\u006e\u002f';
  267. const body = `{
  268. "userId":"${accountid}",
  269. "accountId":"${mobile}"
  270. }`;
  271. const request = {
  272. url: url,
  273. headers: headers,
  274. body: body
  275. };
  276. return new Promise(resolve => {
  277. $.http.post(request)
  278. .then(async (resp) => {
  279. $.log(`\nQueryVideoTask body: \n${resp}`);
  280. data = resp.body;
  281. if (data.includes('"exchangeNum":10,')) {
  282. info += `视频任务:今日已完成‼️\n`;
  283. } else {
  284. await VideoTask(headers);
  285. }
  286. })
  287. .catch((err) => {
  288. const error = '视频任务信息获取失败⚠️';
  289. $.error(error + '\n' + err);
  290. $.notify($.name, '', `${head+error}请查看日志‼️`);
  291. })
  292. .finally(() => {
  293. resolve();
  294. });
  295. });
  296. }
  297.  
  298.  
  299. function VideoTask(headers) {
  300. const url = '\u0068\u0074\u0074\u0070\u0073\u003a\u002f\u002f\u0075\u0064\u0073\u002d\u0069\u002e\u0063\u006d\u0069\u0073\u0068\u006f\u0077\u002e\u0063\u006f\u006d\u003a\u0031\u0034\u0034\u0033\u002f\u0075\u0064\u0073\u002f\u0063\u006c\u006f\u0075\u0064\u002f\u0077\u0061\u0074\u0063\u0068\u002f\u0075\u0070\u0064\u0061\u0074\u0065\u003f\u0076\u0065\u0072\u0073\u0069\u006f\u006e\u003d\u0031';
  301. headers['Referer'] = '\u0068\u0074\u0074\u0070\u0073\u003a\u002f\u002f\u0069\u0073\u0068\u006f\u0077\u002e\u006a\u0065\u0067\u006f\u0074\u0072\u0069\u0070\u002e\u0063\u006f\u006d\u002e\u0063\u006e\u002f\u0066\u0072\u0065\u0065\u0053\u0074\u0079\u006c\u0065\u0054\u006f\u0075\u0072\u0069\u0073\u006d\u002f\u0064\u0065\u0074\u0061\u0069\u006c';
  302. const body = `{
  303. "userId":"${accountid}",
  304. "userWatchTime":"10.0",
  305. "accountId":"${mobile}"
  306. }`;
  307. const request = {
  308. url: url,
  309. headers: headers,
  310. body: body
  311. };
  312. return new Promise(resolve => {
  313. $.http.post(request)
  314. .then(async (resp) => {
  315. $.log(`\nVideoTask body: \n${resp}`);
  316. data = resp.body;
  317. if (data.includes('update success')) {
  318. await Exchange(headers);
  319. }
  320. })
  321. .catch((err) => {
  322. const error = '视频任务失败⚠️';
  323. $.error(error + '\n' + err);
  324. $.notify($.name, '', `${head+error}请查看日志‼️`);
  325. })
  326. .finally(() => {
  327. resolve();
  328. });
  329. });
  330. }
  331.  
  332.  
  333. function Exchange(headers) {
  334. const url = '\u0068\u0074\u0074\u0070\u0073\u003a\u002f\u002f\u0075\u0064\u0073\u002d\u0069\u002e\u0063\u006d\u0069\u0073\u0068\u006f\u0077\u002e\u0063\u006f\u006d\u003a\u0031\u0034\u0034\u0033\u002f\u0075\u0064\u0073\u002f\u0063\u006c\u006f\u0075\u0064\u002f\u0077\u0061\u0074\u0063\u0068\u002f\u0065\u0078\u0063\u0068\u0061\u006e\u0067\u0065\u003f\u0076\u0065\u0072\u0073\u0069\u006f\u006e\u003d\u0031';
  335. headers['Referer'] = '\u0068\u0074\u0074\u0070\u0073\u003a\u002f\u002f\u0069\u0073\u0068\u006f\u0077\u002e\u006a\u0065\u0067\u006f\u0074\u0072\u0069\u0070\u002e\u0063\u006f\u006d\u002e\u0063\u006e\u002f\u0066\u0072\u0065\u0065\u0053\u0074\u0079\u006c\u0065\u0054\u006f\u0075\u0072\u0069\u0073\u006d\u002f\u0061\u0063\u0074\u0069\u0076\u0069\u0074\u0079';
  336. const body = `{
  337. "userId":"${accountid}",
  338. "exchangeTime":10,
  339. "exchangeNum":10,
  340. "accountId":"${mobile}"
  341. }`;
  342. const request = {
  343. url: url,
  344. headers: headers,
  345. body: body
  346. };
  347. return new Promise(resolve => {
  348. $.http.post(request)
  349. .then((resp) => {
  350. $.log(`\nExchange body: \n${resp}`);
  351. data = resp.body;
  352. if (data.includes('"exchangeNum":10,')) {
  353. info += '视频任务:无忧币 +10🎉\n';
  354. } else {
  355. $.error(`\n${head}\n兑换失败⚠️`);
  356. res = $.toObj(data.replace('.',''));
  357. info += `视频任务:${res.mes}‼️\n`;
  358. }
  359. })
  360. .catch((err) => {
  361. const error = '兑换失败⚠️';
  362. $.error(error + '\n' + err);
  363. $.notify($.name, '', `${head+error}请查看日志‼️`);
  364. })
  365. .finally(() => {
  366. resolve();
  367. });
  368. });
  369. }
  370.  
  371.  
  372. function GetCookie() {
  373. const { headers, url, method } = $request;
  374. const { body } = $response;
  375. if (url.includes('accountid') && url.includes('call_phone')) {
  376. const accountid = url.match(/accountid=(\d+)/)[1];
  377. const mobile = url.match(/call_phone=(\d+)/)[1];
  378. SetCookie('accountid',accountid,'mobile',mobile);
  379. }
  380. if (url.includes('logonFree') && body.includes('uid')) {
  381. const token = url.match(/token=(\w+)/)[1];
  382. const userid = body.match(/uid=(\w+)/)[1];
  383. SetCookie('token',token,'userid',userid);
  384. }
  385. if (info.length > 10) {
  386. $.notify($.name, '', info);
  387. }
  388. if (info.includes('\n')) {
  389. info = `=== 账号${AsVow.length}:${AsVow.pop().mobile} ===\nCookie完整🎉`;
  390. $.notify($.name, '', info);
  391. }
  392. }
  393.  
  394.  
  395. function SetCookie(k1,v1,k2,v2) {
  396. if (typeof AsVow != 'undefined') {
  397. if (!$.toStr(AsVow).includes(`'${k1}':'${v1}','${k2}':'${v2}'`)) {
  398. i = AsVow.length;
  399. if (k1 == 'token'){
  400. for (j in AsVow) {
  401. if (AsVow[j].userid == v2) {
  402. info = `=== 账号 ${AsVow[j].mobile} ===\n`
  403. AsVow[j][k1] = v1;
  404. $.write(AsVow, 'AsVow');
  405. $.read('AsVow') == AsVow ? info = '更新token成功🎉' : info = '更新token失败‼️';
  406. return;
  407. }
  408. }
  409. }
  410. if (Object.keys(AsVow[i-1]).length < 4){
  411. AsVow[i-1][k1] = v1;
  412. AsVow[i-1][k2] = v2;
  413. } else {
  414. AsVow[i] = {[k1]:v1,[k2]:v2};
  415. }
  416. $.write(AsVow, 'AsVow');
  417. $.read('AsVow') == AsVow ? info = `写入 ${k1} & ${k2} 成功🎉` : info = `写入 ${k1} & ${k2} 失败‼️`;
  418. }
  419. } else {
  420. AsVow = [{[k1]:v1,[k2]:v2}];
  421. $.write(AsVow, 'AsVow');
  422. $.read('AsVow') == AsVow ? info = `写入 ${k1} & ${k2} 成功🎉` : info = `写入 ${k1} & ${k2} 失败‼️`;
  423. }
  424. Cookie = $.toStr(AsVow[AsVow.length-1]);
  425. if (Cookie.match('accountid.*mobile') && Cookie.match('token.*userid')) {
  426. info += `\n`;
  427. }
  428. }
  429.  
  430. // 随机 User-Agent
  431. function GetRandomUA() {
  432. const USER_AGENTS=['Mozilla/5.0 (Linux; Android 10; ONEPLUS A5010 Build/QKQ1.191014.012; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36 source/jegotrip','Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 source/jegotrip','Mozilla/5.0 (Linux; Android 9; Mi Note 3 Build/PKQ1.181007.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/045131 Mobile Safari/537.36 source/jegotrip','Mozilla/5.0 (Linux; Android 10; GM1910 Build/QKQ1.190716.003; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36 source/jegotrip','Mozilla/5.0 (Linux; Android 9; 16T Build/PKQ1.190616.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36 source/jegotrip','Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 source/jegotrip','Mozilla/5.0 (iPhone; CPU iPhone OS 13_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 source/jegotrip','Mozilla/5.0 (iPhone; CPU iPhone OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 source/jegotrip','Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 source/jegotrip','Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 source/jegotrip','Mozilla/5.0 (iPhone; CPU iPhone OS 13_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 source/jegotrip','Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 source/jegotrip','Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 source/jegotrip','Mozilla/5.0 (iPhone; CPU iPhone OS 13_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 source/jegotrip','Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 source/jegotrip','Mozilla/5.0 (Linux; Android 9; MI 6 Build/PKQ1.190118.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36 source/jegotrip','Mozilla/5.0 (Linux; Android 11; Redmi K30 5G Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045511 Mobile Safari/537.36 source/jegotrip','Mozilla/5.0 (iPhone; CPU iPhone OS 11_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15F79 source/jegotrip','Mozilla/5.0 (Linux; Android 10; M2006J10C Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36 source/jegotrip','Mozilla/5.0 (Linux; Android 10; M2006J10C Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36 source/jegotrip','Mozilla/5.0 (Linux; Android 10; ONEPLUS A6000 Build/QKQ1.190716.003; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045224 Mobile Safari/537.36 source/jegotrip','Mozilla/5.0 (Linux; Android 9; MHA-AL00 Build/HUAWEIMHA-AL00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36 source/jegotrip','Mozilla/5.0 (Linux; Android 8.1.0; 16 X Build/OPM1.171019.026; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36 source/jegotrip','Mozilla/5.0 (Linux; Android 8.0.0; HTC U-3w Build/OPR6.170623.013; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/044942 Mobile Safari/537.36 source/jegotrip','Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 source/jegotrip','Mozilla/5.0 (Linux; Android 10; LYA-AL00 Build/HUAWEILYA-AL00L; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045230 Mobile Safari/537.36 source/jegotrip','Mozilla/5.0 (iPhone; CPU iPhone OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 source/jegotrip','Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 source/jegotrip','Mozilla/5.0 (iPhone; CPU iPhone OS 14_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 source/jegotrip','Mozilla/5.0 (Linux; Android 8.1.0; MI 8 Build/OPM1.171019.026; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/66.0.3359.126 MQQBrowser/6.2 TBS/045131 Mobile Safari/537.36 source/jegotrip','Mozilla/5.0 (Linux; Android 10; Redmi K20 Pro Premium Edition Build/QKQ1.190825.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045227 Mobile Safari/537.36 source/jegotrip','Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 source/jegotrip','Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 source/jegotrip','Mozilla/5.0 (Linux; Android 11; Redmi K20 Pro Premium Edition Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045513 Mobile Safari/537.36 source/jegotrip','Mozilla/5.0 (Linux; Android 10; MI 8 Build/QKQ1.190828.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045227 Mobile Safari/537.36 source/jegotrip','Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 source/jegotrip'];
  433. const RANDOM_UA = USER_AGENTS[Math.min(Math.floor(Math.random() * USER_AGENTS.length), USER_AGENTS.length)];
  434. return RANDOM_UA;
  435. }
  436.  
  437. // prettier-ignore
  438. /*********************************** API *************************************/
  439. function ENV(){const t='undefined'!=typeof $task,e='undefined'!=typeof $loon;return{isQX:t,isLoon:e,isSurge:'undefined'!=typeof $httpClient&&!e,isNode:'undefined'!=typeof module&&!!module.exports,isRequest:'undefined'!=typeof $request,isScriptable:'undefined'!=typeof importModule}}function HTTP(t={baseURL:''}){const{isQX:e,isLoon:s,isSurge:o,isNode:i,isScriptable:n}=ENV(),r=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/;const h={};return['GET','POST','PUT','DELETE','HEAD','OPTIONS','PATCH'].forEach(c=>h[c.toLowerCase()]=(h=>(function(h,c){c='string'==typeof c?{url:c}:c;const l=t.baseURL;l&&!r.test(c.url||'')&&(c.url=l?l+c.url:c.url),c&&c.body&&c.headers&&!c.headers['Content-Type']&&(c.headers['Content-Type']='application/x-www-form-urlencoded');const a=(c={...t,...c}).timeout,_={...{onRequest:()=>{},onResponse:t=>t,onTimeout:()=>{}},...c.events};let p,u;if(_.onRequest(h,c),e)p=$task.fetch({method:h,...c});else if(s||o||i)p=new Promise((t,e)=>{(i?require('request'):$httpClient)[h.toLowerCase()](c,(s,o,i)=>{s?e(s):t({statusCode:o.status||o.statusCode,headers:o.headers,body:i})})});else if(n){const t=new Request(c.url);t.method=h,t.headers=c.headers,t.body=c.body,p=new Promise((e,s)=>{t.loadString().then(s=>{e({statusCode:t.response.statusCode,headers:t.response.headers,body:s})}).catch(t=>s(t))})}const d=a?new Promise((t,e)=>{u=setTimeout(()=>(_.onTimeout(),e(`${h} URL: ${c.url} exceeds the timeout ${a} ms`)),a)}):null;return(d?Promise.race([d,p]).then(t=>(clearTimeout(u),t)):p).then(t=>_.onResponse(t))})(c,h))),h}function API(t='untitled',e=!1){const{isQX:s,isLoon:o,isSurge:i,isNode:n,isScriptable:r}=ENV();return new class{constructor(t,e){this.name=t,this.debug=e,this.http=HTTP(),this.env=ENV(),n&&(this.isMute=process.env.isMute||this.isMute,this.isMuteLog=process.env.isMuteLog||this.isMuteLog),this.startTime=(new Date).getTime(),console.log(`\ud83d\udd14${t}, \u5f00\u59cb!`),this.node=(()=>{if(n){return{fs:require('fs')}}return null})(),this.initCache();Promise.prototype.delay=function(t){return this.then(function(e){return((t,e)=>new Promise(function(s){setTimeout(s.bind(null,e),t)}))(t,e)})}}initCache(){if(s&&(this.cache=JSON.parse($prefs.valueForKey(this.name)||'{}')),(o||i)&&(this.cache=JSON.parse($persistentStore.read(this.name)||'{}')),n){let t='root.json';this.node.fs.existsSync(t)||this.node.fs.writeFileSync(t,JSON.stringify({}),{flag:'wx'},t=>console.log(t)),this.root={},t=`${this.name}.json`,this.node.fs.existsSync(t)?this.cache=JSON.parse(this.node.fs.readFileSync(`${this.name}.json`)):(this.node.fs.writeFileSync(t,JSON.stringify({}),{flag:'wx'},t=>console.log(t)),this.cache={})}}persistCache(){const t=JSON.stringify(this.cache,null,2);s&&$prefs.setValueForKey(t,this.name),(o||i)&&$persistentStore.write(t,this.name),n&&(this.node.fs.writeFileSync(`${this.name}.json`,t,{flag:'w'},t=>console.log(t)),this.node.fs.writeFileSync('root.json',JSON.stringify(this.root,null,2),{flag:'w'},t=>console.log(t)))}write(t,e){if(this.log(`SET ${e}`),-1!==e.indexOf('#')){if(e=e.substr(1),i||o)return $persistentStore.write(t,e);if(s)return $prefs.setValueForKey(t,e);n&&(this.root[e]=t)}else this.cache[e]=t;this.persistCache()}read(t){return this.log(`READ ${t}`),-1===t.indexOf('#')?this.cache[t]:(t=t.substr(1),i||o?$persistentStore.read(t):s?$prefs.valueForKey(t):n?this.root[t]:void 0)}delete(t){if(this.log(`DELETE ${t}`),-1!==t.indexOf('#')){if(t=t.substr(1),i||o)return $persistentStore.write(null,t);if(s)return $prefs.removeValueForKey(t);n&&delete this.root[t]}else delete this.cache[t];this.persistCache()}notify(t,e='',r='',h={}){const c=h['open-url'],l=h['media-url'];if(r=r.replace(/^(?=\n)$|^\s*|\s*$|\n\n+/gm,''),!this.isMute){if(s&&$notify(t,e,r,h),i&&$notification.post(t,e,r+`${l?'\n\u591a\u5a92\u4f53:'+l:''}`,{url:c}),o){let s={};c&&(s.openUrl=c),l&&(s.mediaUrl=l),'{}'===this.toStr(s)?$notification.post(t,e,r):$notification.post(t,e,r,s)}n&&new Promise(async s=>{const o=(e?`${e}\n`:'')+r+(c?`\n\u70b9\u51fb\u8df3\u8f6c: ${c}`:'')+(l?'\n\u591a\u5a92\u4f53: '+l:'');await this.sendNotify(t,o,{url:c})})}if(!this.isMuteLog){let s=['','==============\ud83d\udce3\u7cfb\u7edf\u901a\u77e5\ud83d\udce3=============='];s.push(t),e&&s.push(e),r&&s.push(r),c&&s.push(`\u70b9\u51fb\u8df3\u8f6c: ${c}`),l&&s.push(`\u591a\u5a92\u4f53: ${l}`),console.log(s.join('\n'))}}sendNotify(t,e,s={}){return new Promise(async o=>{this.querystring=require('querystring'),this.timeout=this.timeout||'15000',e+=this.author||'\n\n\u4ec5\u4f9b\u7528\u4e8e\u5b66\u4e60 https://ooxx.be/js',this.setParam(),await Promise.all([this.serverNotify(t,e),this.pushPlusNotify(t,e)]),t=t.match(/.*?(?=\s?-)/g)?t.match(/.*?(?=\s?-)/g)[0]:t,await Promise.all([this.BarkNotify(t,e,s),this.tgBotNotify(t,e),this.ddBotNotify(t,e),this.qywxBotNotify(t,e),this.qywxamNotify(t,e),this.iGotNotify(t,e,s),this.gobotNotify(t,e)])})}setParam(){this.SCKEY=process.env.SCKEY||this.SCKEY,this.PUSH_PLUS_TOKEN=process.env.PUSH_PLUS_TOKEN||this.PUSH_PLUS_TOKEN,this.PUSH_PLUS_USER=process.env.PUSH_PLUS_USER||this.PUSH_PLUS_USER,this.BARK_PUSH=process.env.BARK_PUSH||this.BARK_PUSH,this.BARK_SOUND=process.env.BARK_SOUND||this.BARK_SOUND,this.BARK_GROUP=process.env.BARK_GROUP||'AsVow',this.BARK_PUSH&&!this.BARK_PUSH.includes('http')&&(this.BARK_PUSH=`https://api.day.app/${this.BARK_PUSH}`),this.TG_BOT_TOKEN=process.env.TG_BOT_TOKEN||this.TG_BOT_TOKEN,this.TG_USER_ID=process.env.TG_USER_ID||this.TG_USER_ID,this.TG_PROXY_AUTH=process.env.TG_PROXY_AUTH||this.TG_PROXY_AUTH,this.TG_PROXY_HOST=process.env.TG_PROXY_HOST||this.TG_PROXY_HOST,this.TG_PROXY_PORT=process.env.TG_PROXY_PORT||this.TG_PROXY_PORT,this.TG_API_HOST=process.env.TG_API_HOST||'api.telegram.org',this.DD_BOT_TOKEN=process.env.DD_BOT_TOKEN||this.DD_BOT_TOKEN,this.DD_BOT_SECRET=process.env.DD_BOT_SECRET||this.DD_BOT_SECRET,this.QYWX_KEY=process.env.QYWX_KEY||this.QYWX_KEY,this.QYWX_AM=process.env.QYWX_AM||this.QYWX_AM,this.IGOT_PUSH_KEY=process.env.IGOT_PUSH_KEY||this.IGOT_PUSH_KEY,this.GOBOT_URL=process.env.GOBOT_URL||this.GOBOT_URL,this.GOBOT_TOKEN=process.env.GOBOT_TOKEN||this.GOBOT_TOKEN,this.GOBOT_QQ=process.env.GOBOT_QQ||this.GOBOT_QQ}serverNotify(t,e,s=2100){return new Promise(o=>{if(this.SCKEY){e=e.replace(/[\n\r]/g,'\n\n');const i={url:this.SCKEY.includes('SCT')?`https://sctapi.ftqq.com/${this.SCKEY}.send`:`https://sc.ftqq.com/${this.SCKEY}.send`,body:`text=${t}&desp=${e}`,headers:{'Content-Type':'application/x-www-form-urlencoded'},timeout:this.timeout};setTimeout(()=>{this.http.post(i).then(t=>{const e=this.toObj(t.body);0===e.errno||0===e.data.errno?console.log('server\u9171\u53d1\u9001\u901a\u77e5\u6d88\u606f\u6210\u529f\ud83c\udf89\n'):1024===e.errno?console.log(`server\u9171\u53d1\u9001\u901a\u77e5\u6d88\u606f\u5f02\u5e38: ${e.errmsg}\n`):console.log(`server\u9171\u53d1\u9001\u901a\u77e5\u6d88\u606f\u5f02\u5e38\n${this.toStr(e)}`)}).catch(t=>{console.log('server\u9171\u53d1\u9001\u901a\u77e5\u8c03\u7528API\u5931\u8d25\uff01\uff01\n'),this.error(t)}).finally(()=>{o()})},s)}else o()})}pushPlusNotify(t,e){return new Promise(s=>{if(this.PUSH_PLUS_TOKEN){e=e.replace(/[\n\r]/g,'<br>');const o={token:`${this.PUSH_PLUS_TOKEN}`,title:`${t}`,content:`${e}`,topic:`${this.PUSH_PLUS_USER}`},i={url:'https://www.pushplus.plus/send',body:this.toStr(o),headers:{'Content-Type':' application/json'},timeout:this.timeout};this.http.post(i).then(t=>{const e=this.toObj(t.body);200===e.code?console.log(`push+\u53d1\u9001${this.PUSH_PLUS_USER?'\u4e00\u5bf9\u591a':'\u4e00\u5bf9\u4e00'}\u901a\u77e5\u6d88\u606f\u5b8c\u6210\u3002\n`):console.log(`push+\u53d1\u9001${this.PUSH_PLUS_USER?'\u4e00\u5bf9\u591a':'\u4e00\u5bf9\u4e00'}\u901a\u77e5\u6d88\u606f\u5931\u8d25\uff1a${e.msg}\n`)}).catch(t=>{console.log(`push+\u53d1\u9001${this.PUSH_PLUS_USER?'\u4e00\u5bf9\u591a':'\u4e00\u5bf9\u4e00'}\u901a\u77e5\u6d88\u606f\u5931\u8d25\uff01\uff01\n`),this.error(t)}).finally(()=>{s()})}else s()})}BarkNotify(t,e,s={}){return new Promise(o=>{if(this.BARK_PUSH){const i={url:`${this.BARK_PUSH}/${encodeURIComponent(t)}/${encodeURIComponent(e)}?sound=${this.BARK_SOUND}&group=${this.BARK_GROUP}&${this.querystring.stringify(s)}`,headers:{'Content-Type':'application/x-www-form-urlencoded'},timeout:this.timeout};this.http.get(i).then(t=>{const e=this.toObj(t.body);200===e.code?console.log('Bark APP\u53d1\u9001\u901a\u77e5\u6d88\u606f\u6210\u529f\ud83c\udf89\n'):console.log(`${e.message}\n`)}).catch(t=>{console.log('Bark APP\u53d1\u9001\u901a\u77e5\u8c03\u7528API\u5931\u8d25\uff01\uff01\n'),this.error(t)}).finally(()=>{o()})}else o()})}tgBotNotify(t,e){return new Promise(s=>{if(this.TG_BOT_TOKEN&&this.TG_USER_ID){const o={url:`https://${this.TG_API_HOST}/bot${this.TG_BOT_TOKEN}/sendMessage`,body:`chat_id=${this.TG_USER_ID}&text=${t}\n\n${e}&disable_web_page_preview=true`,headers:{'Content-Type':'application/x-www-form-urlencoded'},timeout:this.timeout};if(this.TG_PROXY_HOST&&this.TG_PROXY_PORT){const t={host:this.TG_PROXY_HOST,port:1*this.TG_PROXY_PORT,proxyAuth:this.TG_PROXY_AUTH};Object.assign(o,{proxy:t})}this.http.post(o).then(t=>{const e=this.toObj(t.body);e.ok?console.log('Telegram\u53d1\u9001\u901a\u77e5\u6d88\u606f\u6210\u529f\ud83c\udf89\u3002\n'):400===e.error_code?console.log('\u8bf7\u4e3b\u52a8\u7ed9bot\u53d1\u9001\u4e00\u6761\u6d88\u606f\u5e76\u68c0\u67e5\u63a5\u6536\u7528\u6237ID\u662f\u5426\u6b63\u786e\u3002\n'):401===e.error_code&&console.log('Telegram bot token \u586b\u5199\u9519\u8bef\u3002\n')}).catch(t=>{console.log('Telegram\u53d1\u9001\u901a\u77e5\u6d88\u606f\u5931\u8d25\uff01\uff01\n'),this.error(t)}).finally(()=>{s()})}else s()})}ddBotNotify(t,e){return new Promise(s=>{const o={url:`https://oapi.dingtalk.com/robot/send?access_token=${this.DD_BOT_TOKEN}`,json:{msgtype:'text',text:{content:` ${t}\n\n${e}`}},headers:{'Content-Type':'application/json'},timeout:this.timeout};if(this.DD_BOT_TOKEN&&this.DD_BOT_SECRET){const t=require('crypto'),e=Date.now(),i=t.createHmac('sha256',this.DD_BOT_SECRET);i.update(`${e}\n${this.DD_BOT_SECRET}`);const n=encodeURIComponent(i.digest('base64'));o.url=`${o.url}&timestamp=${e}&sign=${n}`,this.http.post(o).then(t=>{const e=this.toObj(t.body);0===e.errcode?console.log('\u9489\u9489\u53d1\u9001\u901a\u77e5\u6d88\u606f\u6210\u529f\ud83c\udf89\u3002\n'):console.log(`${e.errmsg}\n`)}).catch(t=>{console.log('\u9489\u9489\u53d1\u9001\u901a\u77e5\u6d88\u606f\u5931\u8d25\uff01\uff01\n'),this.error(t)}).finally(()=>{s()})}else this.DD_BOT_TOKEN?this.http.post(o).then(t=>{const e=this.toObj(t.body);0===e.errcode?console.log('\u9489\u9489\u53d1\u9001\u901a\u77e5\u6d88\u606f\u5b8c\u6210\u3002\n'):console.log(`${e.errmsg}\n`)}).catch(t=>{console.log('\u9489\u9489\u53d1\u9001\u901a\u77e5\u6d88\u606f\u5931\u8d25\uff01\uff01\n'),this.error(t)}).finally(()=>{s()}):s()})}qywxBotNotify(t,e){return new Promise(s=>{const o={url:`https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=${this.QYWX_KEY}`,json:{msgtype:'text',text:{content:` ${t}\n\n${e}`}},headers:{'Content-Type':'application/json'},timeout:this.timeout};this.QYWX_KEY?this.http.post(o).then(t=>{const e=this.toObj(t.body);0===e.errcode?console.log('\u4f01\u4e1a\u5fae\u4fe1\u53d1\u9001\u901a\u77e5\u6d88\u606f\u6210\u529f\ud83c\udf89\u3002\n'):console.log(`${e.errmsg}\n`)}).catch(t=>{console.log('\u4f01\u4e1a\u5fae\u4fe1\u53d1\u9001\u901a\u77e5\u6d88\u606f\u5931\u8d25\uff01\uff01\n'),this.error(t)}).finally(()=>{s()}):s()})}ChangeUserId(t){if(this.QYWX_AM_AY=this.QYWX_AM.split(','),this.QYWX_AM_AY[2]){const e=this.QYWX_AM_AY[2].split('|');let s='';for(let o=0;o<e.length;o++){const i='\u7b7e\u5230\u53f7 '+(o+1);t.match(i)&&(s=e[o])}return s||(s=this.QYWX_AM_AY[2]),s}return'@all'}qywxamNotify(t,e){return new Promise(s=>{if(this.QYWX_AM){this.QYWX_AM_AY=this.QYWX_AM.split(',');const o={url:'https://qyapi.weixin.qq.com/cgi-bin/gettoken',json:{corpid:`${this.QYWX_AM_AY[0]}`,corpsecret:`${this.QYWX_AM_AY[1]}`},headers:{'Content-Type':'application/json'},timeout:this.timeout};let i;this.http.post(o).then(s=>{const o=e.replace(/\n/g,'<br/>'),n=this.toObj(s.body).access_token;switch(this.QYWX_AM_AY[4]){case'0':i={msgtype:'textcard',textcard:{title:`${t}`,description:`${e}`,url:'https://ooxx.be/js',btntxt:'\u66f4\u591a'}};break;case'1':i={msgtype:'text',text:{content:`${t}\n\n${e}`}};break;default:i={msgtype:'mpnews',mpnews:{articles:[{title:`${t}`,thumb_media_id:`${this.QYWX_AM_AY[4]}`,author:'\u667a\u80fd\u52a9\u624b',content_source_url:'',content:`${o}`,digest:`${e}`}]}}}this.QYWX_AM_AY[4]||(i={msgtype:'text',text:{content:`${t}\n\n${e}`}}),i={url:`https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=${n}`,json:{touser:`${this.ChangeUserId(e)}`,agentid:`${this.QYWX_AM_AY[3]}`,safe:'0',...i},headers:{'Content-Type':'application/json'}}}),this.http.post(i).then(t=>{const s=this.toObj(s);0===s.errcode?console.log('\u6210\u5458ID:'+this.ChangeUserId(e)+'\u4f01\u4e1a\u5fae\u4fe1\u5e94\u7528\u6d88\u606f\u53d1\u9001\u901a\u77e5\u6d88\u606f\u6210\u529f\ud83c\udf89\u3002\n'):console.log(`${s.errmsg}\n`)}).catch(t=>{console.log('\u6210\u5458ID:'+this.ChangeUserId(e)+'\u4f01\u4e1a\u5fae\u4fe1\u5e94\u7528\u6d88\u606f\u53d1\u9001\u901a\u77e5\u6d88\u606f\u5931\u8d25\uff01\uff01\n'),this.error(t)}).finally(()=>{s()})}else s()})}iGotNotify(t,e,s={}){return new Promise(o=>{if(this.IGOT_PUSH_KEY){if(this.IGOT_PUSH_KEY_REGX=new RegExp('^[a-zA-Z0-9]{24}$'),!this.IGOT_PUSH_KEY_REGX.test(this.IGOT_PUSH_KEY))return console.log('\u60a8\u6240\u63d0\u4f9b\u7684IGOT_PUSH_KEY\u65e0\u6548\n'),void o();const i={url:`https://push.hellyw.com/${this.IGOT_PUSH_KEY.toLowerCase()}`,body:`title=${t}&content=${e}&${this.querystring.stringify(s)}`,headers:{'Content-Type':'application/x-www-form-urlencoded'},timeout:this.timeout};this.http.post(i).then(t=>{const e=this.toObj(t.body);0===e.ret?console.log('iGot\u53d1\u9001\u901a\u77e5\u6d88\u606f\u6210\u529f\ud83c\udf89\n'):console.log(`iGot\u53d1\u9001\u901a\u77e5\u6d88\u606f\u5931\u8d25\uff1a${e.errMsg}\n`)}).catch(t=>{console.log('iGot\u53d1\u9001\u901a\u77e5\u8c03\u7528API\u5931\u8d25\uff01\uff01\n'),this.error(t)}).finally(()=>{o()})}else o()})}gobotNotify(t,e,s=2100){return new Promise(o=>{if(this.GOBOT_URL){const i={url:`${this.GOBOT_URL}?access_token=${this.GOBOT_TOKEN}&${this.GOBOT_QQ}`,body:`message=${t}\n${e}`,headers:{'Content-Type':'application/x-www-form-urlencoded'},timeout:this.timeout};setTimeout(()=>{this.http.post(i).then(t=>{const e=this.toObj(t.body);0===e.retcode?console.log('go-cqhttp\u53d1\u9001\u901a\u77e5\u6d88\u606f\u6210\u529f\ud83c\udf89\n'):100===e.retcode?console.log(`go-cqhttp\u53d1\u9001\u901a\u77e5\u6d88\u606f\u5f02\u5e38: ${e.errmsg}\n`):console.log(`go-cqhttp\u53d1\u9001\u901a\u77e5\u6d88\u606f\u5f02\u5e38\n${this.toStr(e)}`)}).catch(t=>{console.log('\u53d1\u9001go-cqhttp\u901a\u77e5\u8c03\u7528API\u5931\u8d25\uff01\uff01\n'),this.error(t)}).finally(()=>{o()})},s)}else o()})}log(t){this.debug&&console.log(`[${this.name}] LOG:\n${this.toStr(t)}`)}info(t){console.log(`[${this.name}] INFO:\n${this.toStr(t)}`)}error(t){console.log(`[${this.name}] ERROR:\n${this.toStr(t)}`)}wait(t){return new Promise(e=>setTimeout(e,t))}done(t={}){const e=((new Date).getTime()-this.startTime)/1e3;console.log(`\ud83d\udd14${this.name}, \u7ed3\u675f! \ud83d\udd5b ${e} \u79d2`),s||o||i?$done(t):n&&'undefined'!=typeof $context&&($context.headers=t.headers,$context.statusCode=t.statusCode,$context.body=t.body)}toObj(t){if('object'==typeof t||t instanceof Object)return t;try{return JSON.parse(t)}catch(e){return t}}toStr(t){if('string'==typeof t||t instanceof String)return t;try{return JSON.stringify(t)}catch(e){return t}}}(t,e)}
  440. /*****************************************************************************/
Add Comment
Please, Sign In to add comment