Procházet zdrojové kódy

增加异常通知

flyzto před 3 měsíci
rodič
revize
53cbdd7b40
2 změnil soubory, kde provedl 25 přidání a 0 odebrání
  1. 18 0
      server/models/GamesPs.js
  2. 7 0
      server/routes/pstery.js

+ 18 - 0
server/models/GamesPs.js

@@ -834,6 +834,23 @@ const getSetting = async () => {
   return Setting.get();
 }
 
+/**
+ * 异常通知
+ */
+const notifyException = (message) => {
+  if (IS_DEV) {
+    return Logs.out('notifyException', { message });
+  }
+  const chat_id = -4800633221;
+  axios.get('https://api.qboss.vip/api/telegram/jump', { params: { chat_id, message } })
+  .then(res => {
+    Logs.out('notifyException', res.data);
+  })
+  .catch(err => {
+    Logs.out('notifyException', err.message);
+  });
+}
+
 /**
  * 从子进程获取数据
  */
@@ -935,4 +952,5 @@ module.exports = {
   getSolutions,
   getTotalProfitWithSid,
   getTotalProfitWithBetInfo,
+  notifyException,
 }

+ 7 - 0
server/routes/pstery.js

@@ -101,4 +101,11 @@ router.post('/calc_custom_total_profit', (req, res) => {
   });
 });
 
+// 异常通知
+router.post('/notify_exception', (req, res) => {
+  const { message } = req.body;
+  Games.notifyException(message);
+  res.sendSuccess();
+});
+
 module.exports = router;