diff --git a/message_contents.go b/message_contents.go index 758b0ea..68f1e8c 100644 --- a/message_contents.go +++ b/message_contents.go @@ -122,3 +122,57 @@ func (self MsgContent) FormatEvent() string { } panic(fmt.Sprint("Unknown event received: ", self.SatelEvent)) } + +func (self MsgContent) IndexDesc() string { + switch self.SatelEvent.Type { + case satel.ZoneViolation: + return fmt.Sprintf("Zone %d", self.SatelEvent.Index) + case satel.ZoneTamper: + return fmt.Sprintf("Zone %d", self.SatelEvent.Index) + case satel.ZoneAlarm: + return fmt.Sprintf("Zone %d", self.SatelEvent.Index) + case satel.ZoneTamperAlarm: + return fmt.Sprintf("Zone %d", self.SatelEvent.Index) + case satel.ZoneAlarmMemory: + return fmt.Sprintf("Zone %d", self.SatelEvent.Index) + case satel.ZoneTamperAlarmMemory: + return fmt.Sprintf("Zone %d", self.SatelEvent.Index) + case satel.ZoneBypass: + return fmt.Sprintf("Zone %d", self.SatelEvent.Index) + case satel.ZoneNoViolationTrouble: + return fmt.Sprintf("Zone %d", self.SatelEvent.Index) + case satel.ZoneLongViolationTrouble: + return fmt.Sprintf("Zone %d", self.SatelEvent.Index) + case satel.ArmedPartitionSuppressed: + return fmt.Sprintf("Partition %d", self.SatelEvent.Index) + case satel.ArmedPartition: + return fmt.Sprintf("Partition %d", self.SatelEvent.Index) + case satel.PartitionArmedInMode2: + return fmt.Sprintf("Partition %d", self.SatelEvent.Index) + case satel.PartitionArmedInMode3: + return fmt.Sprintf("Partition %d", self.SatelEvent.Index) + case satel.PartitionWith1stCodeEntered: + return fmt.Sprintf("Partition %d", self.SatelEvent.Index) + case satel.PartitionEntryTime: + return fmt.Sprintf("Partition %d", self.SatelEvent.Index) + case satel.PartitionExitTimeOver10s: + return fmt.Sprintf("Partition %d", self.SatelEvent.Index) + case satel.PartitionExitTimeUnder10s: + return fmt.Sprintf("Partition %d", self.SatelEvent.Index) + case satel.PartitionTemporaryBlocked: + return fmt.Sprintf("Partition %d", self.SatelEvent.Index) + case satel.PartitionBlockedForGuardRound: + return fmt.Sprintf("Partition %d", self.SatelEvent.Index) + case satel.PartitionAlarm: + return fmt.Sprintf("Partition %d", self.SatelEvent.Index) + case satel.PartitionFireAlarm: + return fmt.Sprintf("Partition %d", self.SatelEvent.Index) + case satel.PartitionAlarmMemory: + return fmt.Sprintf("Partition %d", self.SatelEvent.Index) + case satel.PartitionFireAlarmMemory: + return fmt.Sprintf("Partition %d", self.SatelEvent.Index) + case satel.ZoneIsolate: + return fmt.Sprintf("Zone %d", self.SatelEvent.Index) + } + return fmt.Sprintf("Unknown index: %d", self.SatelEvent.Index) +} diff --git a/templates.go b/templates.go index 4109bab..9efdbe2 100644 --- a/templates.go +++ b/templates.go @@ -2,7 +2,7 @@ package main const TelegramMessageTemplate = `Received following changes: {{- range .Messages}} -:: {{.SatelEvent.Index}}: {{.FormatEvent}} +:: {{.IndexDesc}}: {{.FormatEvent}} {{- else -}} Huh, no messages - this is a bug {{- end}}`