(title: str, content: str, ignore_default_config: bool = False, **kwargs)
| 1069 | |
| 1070 | |
| 1071 | def send(title: str, content: str, ignore_default_config: bool = False, **kwargs): |
| 1072 | if kwargs: |
| 1073 | global push_config |
| 1074 | if ignore_default_config: |
| 1075 | push_config = kwargs # 清空从环境变量获取的配置 |
| 1076 | else: |
| 1077 | push_config.update(kwargs) |
| 1078 | |
| 1079 | if not content: |
| 1080 | print(f"{title} 推送内容为空!") |
| 1081 | return |
| 1082 | |
| 1083 | # 根据标题跳过一些消息推送,环境变量:SKIP_PUSH_TITLE 用回车分隔 |
| 1084 | skipTitle = os.getenv("SKIP_PUSH_TITLE") |
| 1085 | if skipTitle: |
| 1086 | if title in re.split("\n", skipTitle): |
| 1087 | print(f"{title} 在SKIP_PUSH_TITLE环境变量内,跳过推送!") |
| 1088 | return |
| 1089 | |
| 1090 | hitokoto = push_config.get("HITOKOTO") |
| 1091 | content += "\n\n" + one() if hitokoto != "false" else "" |
| 1092 | |
| 1093 | notify_function = add_notify_function() |
| 1094 | ts = [ |
| 1095 | threading.Thread(target=mode, args=(title, content), name=mode.__name__) |
| 1096 | for mode in notify_function |
| 1097 | ] |
| 1098 | [t.start() for t in ts] |
| 1099 | [t.join() for t in ts] |
| 1100 | |
| 1101 | |
| 1102 | def main(): |
no test coverage detected