new - tg Login Notification #584

This commit is contained in:
MHSanaei
2023-06-17 19:11:16 +03:30
parent 5188d516e3
commit b833ed7992
9 changed files with 21 additions and 0 deletions
+5
View File
@@ -39,6 +39,7 @@ var defaultValueMap = map[string]string{
"tgBotChatId": "",
"tgRunTime": "@daily",
"tgBotBackup": "false",
"tgBotLoginNotify": "false",
"tgCpu": "0",
"tgLang": "en-US",
"secretEnable": "false",
@@ -266,6 +267,10 @@ func (s *SettingService) GetTgBotBackup() (bool, error) {
return s.getBool("tgBotBackup")
}
func (s *SettingService) GetTgBotLoginNotify() (bool, error) {
return s.getBool("tgBotLoginNotify")
}
func (s *SettingService) GetTgCpu() (int, error) {
return s.getInt("tgCpu")
}
+5
View File
@@ -643,6 +643,11 @@ func (t *Tgbot) UserLoginNotify(username string, ip string, time string, status
return
}
loginNotifyEnabled, err := t.settingService.GetTgBotLoginNotify()
if err != nil || !loginNotifyEnabled {
return
}
msg := ""
if status == LoginSuccess {
msg += t.I18nBot("tgbot.messages.loginSuccess")