36 lines
1.4 KiB
Python
36 lines
1.4 KiB
Python
import os
|
|
from config import Config
|
|
from logger import logger
|
|
|
|
class AgreementManager:
|
|
@staticmethod
|
|
def is_agreed():
|
|
if Config.AGREED_TOS:
|
|
return True
|
|
return os.path.exists(Config.AGREEMENT_FILE)
|
|
|
|
@staticmethod
|
|
def record_agreement():
|
|
with open(Config.AGREEMENT_FILE, 'w') as f:
|
|
f.write("User agreed to terms of service on first use.\n")
|
|
logger.info("协议已同意,记录文件已创建")
|
|
|
|
@staticmethod
|
|
def get_agreement_text():
|
|
return """邮件自动化图片转换工具 - 使用协议
|
|
|
|
1. 本工具仅用于合法用途,用户需自行承担使用风险。
|
|
2. 用户同意不发送违法内容,不滥用服务。
|
|
3. 开发者保留随时停止服务的权利。
|
|
4. 本工具会记录转换日志,但不会泄露您的邮箱密码等敏感信息。
|
|
|
|
请回复本邮件,内容为 "I AGREE" 以确认同意协议。"""
|
|
|
|
@staticmethod
|
|
def request_agreement(recipient_email, mail_sender):
|
|
"""向管理员或用户发送协议请求邮件"""
|
|
subject = "【重要】请同意邮件转换工具使用协议"
|
|
body = AgreementManager.get_agreement_text()
|
|
# 发送邮件(需要mail_handler的实例,为避免循环依赖,在main中调用)
|
|
# 此处只返回内容和收件人,实际发送在main中完成
|
|
return recipient_email, subject, body |