dagster-dingtalk 0.1.16b2__py3-none-any.whl → 0.1.18__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,9 @@
1
1
  # noinspection PyProtectedMember
2
- from dagster._core.libraries import DagsterLibraryRegistry
3
- from dagster_dingtalk.version import __version__
2
+ # from dagster._core.libraries import DagsterLibraryRegistry
3
+ # from dagster_dingtalk.version import __version__
4
4
 
5
5
  from dagster_dingtalk.resources import DingTalkAppResource, DingTalkWebhookResource
6
6
  from dagster_dingtalk.app_client import DingTalkClient as DingTalkAppClient
7
7
  import dagster_dingtalk.operations as dingtalk_op
8
8
 
9
- DagsterLibraryRegistry.register("dagster-dingtalk", __version__)
9
+ # DagsterLibraryRegistry.register("dagster-dingtalk", __version__)
@@ -4,7 +4,8 @@ import time
4
4
  from datetime import datetime
5
5
  from enum import Enum
6
6
  from pathlib import Path
7
- from typing import List, Literal, Dict, Tuple
7
+ from typing import List, Literal
8
+ import platform
8
9
 
9
10
  import httpx
10
11
  from httpx import Client
@@ -30,9 +31,10 @@ class DingTalkClient:
30
31
  self.文档文件 = 文档文件_API(self)
31
32
  self.互动卡片 = 互动卡片_API(self)
32
33
  self.OA审批 = OA审批_API(self)
34
+ self.即时通信 = 即时通信_API(self)
33
35
 
34
36
  def __get_access_token(self) -> str:
35
- access_token_cache = Path("/tmp/.dingtalk_cache")
37
+ access_token_cache = Path.home() / ".dingtalk_cache"
36
38
  all_access_token: dict = {}
37
39
  access_token: str|None = None
38
40
  expire_in: int = 0
@@ -576,3 +578,40 @@ class OA审批_审批钉盘_API:
576
578
  "agentId" : self.__client.agent_id
577
579
  })
578
580
  return response.json()
581
+
582
+ # noinspection NonAsciiCharacters
583
+ class 即时通信_API:
584
+ def __init__(self, _client:DingTalkClient):
585
+ self.__client:DingTalkClient = _client
586
+ self.工作通知 = 即时通信_工作通知_API(_client)
587
+
588
+ # noinspection NonAsciiCharacters
589
+ class 即时通信_工作通知_API:
590
+ def __init__(self, _client:DingTalkClient):
591
+ self.__client:DingTalkClient = _client
592
+
593
+ def 发送工作通知(self, msg:dict, to_all_user:bool=True, user_list:List[str]|None=None, dept_id_list:List[str]|None=None) -> dict:
594
+ """
595
+ 工作通知消息是以某个应用的名义推送到员工的工作通知消息,例如生日祝福、入职提醒等。可以发送文本、语音、链接等。
596
+
597
+ 注意:
598
+ 1. 企业内部应用发送消息单次最多只能给5000人发送。
599
+ 2. 企业内部应用每天给每个员工最多可发送500条消息通知。
600
+ 3. 该接口是异步发送消息,接口返回成功并不表示用户一定会收到消息,需要通过获取工作通知消息的发送结果接口查询是否给用户发送成功。
601
+
602
+ :param msg: 消息数据格式参考 https://open.dingtalk.com/document/orgapp/message-types-and-data-format?spm=ding_open_doc.document.0.0.74742580198aRf
603
+ :param to_all_user: 是否发送给企业全部用户。如果为否,则必须传入 user_list 或 dept_id_list
604
+ :param user_list: 接收者的 userid 列表,最大用户列表长度 100。
605
+ :param dept_id_list: 接收者的部门 id 列表,最大列表长度 20 。接收者是部门 ID 时,包括子部门下的所有用户。
606
+ :return:
607
+ """
608
+ response = self.__client.oapi.post(
609
+ url="/topapi/message/corpconversation/asyncsend_v2",
610
+ json={
611
+ "agent_id" : self.__client.agent_id,
612
+ "to_all_user": to_all_user,
613
+ "userid_list" : ','.join(user_list) if user_list else None,
614
+ "dept_id_list" : ','.join(dept_id_list) if dept_id_list else None,
615
+ "msg": msg
616
+ })
617
+ return response.json()
@@ -9,7 +9,7 @@ from .resources import DingTalkWebhookResource
9
9
  "text": In(str),
10
10
  "at": In(default_value=None, description="@列表,传List[str]解析为userId,传List[int]解析为phone,传ALL解析为全部。")
11
11
  })
12
- def op_send_simple_text(context: OpExecutionContext, text, at):
12
+ def op_send_text(context: OpExecutionContext, text, at):
13
13
  webhook:DingTalkWebhookResource = context.resources.dingtalk_webhook
14
14
  if isinstance(at, str) and at == 'ALL':
15
15
  webhook.send_text(text=text, at_all=True)
@@ -25,9 +25,9 @@ def op_send_simple_text(context: OpExecutionContext, text, at):
25
25
  @op(description="钉钉Webhook发送Markdown消息",
26
26
  required_resource_keys={'dingtalk_webhook'},
27
27
  ins={
28
- "text": In(str),
29
- "title": In(str, default_value=''),
30
- "at": In(default_value=None, description="@列表,传List[str]解析为userId,传List[int]解析为phone,传ALL解析为全部。")
28
+ "text": In(str, description="Markdown 内容"),
29
+ "title": In(str, default_value='', description="标题"),
30
+ "at": In(default_value=None, description="List[str] @userIds ,传 List[int] @mobiles ,传 \"ALL\" @所有人。")
31
31
  })
32
32
  def op_send_markdown(context: OpExecutionContext, text, title, at):
33
33
  webhook:DingTalkWebhookResource = context.resources.dingtalk_webhook
@@ -1 +1 @@
1
- __version__ = "0.1.16b2"
1
+ # __version__ = "0.1.17"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dagster-dingtalk
3
- Version: 0.1.16b2
3
+ Version: 0.1.18
4
4
  Summary: A dagster plugin for the DingTalk
5
5
  Author: YiZixuan
6
6
  Author-email: sqkkyzx@qq.com
@@ -10,8 +10,8 @@ Classifier: Programming Language :: Python :: 3.10
10
10
  Classifier: Programming Language :: Python :: 3.11
11
11
  Classifier: Programming Language :: Python :: 3.12
12
12
  Requires-Dist: dagster (>=1.8.10)
13
- Requires-Dist: httpx (>=0.27.2,<0.28.0)
14
- Requires-Dist: pydantic (>=2.9.2,<3.0.0)
13
+ Requires-Dist: httpx (>=0.27)
14
+ Requires-Dist: pydantic (>=2,<2.10)
15
15
  Description-Content-Type: text/markdown
16
16
 
17
17
  # 钉钉与 Dagster 集成
@@ -22,7 +22,7 @@ Description-Content-Type: text/markdown
22
22
  要安装库,请在现有的Dagster环境中使用pip。
23
23
 
24
24
  ```bash
25
- pip install dagster-dingtalk
25
+ pip install dagster-dingtalk -U
26
26
  ```
27
27
 
28
28
  ## 资源
@@ -0,0 +1,8 @@
1
+ dagster_dingtalk/__init__.py,sha256=jAyn67nRx5wU0YYWDMRINn7Tt3joP5IXsztTtyMbxsE,424
2
+ dagster_dingtalk/app_client.py,sha256=i9az_Dfchx10uYC1jtDqCKihp4bA5nwIcKWFsqV9t-M,26018
3
+ dagster_dingtalk/operations.py,sha256=C1wwXCW7mpKhLC1-Y7TCP_72L9e93a9ceVHRWhNda-Q,3891
4
+ dagster_dingtalk/resources.py,sha256=1u8-oXRa7H_e0CAYkTJDxbjEmt3ZcD_ntBNvrS_rwr8,17430
5
+ dagster_dingtalk/version.py,sha256=ncWWGHPke5qy2-s8w3nAgDE4R__CZi-Q7CLWtmtkbvA,25
6
+ dagster_dingtalk-0.1.18.dist-info/METADATA,sha256=2fVDoNc3oHMNEaY8_anWUHWNPmdgiDchgyQY41-F7mg,7999
7
+ dagster_dingtalk-0.1.18.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
8
+ dagster_dingtalk-0.1.18.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- dagster_dingtalk/__init__.py,sha256=CqR5mJA2IrgCFi90KhgTvVLucIn5p978cF7VhXj84u4,418
2
- dagster_dingtalk/app_client.py,sha256=VNCZhZZ3IntleW5zcUeevtnvtfTnaaRDh3nMJow4btg,23814
3
- dagster_dingtalk/operations.py,sha256=28nDXEB1bpnRLYasuv2dLaRW_k0n5r2UEjykhkRBXYI,3859
4
- dagster_dingtalk/resources.py,sha256=1u8-oXRa7H_e0CAYkTJDxbjEmt3ZcD_ntBNvrS_rwr8,17430
5
- dagster_dingtalk/version.py,sha256=4xKtTw0Yr_cv2ZJN025Xggn9Ckk2-YM2c4KlsTThb1M,25
6
- dagster_dingtalk-0.1.16b2.dist-info/METADATA,sha256=XvQhF_y-DQD4XOrzeBypw7JJFOI3YiV1ETbuse97Tfw,8013
7
- dagster_dingtalk-0.1.16b2.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
8
- dagster_dingtalk-0.1.16b2.dist-info/RECORD,,