job has multiline formatter
parent
2791ba6763
commit
ec2b514a9f
|
|
@ -34,3 +34,16 @@ func (j Job) String() string {
|
|||
func (j JobLocation) String() string {
|
||||
return fmt.Sprintf("%s, %s @ %s", j.City, j.State, j.Date.Format("Monday Jan 02"))
|
||||
}
|
||||
|
||||
func (j Job) FormatMultilineText() string {
|
||||
return fmt.Sprintf(
|
||||
"--- %s => %s ---\nPickup: %s\nDropoff: %s\nNotes: %d lbs, %d miles, %s",
|
||||
j.Pickup.State,
|
||||
j.Dropoff.State,
|
||||
j.Pickup.String(),
|
||||
j.Dropoff.String(),
|
||||
j.Weight,
|
||||
j.Miles,
|
||||
j.Meta,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
6
main.go
6
main.go
|
|
@ -8,6 +8,7 @@ import (
|
|||
"local/storage"
|
||||
"local/truckstop/broker"
|
||||
"local/truckstop/config"
|
||||
"local/truckstop/message"
|
||||
"log"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
|
@ -153,7 +154,6 @@ func dropBanlistJobs(jobs []broker.Job) ([]broker.Job, error) {
|
|||
}
|
||||
|
||||
func sendJob(job broker.Job) error {
|
||||
// TODO
|
||||
log.Printf("found job: %s", job)
|
||||
return nil
|
||||
sender := message.NewMatrix()
|
||||
return sender.Send(job.FormatMultilineText())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package message
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"local/truckstop/config"
|
||||
|
||||
"github.com/matrix-org/gomatrix"
|
||||
|
|
@ -33,9 +32,6 @@ func (m Matrix) Send(text string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
resp, err := c.SendText(m.room, text)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return fmt.Errorf("%+v", resp)
|
||||
_, err = c.SendText(m.room, text)
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue