一个基于 Python Telegram Bot 的智能翻译与词汇学习助手,集成了 DeepSeek AI 引擎,提供翻译、单词学习、智能纠错、学习计划等功能。
- 多引擎支持:DeepSeek、Google、Bing、百度
- 实时翻译,支持 100+ 语言互译
- 自动语言检测
- 智能生词本:翻译时一键添加生词
- 间隔复习:基于 SM-2 算法的智能复习系统
- 学习统计:进度追踪与可视化报告
- 7日学习计划:AI 生成的个性化学习计划
- 智能纠错:拼写错误自动纠正与候选推荐
- 单词详情:IPA 音标、词性、例句、近反义词
- 对话查询:
/chat获取单词记忆技巧与词根分析 - 难词提取:从文本中自动提取高级词汇
- 可配置的翻译引擎偏好
- 自动切词开关
- 学习数量设置
- 英音/美音切换
- Python 3.11+
- Telegram Bot Token
- 302.AI API Key (DeepSeek)
- 克隆项目
git clone <your-repo-url>
cd v4- 安装依赖
pip install -r requirements.txt- 配置环境变量
# 复制示例配置文件
cp .env.example .env
# 编辑 .env 文件,填入您的实际密钥
# 使用文本编辑器编辑 .env 文件编辑 .env 文件,填入以下内容:
# Telegram Bot Token - 从 @BotFather 获取
BOT_TOKEN=你的Telegram机器人Token
# 302.AI API Key - 从 https://302.ai 获取
AI_API_KEY=你的302.AI API Key
# 可选配置
# DB_FILE=vocab_learning.db
# LOG_LEVEL=INFO📝 获取密钥教程:
- Telegram Bot Token: 访问 @BotFather,创建新机器人,获取 Token
- 302.AI API Key: 注册 302.AI 账号,在控制台获取 API Key
- 切勿将
.env文件提交到 Git - 已将
.env添加到.gitignore进行保护 - 如果密钥泄露,请立即重新生成
- 启动机器人
python main.py- telegram 连接机器人,通常机器人会让你输入密钥,密钥为芝麻开门
docker-compose up -d --buildv4/
├── handlers/ # 处理器模块
│ ├── basic_handlers.py # 基础命令处理
│ ├── learning_handlers.py # 学习功能处理
│ └── settings_handlers.py # 设置功能处理
├── ai_service.py # AI 服务封装
├── database.py # 数据库操作
├── vocab_manager.py # 词汇管理
├── logger_config.py # 日志配置
├── main.py # 程序入口
├── requirements.txt # 依赖列表
└── .env # 环境配置
BOT_TOKEN: Telegram Bot Father 获取AI_API_KEY: 302.AI 平台申请
DB_FILE: 数据库文件路径 (默认: vocab_learning.db)LOG_LEVEL: 日志级别 (默认: INFO)
/start- 开始使用/settings- 打开设置面板/cut <文本>- 切分句子为单词按钮/import <文本>- 提取重点词汇
/daily [数量]- 获取今日学习词汇/review- 开始复习/words [页码]- 查看历史单词/plan- 查看学习计划/stats- 查看学习统计/detail <单词>- 查看单词详情/chat <单词>- 单词对话查询
- 直接发送文本进行翻译
- 拼写错误时自动推荐正确单词
- 翻译结果点击按钮添加生词
- 详情页面切换英音/美音
以下为部分功能的界面示例,帮助你快速了解实际使用效果(图片位于 img/ 目录):
项目已配置 .gitignore 保护敏感信息:
# 环境配置文件
.env
# 数据库文件
*.db
*.sqlite
# 日志文件
logs/
*.log
# Python 虚拟环境
.venv/
__pycache__/
*.pyc- 切勿提交敏感信息:确保
.env不被加入版本控制 - 使用环境变量:所有密钥通过环境变量配置
- 定期更换密钥:重要服务密钥定期更新
- 数据库备份:定期备份
vocab_learning.db文件
主要数据表:
users- 用户信息与认证状态vocabulary- 词汇库learning_records- 学习记录user_plan- 学习计划vocabulary_add_logs- 词汇添加日志ai_interaction_logs- AI 交互日志
- DeepSeek 模糊识别与纠错
- IPA 音标支持(英音/美音)
- 单词详情卡片
- 对话式查询
- 智能学习计划
- Cambridge 字典 API 集成
- 语音发音功能
- 多用户学习小组
- 移动端优化
-
Bot 不响应
- 检查
BOT_TOKEN是否正确 - 确认网络连接正常
- 检查
-
翻译失败
- 检查
AI_API_KEY是否有效 - 确认 302.AI 服务状态
- 检查
-
数据库错误
- 检查数据库文件权限
- 确认磁盘空间充足
如遇问题,请检查日志文件 logs/bot.log 或提交 Issue。
本项目采用 MIT 许可证 - 详见 LICENSE 文件。
欢迎提交 Issue 和 Pull Request!
An intelligent translation and vocabulary learning assistant based on Python Telegram Bot, integrated with DeepSeek AI engine, providing translation, word learning, smart correction, and study planning features.
- Multi-engine support: DeepSeek, Google, Bing, Baidu
- Real-time translation, 100+ language pairs
- Automatic language detection
- Smart Vocabulary Book: One-click add words from translation
- Spaced Repetition: SM-2 algorithm based review system
- Learning Statistics: Progress tracking and visual reports
- 7-Day Study Plan: AI-generated personalized learning plan
- Smart Correction: Automatic spelling correction and candidate suggestions
- Word Details: IPA phonetics, part of speech, examples, synonyms/antonyms
- Chat Query:
/chatfor memory techniques and root analysis - Difficult Word Extraction: Automatically extract advanced vocabulary from text
- Configurable translation engine preferences
- Auto word-splitting toggle
- Learning quantity settings
- UK/US pronunciation switching
- Python 3.11+
- Telegram Bot Token
- 302.AI API Key (DeepSeek)
- Clone Project
git clone <your-repo-url>
cd v4- Install Dependencies
pip install -r requirements.txt- Configure Environment
Create
.envfile:
BOT_TOKEN=your_telegram_bot_token
AI_API_KEY=your_302_ai_api_key- Start Bot
python main.pydocker-compose up -d --buildv4/
├── handlers/ # Handler modules
│ ├── basic_handlers.py # Basic command handling
│ ├── learning_handlers.py # Learning feature handling
│ └── settings_handlers.py # Settings handling
├── ai_service.py # AI service wrapper
├── database.py # Database operations
├── vocab_manager.py # Vocabulary management
├── logger_config.py # Logging configuration
├── main.py # Program entry
├── requirements.txt # Dependencies
└── .env # Environment configuration
BOT_TOKEN: From Telegram Bot FatherAI_API_KEY: From 302.AI platform
DB_FILE: Database file path (default: vocab_learning.db)LOG_LEVEL: Log level (default: INFO)
/start- Start using/settings- Open settings panel/cut <text>- Split sentence into word buttons/import <text>- Extract key vocabulary
/daily [count]- Get today's learning words/review- Start review/words [page]- View history words/plan- View study plan/stats- View statistics/detail <word>- View word details/chat <word>- Word chat query
- Send text directly for translation
- Automatic spelling correction suggestions
- Click buttons on translation results to add words
- Switch between UK/US pronunciation in detail view
Project configured with .gitignore to protect sensitive information:
# Environment config
.env
# Database files
*.db
*.sqlite
# Log files
logs/
*.log
# Python virtual environment
.venv/
__pycache__/
*.pyc- Never commit sensitive info: Ensure
.envis not in version control - Use environment variables: All keys configured via environment variables
- Regular key rotation: Regularly update important service keys
- Database backup: Regularly backup
vocab_learning.dbfile
Main tables:
users- User information and authentication statusvocabulary- Vocabulary librarylearning_records- Learning recordsuser_plan- Study plansvocabulary_add_logs- Vocabulary addition logsai_interaction_logs- AI interaction logs
- DeepSeek fuzzy recognition and correction
- IPA phonetic support (UK/US)
- Word detail cards
- Conversational queries
- Smart learning plans
- Cambridge Dictionary API integration
- Voice pronunciation
- Multi-user study groups
- Mobile optimization
-
Bot not responding
- Check
BOT_TOKENis correct - Confirm network connection
- Check
-
Translation failure
- Check
AI_API_KEYis valid - Confirm 302.AI service status
- Check
-
Database errors
- Check database file permissions
- Confirm disk space available
Check log file logs/bot.log or submit an Issue if problems persist.
MIT License - see LICENSE file for details.
Issues and Pull Requests are welcome!



