Improve message formatting
This commit is contained in:
parent
94336e07bf
commit
1e4111ff9c
|
@ -93,15 +93,18 @@ func executeBot(cmd *cobra.Command, args []string) error {
|
|||
log.Info(tLoad)
|
||||
}
|
||||
tMessage := &strings.Builder{}
|
||||
tMessage.WriteString("Hallenauslastung (" + time.Now().Format("2006-01-02 15:04") + "):\n" )
|
||||
for _, tL := range loads {
|
||||
tMessage.WriteString(fmt.Sprintf("*%v*: %v%% (%v)\n", tL.Area.Name, tL.Load, tL.Status))
|
||||
tMessage.WriteString(fmt.Sprintf("%v: __*%v%%*__ \\(%v\\)\n", tL.Area.Name, tL.Load, tL.Status))
|
||||
}
|
||||
tMessage.WriteString("\\(Stand " + time.Now().Format("2006\\-01\\-02 15:04") + "\\)" )
|
||||
for _, tChan := range C.Bot.Channels {
|
||||
if tChan.Id != 0 {
|
||||
if tChan.Message != 0 {
|
||||
// edit
|
||||
tBot.EditMessageText(tChan.Id, tChan.Message, tMessage.String())
|
||||
_, err := tBot.EditMessageText(tChan.Id, tChan.Message, tMessage.String())
|
||||
if err != nil {
|
||||
log.WithError(err).Error("cannot update message")
|
||||
}
|
||||
} else {
|
||||
tMsg, err := tBot.SendMessage(tChan.Id, tMessage.String(), 0)
|
||||
log.WithError(err).Info(tMsg)
|
||||
|
|
2
go.mod
2
go.mod
|
@ -21,6 +21,6 @@ require (
|
|||
gopkg.in/ini.v1 v1.62.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.3.0 // indirect
|
||||
udico.de/uditaren/cure v0.0.0-20201028103208-58e0952a9cc1 // indirect
|
||||
udico.de/uditaren/goboter v0.0.0-20201028103045-edb2c6155023
|
||||
udico.de/uditaren/goboter v0.0.0-20201028143451-375a9ebc9ffd
|
||||
udico.de/uditaren/terminator v0.0.0-20200529143738-0fc1a7f84683
|
||||
)
|
||||
|
|
2
go.sum
2
go.sum
|
@ -374,5 +374,7 @@ udico.de/uditaren/goboter v0.0.0-20201028102424-780ba5195465 h1:903/BL0s6jPy/Wa0
|
|||
udico.de/uditaren/goboter v0.0.0-20201028102424-780ba5195465/go.mod h1:mvZEd09zJhbeZ2wGvUjC5Pw//4VjFlmascT8U6Wg5Qw=
|
||||
udico.de/uditaren/goboter v0.0.0-20201028103045-edb2c6155023 h1:mGoNd/h/WyfcTczlWybOkstyPhkesIgEgl20iXoddDM=
|
||||
udico.de/uditaren/goboter v0.0.0-20201028103045-edb2c6155023/go.mod h1:mvZEd09zJhbeZ2wGvUjC5Pw//4VjFlmascT8U6Wg5Qw=
|
||||
udico.de/uditaren/goboter v0.0.0-20201028143451-375a9ebc9ffd h1:xTMOskyx4WuRRcleeQBr0VF9q64Uw+O7/vpA3QBLr34=
|
||||
udico.de/uditaren/goboter v0.0.0-20201028143451-375a9ebc9ffd/go.mod h1:mvZEd09zJhbeZ2wGvUjC5Pw//4VjFlmascT8U6Wg5Qw=
|
||||
udico.de/uditaren/terminator v0.0.0-20200529143738-0fc1a7f84683 h1:ImhTYFlsoYVX2HcZj8QYimdzzQqUa5PzAle6lc4c+IU=
|
||||
udico.de/uditaren/terminator v0.0.0-20200529143738-0fc1a7f84683/go.mod h1:NyDGvbF2hx5nUAqW5MDcFKRqPS/p6QOv9bbLf+CAnAE=
|
||||
|
|
Loading…
Reference in New Issue
Block a user