Rewrite camera uptime monitor in Golang
This commit is contained in:
1 parent
fd4c30f655
commit
90efd78669
13 files changed
+284
-1
No files matched your search
@@ -0,0 +1,28 @@
|
||||
package notify
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
||||
type Notifier interface {
|
||||
SendNotification(camera string, online bool)
|
||||
}
|
||||
|
||||
func createMessage(camera string, online bool) string {
|
||||
var msgTemplates = map[bool]string{
|
||||
true: "%s camera is back online!",
|
||||
false: "%s camera is offline!",
|
||||
}
|
||||
|
||||
var cameraTitle string
|
||||
for i, s := range strings.Split(camera, "_") {
|
||||
if i > 0 {
|
||||
cameraTitle += " "
|
||||
}
|
||||
cameraTitle += strings.ToUpper(string(s[0])) + s[1:]
|
||||
}
|
||||
|
||||
return fmt.Sprintf(msgTemplates[online], cameraTitle)
|
||||
}
|
||||
Reference in new issue
Block a user