Post a message to Lark. When title is None, message must be a str. otherwise msg can be in rich text format (see https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/im-v1/message/create_json#45e0953e for details).
(self,
content: Union[str, List[List[Dict]]],
title: Optional[str] = None)
| 11 | self.url = url |
| 12 | |
| 13 | def post(self, |
| 14 | content: Union[str, List[List[Dict]]], |
| 15 | title: Optional[str] = None): |
| 16 | """Post a message to Lark. |
| 17 | |
| 18 | When title is None, message must be a str. otherwise msg can be in rich |
| 19 | text format (see |
| 20 | https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/im-v1/message/create_json#45e0953e |
| 21 | for details). |
| 22 | """ |
| 23 | if title is None: |
| 24 | assert isinstance(content, str) |
| 25 | msg = {'msg_type': 'text', 'content': {'text': content}} |
| 26 | else: |
| 27 | if isinstance(content, str): |
| 28 | content = [[{'tag': 'text', 'text': content}]] |
| 29 | msg = { |
| 30 | 'msg_type': 'post', |
| 31 | 'content': { |
| 32 | 'post': { |
| 33 | 'zh_cn': { |
| 34 | 'title': title, |
| 35 | 'content': content |
| 36 | } |
| 37 | } |
| 38 | } |
| 39 | } |
| 40 | requests.post(self.url, data=json.dumps(msg)) |
| 41 | |
| 42 | |
| 43 | def parse_args(): |
no outgoing calls
no test coverage detected