feat: 增加日历与版本化日报
This commit is contained in:
@ -11,6 +11,7 @@ from larkx.auth import LarkAuth
|
||||
|
||||
from snooper_client import SnifferLarkClient as LarkClient
|
||||
from snooper_storage import SnifferStorage as Storage
|
||||
from snooper_version import get_version
|
||||
|
||||
|
||||
def _print_json(value):
|
||||
@ -195,12 +196,14 @@ def cmd_summarize(args):
|
||||
default_dry_run_path,
|
||||
default_summary_path,
|
||||
escape_obsidian_tags,
|
||||
format_followup_checkboxes,
|
||||
load_config,
|
||||
load_previous_summary,
|
||||
resolve_chat_rules,
|
||||
resolve_day,
|
||||
resolve_people_aliases,
|
||||
serialize_message,
|
||||
shorten_headings,
|
||||
summarize_messages,
|
||||
write_summary,
|
||||
)
|
||||
@ -295,6 +298,20 @@ def cmd_summarize(args):
|
||||
previous_summary, previous_day_missing = load_previous_summary(
|
||||
config["output"], target_day
|
||||
)
|
||||
calendar_events = []
|
||||
calendar_error = None
|
||||
if not getattr(args, "no_calendar", False):
|
||||
from snooper_calendar import CalendarError, fetch_calendar_events
|
||||
|
||||
try:
|
||||
calendar_events = fetch_calendar_events(
|
||||
LarkClient(LarkAuth()), target_day, tz
|
||||
)
|
||||
except CalendarError as error:
|
||||
calendar_error = str(error)
|
||||
print(
|
||||
f"日历获取失败({error}),继续生成日报", file=sys.stderr
|
||||
)
|
||||
contacts = None
|
||||
sender_types = {}
|
||||
if rows and not args.no_contacts:
|
||||
@ -317,14 +334,21 @@ def cmd_summarize(args):
|
||||
people_aliases=people_aliases,
|
||||
sender_types=sender_types,
|
||||
previous_summary=previous_summary,
|
||||
calendar_events=calendar_events,
|
||||
calendar_error=calendar_error,
|
||||
)
|
||||
output_path = (
|
||||
args.output
|
||||
or configured_output_path(output_config, "summary", target_day)
|
||||
or default_summary_path(target_day)
|
||||
)
|
||||
content = format_followup_checkboxes(shorten_headings(content))
|
||||
content = escape_obsidian_tags(content)
|
||||
properties = {"model": model.rsplit("/", 1)[-1], "is_read": False}
|
||||
properties = {
|
||||
"version": get_version(),
|
||||
"model": model.rsplit("/", 1)[-1],
|
||||
"is_read": False,
|
||||
}
|
||||
if previous_day_missing:
|
||||
properties["tags"] = ["no_previous_day_log"]
|
||||
content = add_obsidian_properties(content, properties)
|
||||
@ -390,6 +414,7 @@ def main():
|
||||
summarize.add_argument("--timeout", type=int, default=180, help="单次 Magpie 请求超时秒数")
|
||||
summarize.add_argument("--max-chars", type=int, default=80000, help="每个对话内每块消息最大字符数")
|
||||
summarize.add_argument("--no-contacts", action="store_true", help="不联网获取相关会话通讯录")
|
||||
summarize.add_argument("--no-calendar", action="store_true", help="不获取主日历日程")
|
||||
summarize.add_argument("--no-fetch", action="store_true", help="只读取本地已入库记录")
|
||||
summarize.add_argument("--force-fetch", action="store_true", help="即使本地已有数据也强制重新拉取")
|
||||
summarize.add_argument("--config", help="YAML 配置路径;默认读取当前目录 config.yaml")
|
||||
|
||||
Reference in New Issue
Block a user