add fpl dla
This commit is contained in:
+8
-4
@@ -16,6 +16,7 @@ type Telegram struct {
|
||||
Type string
|
||||
FlopValue []string
|
||||
FlightNumber string
|
||||
Plane string
|
||||
RegisterNumber string
|
||||
Departure string
|
||||
DepartureTime time.Time
|
||||
@@ -42,12 +43,15 @@ func Parse(text string) (*Telegram, error) {
|
||||
if isPln(*telegram) {
|
||||
telegram.Type = TypePLN
|
||||
} else if flopValues := getFields(FlopRegex, telegram.Text); len(flopValues) > 0 {
|
||||
telegram.Type = flopValues["flop"]
|
||||
r := regexp.MustCompile(FlopRegex)
|
||||
data := r.FindString(telegram.Text)
|
||||
telegram.Type = flopValues["type"]
|
||||
data := flopRegex.FindString(telegram.Text)
|
||||
switch telegram.Type {
|
||||
case TypeArrival, TypeDeparture:
|
||||
parseArrOrDep(telegram, data)
|
||||
case TypeFlightPlan:
|
||||
parseFlightPlan(telegram, data)
|
||||
case TypeDelay:
|
||||
parseDelay(telegram, data)
|
||||
}
|
||||
}
|
||||
return telegram, nil
|
||||
@@ -80,7 +84,7 @@ func getFields(regEx string, field string) (fields map[string]string) {
|
||||
return
|
||||
}
|
||||
|
||||
func getFlopValues(s string) []string {
|
||||
func getSplitValues(s string) []string {
|
||||
// get rid of ()
|
||||
s = strings.TrimSpace(s)
|
||||
s = s[1 : len(s)-1]
|
||||
|
||||
Reference in New Issue
Block a user