parent
cc379c52ad
commit
48da446e83
|
|
@ -16,8 +16,11 @@
|
|||
"UploadMethod": "POST"
|
||||
},
|
||||
"Maps": {
|
||||
"DirectionsURIFormat": "https://maps.googleapis.com/maps/api/directions/json?origin=%s\u0026destination=%s\u0026mode=driving\u0026key=AIzaSyBkACm-LQkoSfsTO5_XAzBVZE9-JQzcNkg",
|
||||
"PathedURIFormat": "https://maps.googleapis.com/maps/api/staticmap?size=250x250\u0026path=%s\u0026format=jpeg\u0026maptype=roadmap\u0026key=AIzaSyBkACm-LQkoSfsTO5_XAzBVZE9-JQzcNkg\u0026size=250x250\u0026markers=%s|%s\u0026zoom=5",
|
||||
"URIFormat": "https://maps.googleapis.com/maps/api/staticmap?center=%s\u0026markers=label=A|%s\u0026zoom=5\u0026size=250x250\u0026scale=1\u0026format=jpeg\u0026maptype=roadmap\u0026key=AIzaSyBkACm-LQkoSfsTO5_XAzBVZE9-JQzcNkg",
|
||||
"Pickup": true,
|
||||
"Pathed": true,
|
||||
"Pickup": false,
|
||||
"Dropoff": false
|
||||
},
|
||||
"Clients": {
|
||||
|
|
@ -58,7 +61,7 @@
|
|||
"Matrix": {
|
||||
"ReceiveEnabled": true,
|
||||
"Mock": false,
|
||||
"Continuation": "210",
|
||||
"Continuation": "602",
|
||||
"Homeserver": "https://m.bltrucks.top",
|
||||
"Username": "@bot.m.bltrucks.top",
|
||||
"Token": "mvDWB96KXMF8XhOam8EC5XVdQvSEw0CDeClcSWocBcYkwZX3FPNWZ5uOnQk2EmT1cjpzfeuD7gDYPPjOuyZlI3bE9TE35UjNOlZgi0Tugm25s91iVsbIF6kMZsCIhVMSmEf6w3jxX6wQYOWvmDZ4mu6f5c8wr221EMDcOpEzQV09d1zuBSWgKLBgjqAkYHJZ5dTRIWpEDpPgujhOFZa2ld1HiAOxrJKlIrlfDBN0CUsTlGOGplujDAr4VtpFzNRS",
|
||||
|
|
|
|||
|
|
@ -27,7 +27,10 @@ type Config struct {
|
|||
UploadMethod string
|
||||
}
|
||||
Maps struct {
|
||||
DirectionsURIFormat string
|
||||
PathedURIFormat string
|
||||
URIFormat string
|
||||
Pathed bool
|
||||
Pickup bool
|
||||
Dropoff bool
|
||||
}
|
||||
|
|
|
|||
44
main.go
44
main.go
|
|
@ -9,6 +9,7 @@ import (
|
|||
"local/truckstop/config"
|
||||
"local/truckstop/message"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"sort"
|
||||
|
|
@ -337,8 +338,48 @@ func sendJob(job broker.Job) (bool, error) {
|
|||
return false, err
|
||||
}
|
||||
maps := config.Get().Maps
|
||||
if maps.Pickup {
|
||||
pickup := fmt.Sprintf("%s,%s", url.QueryEscape(job.Pickup.City), job.Pickup.State)
|
||||
dropoff := fmt.Sprintf("%s,%s", url.QueryEscape(job.Dropoff.City), job.Dropoff.State)
|
||||
if maps.Pathed {
|
||||
directionsURI := fmt.Sprintf(maps.DirectionsURIFormat, pickup, dropoff)
|
||||
resp, err := http.Get(directionsURI)
|
||||
if err != nil {
|
||||
return true, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return true, fmt.Errorf("bad status getting path: %d", resp.StatusCode)
|
||||
}
|
||||
var directionsResp struct {
|
||||
Routes []struct {
|
||||
Legs []struct {
|
||||
Steps []struct {
|
||||
StartLocation struct {
|
||||
Lat float32 `json:"lat"`
|
||||
Lng float32 `json:"lng"`
|
||||
} `json:"start_location"`
|
||||
} `json:"steps"`
|
||||
} `json:"legs"`
|
||||
} `json:"routes"`
|
||||
}
|
||||
if err := json.NewDecoder(resp.Body).Decode(&directionsResp); err != nil {
|
||||
return true, err
|
||||
}
|
||||
if len(directionsResp.Routes) < 1 || len(directionsResp.Routes[0].Legs) < 1 || len(directionsResp.Routes[0].Legs[0].Steps) < 1 {
|
||||
} else {
|
||||
latLngPath := make([]string, 0)
|
||||
for _, v := range directionsResp.Routes[0].Legs[0].Steps {
|
||||
latLngPath = append(latLngPath, fmt.Sprintf("%.9f,%.9f", v.StartLocation.Lat, v.StartLocation.Lng))
|
||||
}
|
||||
pathQuery := strings.Join(latLngPath, "|")
|
||||
uri := fmt.Sprintf(maps.PathedURIFormat, pathQuery, pickup, dropoff)
|
||||
log.Printf("sending pathed image: %s", uri)
|
||||
if err := sender.SendImage(uri); err != nil {
|
||||
return true, err
|
||||
}
|
||||
}
|
||||
}
|
||||
if maps.Pickup {
|
||||
uri := fmt.Sprintf(maps.URIFormat, pickup, pickup)
|
||||
log.Printf("sending pickup image: %s", uri)
|
||||
if err := sender.SendImage(uri); err != nil {
|
||||
|
|
@ -346,7 +387,6 @@ func sendJob(job broker.Job) (bool, error) {
|
|||
}
|
||||
}
|
||||
if maps.Dropoff {
|
||||
dropoff := fmt.Sprintf("%s,%s", url.QueryEscape(job.Dropoff.City), job.Dropoff.State)
|
||||
uri := fmt.Sprintf(maps.URIFormat, dropoff, dropoff)
|
||||
log.Printf("sending dropoff image: %s", uri)
|
||||
if err := sender.SendImage(uri); err != nil {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
#! /bin/bash
|
||||
|
||||
poly="${poly:-"$(curl 'https://maps.googleapis.com/maps/api/directions/json?origin=advance,nc&destination=winston-salem,nc&mode=driving&key=AIzaSyBkACm-LQkoSfsTO5_XAzBVZE9-JQzcNkg' | jq -c .routes[0].legs[0].steps[] | jq -c .start_location | jq -r '(.lat|tostring) + "," + (.lng|tostring)' | tr '\n' '|' | sed 's/.$//')"}"; curl "https://maps.googleapis.com/maps/api/staticmap?size=250x250&path=$(urlencode "$poly")&format=jpeg&maptype=roadmap&key=AIzaSyBkACm-LQkoSfsTO5_XAzBVZE9-JQzcNkg&size=600x400&sensor=false" > /tmp/f.jpg ; open /tmp/f.jpg
|
||||
|
|
@ -1,9 +1,8 @@
|
|||
todo:
|
||||
- write-as for clients so ma can write to pa by default
|
||||
- link to view more
|
||||
- map with to-from line
|
||||
- continuation is garbo, but I can still do better client side to avoid get-set high level
|
||||
- todo: details from ntg: stophours for pickup, appointmenttime/facitlyhours for dest
|
||||
- todo: details from ntg; stophours for pickup, appointmenttime/facitlyhours for dest
|
||||
details: |
|
||||
curl 'https://ntgvision.com/api/v1/load/LoadDetails?loadId=5088453' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0' -H 'Accept: application/json, text/plain, */*' -H 'Accept-Language: en-US,en;q=0.5' -H 'Accept-Encoding: gzip, deflate, br' -H 'Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMzgyMSIsInVuaXF1ZV9uYW1lIjoiYmlyZGNvbXBhbnlsb2dpc3RpY3NAZ21haWwuY29tIiwianRpIjoiYTFiMjkxM2YtN2RjZS00ZDQ0LWEzMDYtMTRjMTBlYjQ2MmE1IiwiaWF0IjoiMS8xMy8yMDIyIDI6MTE6NTUgUE0iLCJudGd2Um9sZSI6IkNhcnJpZXJBcHByb3ZlZCIsImxvY2tVc2VyIjoiRmFsc2UiLCJvdmVycmlkZUJsYWNrbGlzdCI6IkZhbHNlIiwic2hvd1JhdGVzIjoiRmFsc2UiLCJ1c2VyQ2FycmllcnMiOiIxMTQxOTMiLCJvdHJVc2VyIjoiRmFsc2UiLCJuYmYiOjE2NDIwODMxMTUsImV4cCI6MTY0MjE2NTkxNSwiaXNzIjoiTlRHIFNlY3VyaXR5IFRva2VuIFNlcnZpY2UiLCJhdWQiOiJOVEcifQ.eDE2Jfok79b7oD1deP_00h9g8zZ3AnY60McnJ1hfS-8YJ12L3Bl-CJeN0eBos0aj2FXHv5MrqOJ6MFCaatqjIddPJl2MvtSByGUCLBzih67O20mkCowCmZfGjSnKvUu7DHFxjzo_y4_a3cjjGPYNc2LSCVJxV9NYzSXIuXG3WvXeE3dv8ml23bJFFhMWZzhSAfWBOW4kR61sibS6BpRD8dpkKoqUfXInq_7o8jz9_PsEhPBdJydqbXwg8ifQHkaPNAojsIr2rnJ3Tf_iQpom-6oAEUAOd2D3fK1XuWtRrysnD8s41YDthmqKpni2WOk72L-sKzRxD4KX2t_gyEb3Fw' -H 'DNT: 1' -H 'Connection: keep-alive' -H 'Cookie: cookiesession1=678A3E1398901234BCDEFGHIJKLMA492; _uiq_id.711119701.3d83=516d3e744ebe2d9a.1641792415.0.1642083653..; NTGAuthToken=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMzgyMSIsInVuaXF1ZV9uYW1lIjoiYmlyZGNvbXBhbnlsb2dpc3RpY3NAZ21haWwuY29tIiwianRpIjoiYTFiMjkxM2YtN2RjZS00ZDQ0LWEzMDYtMTRjMTBlYjQ2MmE1IiwiaWF0IjoiMS8xMy8yMDIyIDI6MTE6NTUgUE0iLCJudGd2Um9sZSI6IkNhcnJpZXJBcHByb3ZlZCIsImxvY2tVc2VyIjoiRmFsc2UiLCJvdmVycmlkZUJsYWNrbGlzdCI6IkZhbHNlIiwic2hvd1JhdGVzIjoiRmFsc2UiLCJ1c2VyQ2FycmllcnMiOiIxMTQxOTMiLCJvdHJVc2VyIjoiRmFsc2UiLCJuYmYiOjE2NDIwODMxMTUsImV4cCI6MTY0MjE2NTkxNSwiaXNzIjoiTlRHIFNlY3VyaXR5IFRva2VuIFNlcnZpY2UiLCJhdWQiOiJOVEcifQ.eDE2Jfok79b7oD1deP_00h9g8zZ3AnY60McnJ1hfS-8YJ12L3Bl-CJeN0eBos0aj2FXHv5MrqOJ6MFCaatqjIddPJl2MvtSByGUCLBzih67O20mkCowCmZfGjSnKvUu7DHFxjzo_y4_a3cjjGPYNc2LSCVJxV9NYzSXIuXG3WvXeE3dv8ml23bJFFhMWZzhSAfWBOW4kR61sibS6BpRD8dpkKoqUfXInq_7o8jz9_PsEhPBdJydqbXwg8ifQHkaPNAojsIr2rnJ3Tf_iQpom-6oAEUAOd2D3fK1XuWtRrysnD8s41YDthmqKpni2WOk72L-sKzRxD4KX2t_gyEb3Fw' -H 'Sec-Fetch-Dest: empty' -H 'Sec-Fetch-Mode: cors' -H 'Sec-Fetch-Site: same-origin' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache'
|
||||
{"headerSummary":"Washington, NC to Abilene, TX","loadId":5088453,"miles":1481,"weight":6000,"temp":null,"equipment":"Str Truck W/ Lift Gate","categoryName":"Lighting / Lighting Fixtures","categoryLabel":"Product Category","cargoInformation":["Store Fixtures - 6000 lbs"],"loadRequirements":["Straight Truck with lift gate required"],"stopInfos":[{"loadInfoIds":[5431607],"stopDateTime":"0001-01-01T00:00:00","isPickup":true,"location":"Washington, NC","stopDate":"Friday, 01/14/22","stopHours":"10:00 - 12:00","appointmentTime":"","appointmentType":"FCFS","instructions":"***LIFTGATE, PALLET JACK, DRIVER ASSIST***--MUST DELIVER ONLY ON APPT TIME-- CANNOT DELIVER EARLY OR LATE \r\n","isDropTrailer":false,"shipperName":"IDX NORTH CAROLINA","processedStopDate":""},{"loadInfoIds":[5431607],"stopDateTime":"0001-01-01T00:00:00","isPickup":false,"location":"Abilene, TX","stopDate":"Monday, 01/17/22","stopHours":"09:00 - 10:00","appointmentTime":"09:00","appointmentType":"APPT","instructions":"***LIFTGATE, PALLET JACK, DRIVER ASSIST***--MUST DELIVER ONLY ON APPT TIME-- CANNOT DELIVER EARLY OR LATE \r\n","isDropTrailer":false,"shipperName":"hibbett sports","processedStopDate":""}],"drayStopInfos":null,"rateInfo":null,"isDray":false,"equipmentGroupId":8,"totalCarrierRate":2600.00,"payUpTo":2700.00,"firstLoadInfoId":5431607,"loadStatus":"ACTIVE","hasBlockingAlert":false,"customerLoadBlocked":false,"canSeeRate":false,"canBookNow":false,"canBidNow":true,"buttonData":{"useBidDialog":false,"lastBidAmount":null,"remainingBids":1,"carrierPhoneNumber":null,"carrierPhoneExtension":null},"stopData":[{"addr":"IDX NORTH CAROLINA","city":"Washington","state":"NC","zip":"27889"},{"addr":"hibbett sports","city":"Abilene","state":"TX","zip":"79606"}]}
|
||||
|
|
@ -23,6 +22,7 @@ todo:
|
|||
- banlist criteria like vendors, brokers, metadata
|
||||
- set up copy for caleb, broc
|
||||
done:
|
||||
- map with to-from line
|
||||
- TO CONFLUENT.RS OR W/E
|
||||
- rm get-set stuff for matrix now that it has continuation
|
||||
- setup ma on element !!fluffychat
|
||||
|
|
|
|||
Loading…
Reference in New Issue