impl sending maps of pickup+dropoff
parent
3423e5f76a
commit
1334295204
|
|
@ -19,11 +19,11 @@
|
|||
{
|
||||
"id": 4650338,
|
||||
"sDate": "01/12/22",
|
||||
"sCity": "Somewhere",
|
||||
"sState": "OH",
|
||||
"sCity": "Advance",
|
||||
"sState": "NC",
|
||||
"sdh": null,
|
||||
"cDate": "01/13/22",
|
||||
"cCity": "SomewhereElse",
|
||||
"cCity": "Atlanta",
|
||||
"cState": "GA",
|
||||
"cdh": null,
|
||||
"stopCnt": 2,
|
||||
|
|
|
|||
14
config.json
14
config.json
|
|
@ -4,6 +4,11 @@
|
|||
"OK": "6h0m0s..6h0m0s",
|
||||
"Error": "6h0m0s..6h0m0s"
|
||||
},
|
||||
"Maps": {
|
||||
"URIFormat": "https://maps.googleapis.com/maps/api/staticmap?center=%s\u0026markers=label=A|%s\u0026zoom=5\u0026size=250x250\u0026scale=2\u0026format=jpeg\u0026maptype=roadmap\u0026key=AIzaSyBkACm-LQkoSfsTO5_XAzBVZE9-JQzcNkg",
|
||||
"Pickup": true,
|
||||
"Dropoff": false
|
||||
},
|
||||
"Clients": {
|
||||
"broc": {
|
||||
"States": [
|
||||
|
|
@ -12,7 +17,7 @@
|
|||
"IDs": {
|
||||
"Matrix": "@belandbroc:matrix.org"
|
||||
},
|
||||
"PauseUntil": 5641848000
|
||||
"PauseUntil": 5642107200
|
||||
},
|
||||
"caleb": {
|
||||
"States": [
|
||||
|
|
@ -30,10 +35,6 @@
|
|||
"IDs": {
|
||||
"Matrix": "@belandbroc:matrix.org"
|
||||
},
|
||||
"Maps": {
|
||||
"Pickup": true,
|
||||
"Dropoff": true
|
||||
},
|
||||
"PauseUntil": -62135596800
|
||||
}
|
||||
},
|
||||
|
|
@ -59,8 +60,5 @@
|
|||
"Username": "noeasyrunstrucking@gmail.com",
|
||||
"Password": "thumper123"
|
||||
}
|
||||
},
|
||||
"Maps": {
|
||||
"URIFormat": "https://maps.googleapis.com/maps/api/staticmap?center=%s&markers=label=A|%s&zoom=5&size=250x250&scale=2&format=jpeg&maptype=roadmap&key=AIzaSyBkACm-LQkoSfsTO5_XAzBVZE9-JQzcNkg"
|
||||
}
|
||||
}
|
||||
|
|
@ -17,6 +17,8 @@ type Config struct {
|
|||
}
|
||||
Maps struct {
|
||||
URIFormat string
|
||||
Pickup bool
|
||||
Dropoff bool
|
||||
}
|
||||
Clients map[string]Client
|
||||
Storage []string
|
||||
|
|
@ -50,10 +52,6 @@ type Client struct {
|
|||
IDs struct {
|
||||
Matrix string
|
||||
}
|
||||
Maps struct {
|
||||
Pickup bool
|
||||
Dropoff bool
|
||||
}
|
||||
PauseUntil Time
|
||||
}
|
||||
|
||||
|
|
|
|||
20
main.go
20
main.go
|
|
@ -269,7 +269,23 @@ func dropBanlistJobs(jobs []broker.Job) ([]broker.Job, error) {
|
|||
|
||||
func sendJob(job broker.Job) error {
|
||||
sender := message.NewMatrix()
|
||||
return sender.Send(job.FormatMultilineText())
|
||||
payload := job.FormatMultilineText()
|
||||
if len(payload) == 0 {
|
||||
return nil
|
||||
}
|
||||
if err := sender.Send(payload); err != nil {
|
||||
return err
|
||||
}
|
||||
maps := config.Get().Maps
|
||||
pickup := fmt.Sprintf("%s, %s", job.Pickup.City, job.Pickup.State)
|
||||
dropoff := fmt.Sprintf("%s, %s", job.Dropoff.City, job.Dropoff.State)
|
||||
if maps.Pickup {
|
||||
sender.SendImage(fmt.Sprintf(maps.URIFormat, pickup, pickup))
|
||||
}
|
||||
if maps.Dropoff {
|
||||
sender.SendImage(fmt.Sprintf(maps.URIFormat, dropoff, dropoff))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func sendNewStates(client string, states []config.State) error {
|
||||
|
|
@ -279,5 +295,5 @@ func sendNewStates(client string, states []config.State) error {
|
|||
|
||||
func sendNewPause(client string, pause time.Time) error {
|
||||
sender := message.NewMatrix()
|
||||
return sender.Send(fmt.Sprintf("%s: not searching for loads until %s", client, pause.Format("2006-01-02")))
|
||||
return sender.Send(fmt.Sprintf("%s: only searching for loads on and after %s", client, pause.Format("2006-01-02")))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
package message
|
||||
|
|
@ -103,3 +103,16 @@ func (m Matrix) Send(text string) error {
|
|||
_, err = c.SendText(m.room, text)
|
||||
return err
|
||||
}
|
||||
|
||||
func (m Matrix) SendImage(uri string) error {
|
||||
if m.mock {
|
||||
log.Printf("matrix.SendImage(%s)", uri)
|
||||
return nil
|
||||
}
|
||||
c, err := m.getclient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = c.SendImage(m.room, "", uri)
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
todo:
|
||||
- convert pauseuntil to search results only on and after target date
|
||||
- todo: maps of to+from to get location within state via api
|
||||
details: |
|
||||
curl 'https://maps.googleapis.com/maps/api/staticmap?center=Advance,NC&markers=label=A|Advance,NC&zoom=5&size=250x250&scale=2&format=jpeg&maptype=roadmap&key=AIzaSyBkACm-LQkoSfsTO5_XAzBVZE9-JQzcNkg' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0' -H 'Accept: image/avif,image/webp,*/*' -H 'Accept-Language: en-US,en;q=0.5' -H 'Accept-Encoding: gzip, deflate, br' -H 'DNT: 1' -H 'Alt-Used: maps.googleapis.com' -H 'Connection: keep-alive' -H 'Sec-Fetch-Dest: image' -H 'Sec-Fetch-Mode: no-cors' -H 'Sec-Fetch-Site: cross-site' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' -H 'TE: trailers' > whatever.jpg; open whatever.jpg~/Go/src/local/truckstop
|
||||
|
|
|
|||
Loading…
Reference in New Issue