telegram-bot-manager/modules/utils/utils.go

70 lines
1.6 KiB
Go

package utils
import (
"jannex/telegram-bot-manager/modules/logger"
"strings"
"git.ex.umbach.dev/Alex/roese-utils/rslogger"
)
func GetNotificationIconByType(notificationType uint8) string {
switch notificationType {
case 1:
return NotificationIconSuccess
case 2:
return NotificationSymbolInfo
case 3:
return NotificationSymbolWarnung
case 4:
return NotificationSymbolError
default:
logger.AddSystemLog(rslogger.LogTypeError, "Unknown notification type: %v", notificationType)
return ""
}
}
func GetFormattedFilters(filter string) string {
filterValues := strings.Split(filter, ",")
var formattedFilters []string
for _, v := range filterValues {
switch v {
case NotificationTypeSuccess:
formattedFilters = append(formattedFilters, NotificationTypeSuccessString)
case NotificationTypeInfo:
formattedFilters = append(formattedFilters, NotificationTypeInfoString)
case NotificationTypeWarning:
formattedFilters = append(formattedFilters, NotificationTypeWarningString)
case NotificationTypeError:
formattedFilters = append(formattedFilters, NotificationTypeErrorString)
}
}
return strings.Join(formattedFilters, ", ")
}
func IsNotificationTypeInFilter(filter []string, notificationType uint8) bool {
for _, v := range filter {
switch v {
case NotificationTypeSuccess:
if notificationType == 1 {
return true
}
case NotificationTypeInfo:
if notificationType == 2 {
return true
}
case NotificationTypeWarning:
if notificationType == 3 {
return true
}
case NotificationTypeError:
if notificationType == 4 {
return true
}
}
}
return false
}