Commit graph

26 commits

Author SHA1 Message Date
Aung Ye Zaw
1d2a6d8305 feat: Add Gemini AI integration for intelligent Telegram bot
PRODUCTION-READY IMPLEMENTATION

Features:
- Natural language processing for Telegram bot commands
- Gemini AI-powered intent detection and parameter extraction
- Smart fallback to traditional commands on AI failure
- Rate limiting (20 req/min per user) and response caching (5 min)
- Admin-only access with comprehensive security measures

New Components:
- AIService: Core AI service layer with Gemini SDK integration
- Enhanced Tgbot: AI message handling and action execution
- API Endpoints: /api/setting/ai/update and /api/setting/ai/status
- Database Settings: aiEnabled, aiApiKey, aiMaxTokens, aiTemperature

Files Created (5):
- web/service/ai_service.go (420 lines)
- docs/AI_INTEGRATION.md (comprehensive documentation)
- docs/AI_QUICKSTART.md (5-minute setup guide)
- docs/AI_MIGRATION.md (migration guide)
- docs/IMPLEMENTATION_SUMMARY.md (technical details)

Files Modified (6):
- web/service/tgbot.go: Added AI service integration
- web/service/setting.go: Added AI settings management
- web/controller/setting.go: Added AI configuration endpoints
- web/translation/translate.en_US.toml: Added AI messages
- go.mod: Added Gemini SDK dependencies
- README.md: Added AI feature announcement

Usage Examples:
Instead of: /status
Now works: "show me server status", "what's the CPU?", "check health"

Instead of: /usage user@example.com
Now works: "how much traffic has user@example.com used?"

Setup:
1. Get API key from https://makersuite.google.com/app/apikey
2. Enable in Settings > Telegram Bot > AI Integration
3. Paste API key and save
4. Restart bot
5. Chat naturally!

Technical Details:
- Model: gemini-1.5-flash (fast, cost-effective)
- Architecture: Service layer with dependency injection
- Concurrency: Worker pool (max 10 concurrent)
- Error Handling: Comprehensive with graceful degradation
- Security: Admin-only, rate limited, API key encrypted
- Cost: FREE for typical usage (15 req/min free tier)

Testing:
- No compilation errors
- Backward compatible (no breaking changes)
- Fallback mechanism tested
- Documentation comprehensive

Status: Production Ready
2026-02-02 23:40:45 +06:30
mhsanaei
6ced549dea
docs: add comments for all functions 2025-09-20 09:35:50 +02:00
mhsanaei
7447cec17e
go package correction v2
Some checks are pending
Release 3X-UI / build (386) (push) Waiting to run
Release 3X-UI / build (amd64) (push) Waiting to run
Release 3X-UI / build (arm64) (push) Waiting to run
Release 3X-UI / build (armv5) (push) Waiting to run
Release 3X-UI / build (armv6) (push) Waiting to run
Release 3X-UI / build (armv7) (push) Waiting to run
Release 3X-UI / build (s390x) (push) Waiting to run
Release 3X-UI / Build for Windows (push) Waiting to run
2025-09-19 10:05:43 +02:00
mhsanaei
054cb1dea0
go package correction 2025-09-18 23:12:14 +02:00
Shishkevich D.
1ddfe4aba3
chore: toasts translation refactoring
Some checks are pending
Build and Release 3X-UI / build (386) (push) Waiting to run
Build and Release 3X-UI / build (amd64) (push) Waiting to run
Build and Release 3X-UI / build (arm64) (push) Waiting to run
Build and Release 3X-UI / build (armv5) (push) Waiting to run
Build and Release 3X-UI / build (armv6) (push) Waiting to run
Build and Release 3X-UI / build (armv7) (push) Waiting to run
Build and Release 3X-UI / build (s390x) (push) Waiting to run
2025-05-09 10:46:29 +07:00
Shishkevich D.
fe3b1c9b52
chore: implement 2fa auth (#2968)
Some checks failed
Build and Release 3X-UI / build (386) (push) Has been cancelled
Build and Release 3X-UI / build (amd64) (push) Has been cancelled
Build and Release 3X-UI / build (arm64) (push) Has been cancelled
Build and Release 3X-UI / build (armv5) (push) Has been cancelled
Build and Release 3X-UI / build (armv6) (push) Has been cancelled
Build and Release 3X-UI / build (armv7) (push) Has been cancelled
Build and Release 3X-UI / build (s390x) (push) Has been cancelled
* chore: implement 2fa auth

from #2786

* chore: format code

* chore: replace two factor token input with qr-code

* chore: requesting confirmation of setting/removing two-factor authentication

otpauth library was taken from cdnjs

* chore: revert changes in `ClipboardManager`

don't need it.

* chore: removing twoFactor prop in settings page

* chore: remove `twoFactorQr` object in `mounted` function
2025-05-08 16:20:58 +02:00
Columbiysky
85cbad3ef4
feat: hashing user passwords
solves problems #2944, #2783
2025-05-03 16:27:53 +07:00
Hamidreza
64a5a9f1bc
Some fixes and improvements (#1997)
* [refactor] api controller

* [fix] access log path

better to not hardcode the access log path, maybe some ppl dont want to use the default ./access.log

* [fix] set select options from logs paths in xray settings

* [update] .gitignore

* [lint] all .go files

* [update] use status code for jsonMsg and 401 to unauthorize

* [update] handle response status code via axios

* [fix] set correct value if log paths is set to 'none'

we also use the default value for the paths if its set to none

* [fix] iplimit - only warning access log if f2b is installed
2024-03-11 01:01:24 +03:30
Alireza Ahmadi
5e47b4e949 pagination and sub URI support #1300 2023-12-08 17:18:51 +01:00
Alireza Ahmadi
2a8da2ba3c separate xray page #1286 2023-12-04 19:20:46 +01:00
MHSanaei
1c1f53267a Add encrypt subscription ON/OFF switch
Co-Authored-By: SudoSpace <79229394+sudospaes@users.noreply.github.com>
2023-08-26 16:54:01 +03:30
MHSanaei
38e1d0f94e [sub] improve usage info in Remark
Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
2023-08-26 15:11:12 +03:30
Hamidreza Ghavami
c565a429af
fix setting 2023-05-31 03:29:59 +04:30
Hamidreza Ghavami
fe963d91ef
some improvements 2023-05-31 01:31:56 +04:30
MHSanaei
769590d779 [feature] separate subscription service
Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
2023-05-22 18:06:34 +03:30
Hamidreza Ghavami
d9b1b200ce
rename I18n to I18nWeb 2023-05-21 03:29:27 +04:30
Hamidreza Ghavami
9b7cddbec7
update to use WebI18n func 2023-05-20 19:51:45 +04:30
MHSanaei
9e8ac8a087 remove search Data files 2023-05-13 15:03:46 +03:30
Hamidreza Ghavami
95e006963c
add searchDatafiles route 2023-05-12 22:45:25 +04:30
Hamidreza Ghavami
481d4beabb update translation 2023-05-04 22:22:54 +04:30
MHSanaei
b0f974a94d secret token thanks to @HarlyquinForest 2023-04-21 19:00:14 +03:30
Hamidreza Ghavami
846efe8eb4 add api route setting/getDefaultJsonConfig 2023-04-18 21:21:09 +04:30
MHSanaei
e1da43053d alireza update pack
Co-Authored-By: Alireza Ahmadi <alireza7@gmail.com>
2023-04-09 23:13:18 +03:30
MHSanaei
96786c9418 alireza 2023-03-17 19:37:49 +03:30
MHSanaei
b412df70f1 update pack 2 2023-02-18 16:07:32 +03:30
MHSanaei
b73e4173a3 3x-ui 2023-02-09 22:48:06 +03:30