parent
bfc7aedecf
commit
b515143fc6
24
config.json
24
config.json
|
|
@ -4,15 +4,27 @@
|
|||
"OK": "6h0m0s..6h0m0s",
|
||||
"Error": "6h0m0s..6h0m0s"
|
||||
},
|
||||
"Images": {
|
||||
"ClientID": "d9ac7cabe813d10",
|
||||
"ClientSecret": "9d0b3d82800b30ca88f595d3bcd6985f627d7d82",
|
||||
"RefreshToken": "171417741bf762b99b0b9f9137491b7a69874a77",
|
||||
"AccessToken": "e63db98f92d2db7ac7f56914a2030c889b378e9b",
|
||||
"RefreshURI": "https://api.imgur.com/oauth2/token",
|
||||
"RefreshFormat": "refresh_token=%s&client_id=%s&client_secret=%s&grant_type=refresh_token",
|
||||
"RefreshMethod": "POST",
|
||||
"UploadURI": "https://api.imgur.com/3/image",
|
||||
"UploadMethod": "POST"
|
||||
},
|
||||
"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",
|
||||
"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,
|
||||
"Dropoff": false
|
||||
"Dropoff": true
|
||||
},
|
||||
"Clients": {
|
||||
"broc": {
|
||||
"States": [
|
||||
"OH"
|
||||
"FL",
|
||||
"NC"
|
||||
],
|
||||
"IDs": {
|
||||
"Matrix": "@belandbroc:matrix.org"
|
||||
|
|
@ -21,7 +33,7 @@
|
|||
},
|
||||
"caleb": {
|
||||
"States": [
|
||||
"OH"
|
||||
"FL"
|
||||
],
|
||||
"IDs": {
|
||||
"Matrix": "@belandbroc:matrix.org"
|
||||
|
|
@ -44,12 +56,12 @@
|
|||
"Message": {
|
||||
"Matrix": {
|
||||
"ReceiveEnabled": true,
|
||||
"Mock": true,
|
||||
"Mock": false,
|
||||
"Homeserver": "https://matrix-client.matrix.org",
|
||||
"Username": "@breellocaldev:matrix.org",
|
||||
"Token": "syt_YnJlZWxsb2NhbGRldg_HTewKMMePdEcLvceAKEz_2fHsHa",
|
||||
"Device": "TGNIOGKATZ",
|
||||
"Room": "!rMvyKroCAJMRqFwTwC:matrix.org"
|
||||
"Room": "!ySKxwGHQPzPfVAldfJ:matrix.org"
|
||||
}
|
||||
},
|
||||
"Once": true,
|
||||
|
|
|
|||
|
|
@ -15,6 +15,17 @@ type Config struct {
|
|||
OK Duration
|
||||
Error Duration
|
||||
}
|
||||
Images struct {
|
||||
ClientID string
|
||||
ClientSecret string
|
||||
RefreshToken string
|
||||
AccessToken string
|
||||
RefreshURI string
|
||||
RefreshFormat string
|
||||
RefreshMethod string
|
||||
UploadURI string
|
||||
UploadMethod string
|
||||
}
|
||||
Maps struct {
|
||||
URIFormat string
|
||||
Pickup bool
|
||||
|
|
|
|||
16
main.go
16
main.go
|
|
@ -277,13 +277,21 @@ func sendJob(job broker.Job) error {
|
|||
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))
|
||||
pickup := fmt.Sprintf("%s,%s", job.Pickup.City, job.Pickup.State)
|
||||
uri := fmt.Sprintf(maps.URIFormat, pickup, pickup)
|
||||
log.Printf("sending pickup image: %s", uri)
|
||||
if err := sender.SendImage(uri); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if maps.Dropoff {
|
||||
sender.SendImage(fmt.Sprintf(maps.URIFormat, dropoff, dropoff))
|
||||
dropoff := fmt.Sprintf("%s,%s", 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 {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
package message
|
||||
|
|
@ -2,8 +2,10 @@ package message
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"local/truckstop/config"
|
||||
"log"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
|
@ -109,10 +111,24 @@ func (m Matrix) SendImage(uri string) error {
|
|||
log.Printf("matrix.SendImage(%s)", uri)
|
||||
return nil
|
||||
}
|
||||
response, err := http.Get(uri)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
b, err := ioutil.ReadAll(response.Body)
|
||||
response.Body.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
publicURI, err := UploadImage(b)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
c, err := m.getclient()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = c.SendImage(m.room, "", uri)
|
||||
resp, err := c.SendImage(m.room, "img", publicURI)
|
||||
log.Printf("sent image %s => %s: %+v", uri, publicURI, resp)
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
|
|
@ -19,6 +19,11 @@ todo:
|
|||
- setup ma on element !!fluffychat
|
||||
- set up copy for caleb, broc
|
||||
done:
|
||||
- todo: upload g map to imgur
|
||||
details: |
|
||||
w oath d9ac7cabe813d10 9d0b3d82800b30ca88f595d3bcd6985f627d7d82
|
||||
Authorization: Client-ID d9ac7cabe813d10
|
||||
Authorization: Bearer YOUR_ACCESS_TOKEN
|
||||
- quiet hours
|
||||
- "@caleb commands: args"
|
||||
- accept after date
|
||||
|
|
|
|||
Loading…
Reference in New Issue