API Reference

Core Components

BirthdayChecker

class src.core.checker.BirthdayChecker[source]

Bases: object

check_birthdays(recipients: List[Recipient]) List[Tuple[Recipient, bool, Dict]][source]

检查所有人的生日

Parameters:

recipients – 收件人列表

Returns:

返回收件人、是否生日和额外信息的元组列表

Return type:

List[Tuple[Recipient, bool, Dict]]

ConfigManager

class src.core.config_manager.ConfigManager(config_path: str | None = None)[source]

Bases: object

配置管理器 - 只做必要的配置管理

__init__(config_path: str | None = None)[source]
property config: Config

获取配置,如果未加载则自动加载

load_config() Config[source]

加载配置文件

get_templates_dir() str[source]

获取模板目录路径

validate_config() bool[source]

验证配置的有效性

NotificationFactory

class src.core.notification_factory.NotificationFactory(templates_dir: str)[source]

Bases: object

通知发送器工厂 - 只做必要的对象创建

__init__(templates_dir: str)[source]
create_senders(config: Config) List[NotificationBase][source]

根据配置创建通知发送器列表

Configuration Classes

SMTPConfig

class src.core.config.SMTPConfig(host: str, port: int, username: str, password: str, use_tls: bool = True, default_receive_email: str | None = None, default_template_file: str = 'birthday.html', default_reminder_days: int = 0)[source]

Bases: object

SMTP服务器配置

host: str
port: int
username: str
password: str
use_tls: bool = True
default_receive_email: str | None = None
default_template_file: str = 'birthday.html'
default_reminder_days: int = 0
__init__(host: str, port: int, username: str, password: str, use_tls: bool = True, default_receive_email: str | None = None, default_template_file: str = 'birthday.html', default_reminder_days: int = 0) None

ServerChanConfig

class src.core.config.ServerChanConfig(default_sckey: str | None = None, default_reminder_days: int = 0)[source]

Bases: object

default_sckey: str | None = None
default_reminder_days: int = 0
__init__(default_sckey: str | None = None, default_reminder_days: int = 0) None

Recipient

class src.core.config.Recipient(name: str, email: str | None = None, solar_birthday: str | None = None, lunar_birthday: str | None = None, reminder_days: int | None = None, template_file: str | None = None)[source]

Bases: object

收件人信息

name: str
email: str | None = None
solar_birthday: str | None = None
lunar_birthday: str | None = None
reminder_days: int | None = None
template_file: str | None = None
__post_init__()[source]

验证至少有一个生日日期

__init__(name: str, email: str | None = None, solar_birthday: str | None = None, lunar_birthday: str | None = None, reminder_days: int | None = None, template_file: str | None = None) None

Config

class src.core.config.Config(smtp_config: SMTPConfig | None, serverchan_config: ServerChanConfig | None, recipients: List[Recipient], notification_types: List[str])[source]

Bases: object

应用配置

smtp_config: SMTPConfig | None
serverchan_config: ServerChanConfig | None
recipients: List[Recipient]
notification_types: List[str]
classmethod from_yaml(config_path: str) Config[source]

从YAML文件加载配置

__init__(smtp_config: SMTPConfig | None, serverchan_config: ServerChanConfig | None, recipients: List[Recipient], notification_types: List[str]) None

Notification Senders

EmailSender

class src.notification.sender_email.EmailSender(smtp_config: SMTPConfig, templates_dir: str)[source]

Bases: NotificationBase

__init__(smtp_config: SMTPConfig, templates_dir: str)[source]
render_content(name: str, template_file: str, extra_info: Dict) str[source]
async send(recipient: Recipient, content: str, days_until: int, age: int)[source]
static preview_email(template: str = 'templates/birthday.html', web_open: bool = True)[source]

只渲染birthday.html模板并直接预览,无自定义外壳

ServerChanSender

class src.notification.sender_serverchan.ServerChanSender(sckey: str)[source]

Bases: NotificationBase

__init__(sckey: str)[source]
render_content(name: str, template_file: str, extra_info: Dict) str[source]
async send(recipient: Recipient, content: str, days_until: int, age: int)[source]

Main Application

BirthdayReminder

class src.main.BirthdayReminder(config_path: str = None)[source]

Bases: object

__init__(config_path: str = None)[source]
async send_birthday_reminder(recipient: Recipient, extra_info: Dict) None[source]

发送生日提醒

check_birthdays() List[Tuple[Recipient, bool, Dict]][source]

检查所有人的生日

async run() None[source]

运行生日提醒主流程

reload_config() None[source]

重新加载配置

CLI Commands

src.main.cli(*args: t.Any, **kwargs: t.Any) t.Any

生日提醒系统 - 简洁版本

src.main.run(*args: t.Any, **kwargs: t.Any) t.Any

运行生日提醒主流程

src.main.preview(*args: t.Any, **kwargs: t.Any) t.Any

预览生日提醒邮件内容(默认模板)

src.main.validate(*args: t.Any, **kwargs: t.Any) t.Any

验证配置文件

src.main.info(*args: t.Any, **kwargs: t.Any) t.Any

显示应用信息