This commit is contained in:
parent
73c6ab3cba
commit
3c455186b7
156
.gitignore
vendored
156
.gitignore
vendored
@ -1,62 +1,110 @@
|
||||
.idea
|
||||
.DS_Store
|
||||
dist
|
||||
output
|
||||
smail.db
|
||||
backend/plugins/*
|
||||
!backend/plugins/
|
||||
!backend/plugins/catalog/
|
||||
!backend/plugins/catalog/*.go
|
||||
config
|
||||
*_KEY
|
||||
AURORA_SECRET
|
||||
.codex-edit-config.py
|
||||
backend/gosec-report
|
||||
backend/gosec-g104-current.json
|
||||
backend/spam_block.exe
|
||||
backend/wechat_push.exe
|
||||
backend/utils/validation/test.tmp
|
||||
backend/.codex-smail-*
|
||||
backend/.tmp-*
|
||||
|
||||
!backend/config/
|
||||
backend/config/*
|
||||
!backend/config/*.go
|
||||
!backend/config/dkim/
|
||||
backend/config/dkim/*
|
||||
!backend/config/dkim/README.md
|
||||
!backend/config/ssl/
|
||||
backend/config/ssl/*
|
||||
!backend/config/ssl/README.md
|
||||
.codex-cg*.patch
|
||||
backend/config/credential.key
|
||||
backend/smail.exe
|
||||
backend/smail-admin.exe
|
||||
.codex-smail-*
|
||||
|
||||
# 本地测试输出和临时文件
|
||||
# 统一输出目录:测试源码放 test,日志放 test-log,编译产物放 out
|
||||
/out/
|
||||
/test-log/
|
||||
/test/archive/
|
||||
artifacts/
|
||||
/artifacts/
|
||||
/dist/
|
||||
/output/
|
||||
|
||||
# 本机运行根目录与人工证书输入,不匹配源码中的同名目录
|
||||
/config/
|
||||
/ssl/
|
||||
|
||||
# 后端配置目录混放源码与运行数据:只放行代码、文档和脱敏示例
|
||||
/backend/config/*
|
||||
!/backend/config/*.go
|
||||
!/backend/config/*.md
|
||||
!/backend/config/*.json.example
|
||||
!/backend/config/dkim/
|
||||
/backend/config/dkim/*
|
||||
!/backend/config/dkim/README.md
|
||||
!/backend/config/ssl/
|
||||
/backend/config/ssl/*
|
||||
!/backend/config/ssl/README.md
|
||||
|
||||
# 后端插件安装目录保留源码目录,其余视为运行时安装内容
|
||||
/backend/plugins/*
|
||||
!/backend/plugins/catalog/
|
||||
!/backend/plugins/catalog/**
|
||||
|
||||
# Telegram 配置源码和示例可跟踪,真实配置与数据不上传
|
||||
/plugins/pmail_telegram_push/config/*
|
||||
!/plugins/pmail_telegram_push/config/*.go
|
||||
!/plugins/pmail_telegram_push/config/*.json.example
|
||||
!/plugins/pmail_telegram_push/config/README.md
|
||||
/plugins/pmail_telegram_push/plugins/
|
||||
|
||||
# Go 嵌入中间文件,以及旧命令仍可能生成的构建目录
|
||||
/backend/listen/http_server/dist/
|
||||
/frontend/dist/
|
||||
/frontend/dist-ssr/
|
||||
/plugins/pmail_telegram_push/hook/dist/
|
||||
/plugins/pmail_telegram_push/dist/
|
||||
/plugins/pmail_telegram_push/dist-ssr/
|
||||
/plugins/pmail_telegram_push/output/
|
||||
/backend/*.exe
|
||||
/backend/smail
|
||||
/backend/smail-admin
|
||||
/backend/smail-config
|
||||
/backend/smail_linux_*
|
||||
/backend/smail_windows_*
|
||||
/backend/smail_mac_*
|
||||
/backend/smail_darwin_*
|
||||
/backend/smail-admin_linux_*
|
||||
/backend/smail-admin_windows_*
|
||||
/backend/smail-admin_mac_*
|
||||
/backend/smail-admin_darwin_*
|
||||
/backend/hooks/spam_block/export/export_linux_*
|
||||
/backend/hooks/spam_block/export/export_windows_*
|
||||
/backend/hooks/spam_block/export/export_mac_*
|
||||
/plugins/spam_block/export/export_linux_*
|
||||
/plugins/spam_block/export/export_windows_*
|
||||
/plugins/spam_block/export/export_mac_*
|
||||
|
||||
# 历史扫描结果与本地调试辅助文件,不忽略正式测试源码
|
||||
/backend/gosec-report
|
||||
/backend/gosec-g104-current.json
|
||||
/backend/utils/validation/test.tmp
|
||||
/backend/.codex-smail-*
|
||||
/.codex-edit-config.py
|
||||
/.codex-cg*.patch
|
||||
/.codex-smail-*
|
||||
.tmp-*
|
||||
*.log
|
||||
*.pid
|
||||
backend/smail_*
|
||||
backend/smail-admin_*
|
||||
backend/*.exe
|
||||
backend/config/smail_temp.db
|
||||
backend/config/external-email-*.key
|
||||
backend/config/ssl/*.crt
|
||||
backend/config/ssl/*.key
|
||||
backend/config/ssl/*.csr
|
||||
backend/config/dkim/backup-*/
|
||||
|
||||
# 配置迁移生成的本地分区和原始备份,不进入版本库
|
||||
backend/config/config.json.legacy
|
||||
backend/config/smtp.json
|
||||
backend/config/email.json
|
||||
backend/config/ssl.json
|
||||
backend/config/plugins.json
|
||||
backend/config/migration-backups/
|
||||
# 依赖、解释器缓存及覆盖率;不忽略 Go 测试或手写声明文件
|
||||
node_modules/
|
||||
__pycache__/
|
||||
.pytest_cache/
|
||||
*.pyc
|
||||
*.pyo
|
||||
*.tsbuildinfo
|
||||
coverage/
|
||||
|
||||
# 本地数据库及 SQLite 附属文件
|
||||
*.db
|
||||
*.db-wal
|
||||
*.db-shm
|
||||
*.db-journal
|
||||
*.sqlite
|
||||
*.sqlite-wal
|
||||
*.sqlite-shm
|
||||
*.sqlite-journal
|
||||
*.sqlite3
|
||||
*.sqlite3-wal
|
||||
*.sqlite3-shm
|
||||
*.sqlite3-journal
|
||||
|
||||
# 本机环境变量与凭据文件;不使用全局 *.json、*.key 或 config 规则
|
||||
.env
|
||||
.env.local
|
||||
.env.*.local
|
||||
*_KEY
|
||||
AURORA_SECRET
|
||||
|
||||
# 编辑器及操作系统缓存
|
||||
.idea/
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
Desktop.ini
|
||||
|
||||
4
backend/.gitignore
vendored
4
backend/.gitignore
vendored
@ -1,3 +1,3 @@
|
||||
|
||||
!backend/config/
|
||||
!backend/config/*.go
|
||||
# 后端配置、插件安装目录和构建产物统一由项目根目录 .gitignore 管理。
|
||||
# 不在这里重复配置相对 backend/ 的路径,避免规则失效或误放行运行数据。
|
||||
|
||||
10
plugins/pmail_telegram_push/.gitignore
vendored
10
plugins/pmail_telegram_push/.gitignore
vendored
@ -1,5 +1,11 @@
|
||||
config/*.json
|
||||
pmail_telegram_push*
|
||||
# 配置源码与示例由根规则放行,此处只忽略插件根目录的编译产物。
|
||||
/config/*.json
|
||||
/pmail_telegram_push
|
||||
/pmail_telegram_push.exe
|
||||
/pmail_telegram_push_linux_*
|
||||
/pmail_telegram_push_windows_*
|
||||
/pmail_telegram_push_mac_*
|
||||
/pmail_telegram_push_darwin_*
|
||||
*.db
|
||||
|
||||
# Logs
|
||||
|
||||
67
plugins/pmail_telegram_push/config/config.go
Normal file
67
plugins/pmail_telegram_push/config/config.go
Normal file
@ -0,0 +1,67 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
|
||||
pconfig "git.pcux.cn/xuans/Smail/config"
|
||||
"github.com/ydzydzydz/pmail_telegram_push/logger"
|
||||
)
|
||||
|
||||
const (
|
||||
MAIN_CONFIG_FILE = "./config/config.json"
|
||||
PLUGIN_CONFIG_FILE = "./config/pmail_telegram_push_config.json"
|
||||
)
|
||||
|
||||
// PluginConfig 插件配置
|
||||
type PluginConfig struct {
|
||||
TelegramBotToken string `json:"telegram_bot_token"` // Telegram机器人Token
|
||||
Proxy string `json:"proxy" default:""` // 代理地址
|
||||
Timeout int `json:"timeout" default:"30"` // 超时时间
|
||||
Debug bool `json:"debug" default:"false"` // 调试模式
|
||||
}
|
||||
|
||||
// Config 配置
|
||||
type Config struct {
|
||||
PluginConfig *PluginConfig
|
||||
MainConfig *pconfig.Config
|
||||
}
|
||||
|
||||
// readMainConfig 读取主配置文件
|
||||
func readMainConfig() *pconfig.Config {
|
||||
content, err := os.ReadFile(MAIN_CONFIG_FILE)
|
||||
if err != nil {
|
||||
logger.PluginLogger.Panic().Err(err).Msg("主配置文件读取失败")
|
||||
}
|
||||
var mainConfig pconfig.Config
|
||||
if err := json.Unmarshal(content, &mainConfig); err != nil {
|
||||
logger.PluginLogger.Panic().Err(err).Msg("主配置文件解析失败")
|
||||
}
|
||||
logger.PluginLogger.Info().Msg("主配置文件读取成功")
|
||||
return &mainConfig
|
||||
}
|
||||
|
||||
// readPluginConfig 读取插件配置文件
|
||||
func readPluginConfig() *PluginConfig {
|
||||
content, err := os.ReadFile(PLUGIN_CONFIG_FILE)
|
||||
if err != nil {
|
||||
logger.PluginLogger.Panic().Err(err).Msg("插件配置文件读取失败")
|
||||
}
|
||||
var pluginConfig PluginConfig
|
||||
if err := json.Unmarshal(content, &pluginConfig); err != nil {
|
||||
logger.PluginLogger.Panic().Err(err).Msg("插件配置文件解析失败")
|
||||
}
|
||||
if pluginConfig.TelegramBotToken == "" {
|
||||
logger.PluginLogger.Panic().Msg("telegram bot token is empty")
|
||||
}
|
||||
logger.PluginLogger.Info().Msg("插件配置文件读取成功")
|
||||
return &pluginConfig
|
||||
}
|
||||
|
||||
// ReadConfig 读取配置
|
||||
func ReadConfig() *Config {
|
||||
return &Config{
|
||||
PluginConfig: readPluginConfig(),
|
||||
MainConfig: readMainConfig(),
|
||||
}
|
||||
}
|
||||
4
plugins/pmail_telegram_push/config/config.json.example
Normal file
4
plugins/pmail_telegram_push/config/config.json.example
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"webDomain": "YOUR_PMAIL_WEB_DOMAIN",
|
||||
"httpsEnabled": 2,
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
{
|
||||
"telegram_bot_token": "YOUR_TELEGRAM_BOT_TOKEN",
|
||||
"debug": false,
|
||||
"proxy": "",
|
||||
"timeout": 30
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user