Exemple #1
0
 def send_movie(self, path, users=[], parties=[], tags=[]):
     sucai = SuCai()
     self.json_data = requests.post(self.send_url,
                                    params={
                                        "access_token":
                                        WeWork.get_message_token()
                                    },
                                    json={
                                        "touser": "******".join(users),
                                        "toparty": "|".join(parties),
                                        "totag": "|".join(tags),
                                        "msgtype": "video",
                                        "agentid": WeWork.agent_id,
                                        "video": {
                                            "media_id":
                                            sucai.get_media_id(
                                                path, "video"),
                                            "title":
                                            "Title",
                                            "description":
                                            "Description"
                                        },
                                        "safe": 0
                                    }).json()
     self.verbose()
     return self.json_data
Exemple #2
0
 def send_file_card(self, dec, title, users=[], parties=[], tags=[]):
     self.json_data = requests.post(
         self.send_url,
         params={
             "access_token": WeWork.get_message_token()
         },
         json={
             "touser": "******".join(users),
             "toparty": "|".join(parties),
             "totag": "|".join(tags),
             "msgtype": "news",
             "agentid": WeWork.agent_id,
             "news": {
                 "articles": [{
                     "title":
                     title,
                     "description":
                     dec,
                     "url":
                     "URL",
                     "picurl":
                     "http://res.mail.qq.com/node/ww/wwopenmng/images/independent/doc/test_pic_msg1.png"
                 }]
             },
             "enable_id_trans": 0
         }).json()
     self.verbose()
     return self.json_data
Exemple #3
0
 def delete(self, id=None):
     self.json_data = requests.get(self.delete_url,
                                   params={
                                       "access_token": WeWork.get_token(),
                                       "id": id
                                   }).json()
     self.verbose(self.json_data)
     return self.json_data
Exemple #4
0
 def list(self, id):
     self.json_data = requests.get(self.list_url,
                                   params={
                                       "access_token": WeWork.get_token(),
                                       "id": id
                                   }).json()
     self.verbose(self.json_data)
     return self.json_data
Exemple #5
0
 def get_media_id(self, file_path, type):
     files = {'file': open(file_path, 'rb')}
     r = requests.post(self.media_id_url,
                       files=files,
                       params={
                           "access_token": WeWork.get_message_token(),
                           "type": type
                       }).json()
     self.verbose(r)
     return r["media_id"]
Exemple #6
0
 def update(self, id, name, parentid, order):
     self.json_data = requests.post(self.update_url,
                                    headers=self.headers,
                                    params={
                                        "access_token": WeWork.get_token()
                                    },
                                    json={
                                        "id": id,
                                        "name": name,
                                        "parentid": parentid,
                                        "order": order
                                    }).json()
     self.verbose(self.json_data)
     return self.json_data
Exemple #7
0
 def send_text(self, msg=None, users=[], parties=[], tags=[]):
     self.json_data = requests.post(self.send_url,
                                    params={
                                        "access_token":
                                        WeWork.get_message_token()
                                    },
                                    json={
                                        "touser": "******".join(users),
                                        "toparty": "|".join(parties),
                                        "totag": "|".join(tags),
                                        "msgtype": "text",
                                        "agentid": WeWork.agent_id,
                                        "text": {
                                            "content": msg
                                        },
                                        "safe": 0,
                                        "enable_id_trans": 0
                                    }).json()
     self.verbose()
     return self.json_data
Exemple #8
0
 def send_voice(self, path, users=[], parties=[], tags=[]):
     sucai = SuCai()
     self.json_data = requests.post(self.send_url,
                                    params={
                                        "access_token":
                                        WeWork.get_message_token()
                                    },
                                    json={
                                        "touser": "******".join(users),
                                        "toparty": "|".join(parties),
                                        "totag": "|".join(tags),
                                        "msgtype": "voice",
                                        "agentid": WeWork.agent_id,
                                        "voice": {
                                            "media_id":
                                            sucai.get_media_id(
                                                path, "voice")
                                        }
                                    }).json()
     self.verbose()
     return self.json_data
     pass
Exemple #9
0
 def send_task_card(self, task_id, users=[], parties=[], tags=[]):
     self.json_data = requests.post(self.send_url,
                                    params={
                                        "access_token":
                                        WeWork.get_message_token()
                                    },
                                    json={
                                        "touser": "******".join(users),
                                        "toparty": "|".join(parties),
                                        "totag": "|".join(tags),
                                        "msgtype": "taskcard",
                                        "agentid": WeWork.agent_id,
                                        "taskcard": {
                                            "title":
                                            "赵明登的礼物申请",
                                            "description":
                                            "礼品:A31茶具套装<br>用途:赠与小黑科技张总经理",
                                            "url":
                                            "https:www.baidu.com",
                                            "task_id":
                                            task_id,
                                            "btn": [{
                                                "key": "key111",
                                                "name": "批准",
                                                "replace_name": "已批准",
                                                "color": "red",
                                                "is_bold": True
                                            }, {
                                                "key": "key222",
                                                "name": "驳回",
                                                "replace_name": "已驳回"
                                            }]
                                        },
                                        "enable_id_trans": 0
                                    }).json()
     self.verbose()
     return self.json_data
Exemple #10
0
 def test_get_token(self):
     wework = WeWork()
     token = wework.get_token()
     assert token != None
Exemple #11
0
 def creat(self, name, parentid, order):
     self.json_data=requests.post(self.creat_url,headers=self.headers,params={"access_token":WeWork.get_token()},json={
         "name": name,
         "parentid": parentid,
         "order": order,
         "id": None
     }
     # ,
     # # proxies=self.proxies,verify=False
                       )\
         .json()
     self.verbose(self.json_data)
     return self.json_data
Exemple #12
0
 def get_department_persons(self, user_id):
     print(WeWork.get_message_token())
     get_url = "https://qyapi.weixin.qq.com/cgi-bin/user/get"
     return self.send_data("get", get_url, WeWork.get_message_token(),
                           {"userid": user_id})