stats_notify_job.go 758 B

1234567891011121314151617181920212223242526272829303132
  1. package job
  2. import (
  3. "github.com/mhsanaei/3x-ui/v2/web/service"
  4. )
  5. // LoginStatus represents the status of a login attempt.
  6. type LoginStatus byte
  7. const (
  8. LoginSuccess LoginStatus = 1 // Successful login
  9. LoginFail LoginStatus = 0 // Failed login attempt
  10. )
  11. // StatsNotifyJob sends periodic statistics reports via Telegram bot.
  12. type StatsNotifyJob struct {
  13. xrayService service.XrayService
  14. tgbotService service.Tgbot
  15. }
  16. // NewStatsNotifyJob creates a new statistics notification job instance.
  17. func NewStatsNotifyJob() *StatsNotifyJob {
  18. return new(StatsNotifyJob)
  19. }
  20. // Run sends a statistics report via Telegram bot if Xray is running.
  21. func (j *StatsNotifyJob) Run() {
  22. if !j.xrayService.IsXrayRunning() {
  23. return
  24. }
  25. j.tgbotService.SendReport()
  26. }