2023-02-09 19:18:06 +00:00
|
|
|
package job
|
|
|
|
|
|
|
|
import (
|
2025-09-19 08:05:43 +00:00
|
|
|
"github.com/mhsanaei/3x-ui/v2/web/service"
|
2023-02-09 19:18:06 +00:00
|
|
|
)
|
|
|
|
|
2025-09-20 07:35:50 +00:00
|
|
|
// LoginStatus represents the status of a login attempt.
|
2023-02-09 19:18:06 +00:00
|
|
|
type LoginStatus byte
|
|
|
|
|
|
|
|
const (
|
2025-09-20 07:35:50 +00:00
|
|
|
LoginSuccess LoginStatus = 1 // Successful login
|
|
|
|
LoginFail LoginStatus = 0 // Failed login attempt
|
2023-02-09 19:18:06 +00:00
|
|
|
)
|
|
|
|
|
2025-09-20 07:35:50 +00:00
|
|
|
// StatsNotifyJob sends periodic statistics reports via Telegram bot.
|
2023-02-09 19:18:06 +00:00
|
|
|
type StatsNotifyJob struct {
|
2023-03-17 16:07:49 +00:00
|
|
|
xrayService service.XrayService
|
|
|
|
tgbotService service.Tgbot
|
2023-02-09 19:18:06 +00:00
|
|
|
}
|
|
|
|
|
2025-09-20 07:35:50 +00:00
|
|
|
// NewStatsNotifyJob creates a new statistics notification job instance.
|
2023-02-09 19:18:06 +00:00
|
|
|
func NewStatsNotifyJob() *StatsNotifyJob {
|
|
|
|
return new(StatsNotifyJob)
|
|
|
|
}
|
|
|
|
|
2025-09-20 07:35:50 +00:00
|
|
|
// Run sends a statistics report via Telegram bot if Xray is running.
|
2023-02-09 19:18:06 +00:00
|
|
|
func (j *StatsNotifyJob) Run() {
|
|
|
|
if !j.xrayService.IsXrayRunning() {
|
|
|
|
return
|
|
|
|
}
|
2023-03-17 16:07:49 +00:00
|
|
|
j.tgbotService.SendReport()
|
2023-02-09 19:18:06 +00:00
|
|
|
}
|