ck 4 years ago
parent
commit
0f219b5dfc
2 changed files with 13 additions and 36 deletions
  1. 4 2
      handlers/GitHookHandler.py
  2. 9 34
      model/DingTalkUtils.py

+ 4 - 2
handlers/GitHookHandler.py

@@ -1,10 +1,12 @@
 from handlers.HandlerBase import BaseHandler
 from handlers.HandlerBase import BaseHandler
 import os
 import os
+from model import DingTalkUtils
 
 
 
 
 class DataCenerHook(BaseHandler):
 class DataCenerHook(BaseHandler):
 
 
     def get(self):
     def get(self):
         os.system('cd /home/qc/DataCenter')
         os.system('cd /home/qc/DataCenter')
-        os.system('git pull')
-        self.write('ok')
+        val= os.popen('git pull')
+        self.write('ok')
+        DingTalkUtils.send('DataCenter代码更新:\n '+val.read())

+ 9 - 34
model/DingTalkUtils.py

@@ -1,48 +1,23 @@
-"""
-@desc 钉钉报警
-@auth ck
-手机号是str,用","分隔,如果不填,默认@所有人
-"""
+
 import requests
 import requests
 import random
 import random
 
 
-url = "https://oapi.dingtalk.com/robot/send?access_token=ba21cd5591c44593ca7cac05902835e33298c7bf566a5381dc3f01e41c8d5c30"
+url = "https://oapi.dingtalk.com/robot/send?access_token=8c4c99b4b2ca152fb0a5f21b368fae743a64b4ccecac01548a8620fe7f63a0ca"
 headers = {'Content-Type': 'application/json;charset=utf-8'}
 headers = {'Content-Type': 'application/json;charset=utf-8'}
-members = ["13726204048", "18860455786"]
-
-class DingTalkUtils:
-    """
-    @phone Str
-
-            不填:默认@所有人
-            可多个,按英文逗号隔开
-            可填 【ramdom】 随机发送
-    """
-    def send(msg, phone=""):
-        if phone == "":
-            isAtall = True
-            atMobiles = []
-
-        elif phone == "random":
-            isAtall = False
-            atMobiles = []
-            atMobiles.append(random.choice(members))
 
 
-        else:
-            isAtall = False
-            atMobiles =phone.split(",")
 
 
-        data = {'msgtype': 'text',
-                    "at": {"isAtAll": isAtall,
-                           "atMobiles": atMobiles},
-                    "text": {"content": msg+"\n[趣程]"}}
+def send(msg):
+    data = {'msgtype': 'text',
+                "at": {"isAtAll": True,
+                       "atMobiles": []},
+                "text": {"content": "[代码发布]"+msg}}
 
 
-        requests.post(url=url, headers=headers, json=data)
+    requests.post(url=url, headers=headers, json=data)
 
 
 
 
 
 
 if __name__ == '__main__':
 if __name__ == '__main__':
-    DingTalkUtils.send("该下班了","13726204048,11")
+    send("双击打开撒就发了")
     # 发送的内容得加上趣程
     # 发送的内容得加上趣程