Compare commits
35 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
373e9ff3c3 | ||
|
|
d3fff1519b | ||
|
|
2b6acc51fb | ||
|
|
fade4467d6 | ||
|
|
c8800c010e | ||
|
|
266ccb5f98 | ||
|
|
1cc082083c | ||
|
|
5170e96f7e | ||
|
|
826278fa78 | ||
|
|
111fe0ad6d | ||
|
|
72a474b50a | ||
|
|
de80f11392 | ||
|
|
d26d043f2e | ||
|
|
b6dbe25a48 | ||
|
|
09e87c66d8 | ||
|
|
75409a11b9 | ||
|
|
3213c21c7e | ||
|
|
b515143fc6 | ||
|
|
bfc7aedecf | ||
|
|
cf9d6d83c6 | ||
|
|
1334295204 | ||
|
|
3423e5f76a | ||
|
|
7ec4ce79dd | ||
|
|
9d855e0f30 | ||
|
|
f90ec3917b | ||
|
|
8f681c7927 | ||
|
|
4ffc6bba8c | ||
|
|
9840be93f6 | ||
|
|
95bb4de13a | ||
|
|
d361c2164f | ||
|
|
b54be3c32c | ||
|
|
e546034c26 | ||
|
|
5a4bcecac7 | ||
|
|
6569631928 | ||
|
|
e963162303 |
@@ -1,7 +1,28 @@
|
|||||||
package broker
|
package broker
|
||||||
|
|
||||||
import "local/truckstop/config"
|
import (
|
||||||
|
"context"
|
||||||
|
"local/truckstop/config"
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"golang.org/x/time/rate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// once per minute
|
||||||
|
var authlimiter = rate.NewLimiter(rate.Limit(1.0/60.0), 1)
|
||||||
|
|
||||||
|
// thrice per minute
|
||||||
|
var limiter = rate.NewLimiter(rate.Limit(1.0/20.0), 1)
|
||||||
|
|
||||||
type Broker interface {
|
type Broker interface {
|
||||||
Search([]config.State) ([]Job, error)
|
Search([]config.State) ([]Job, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func do(r *http.Request) (*http.Response, error) {
|
||||||
|
limiter.Wait(context.Background())
|
||||||
|
if strings.Contains(strings.ToLower(r.URL.Path), "login") {
|
||||||
|
authlimiter.Wait(context.Background())
|
||||||
|
}
|
||||||
|
return http.DefaultClient.Do(r)
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package broker
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"local/truckstop/config"
|
"local/truckstop/config"
|
||||||
|
"log"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -37,15 +39,29 @@ func (j JobLocation) String() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (j Job) FormatMultilineText() string {
|
func (j Job) FormatMultilineText() string {
|
||||||
return fmt.Sprintf(
|
foo := func(client string) string {
|
||||||
"--- %s: %s => %s ---\nPickup: %s\nDropoff: %s\nNotes: %d lbs, %d miles, %s",
|
return fmt.Sprintf(
|
||||||
config.Get().Name,
|
"--- %s: %s => %s ---\nPickup: %s\nDropoff: %s\nNotes: %d lbs, %d miles, %s",
|
||||||
j.Pickup.State,
|
client,
|
||||||
j.Dropoff.State,
|
j.Pickup.State,
|
||||||
j.Pickup.String(),
|
j.Dropoff.State,
|
||||||
j.Dropoff.String(),
|
j.Pickup.String(),
|
||||||
j.Weight,
|
j.Dropoff.String(),
|
||||||
j.Miles,
|
j.Weight,
|
||||||
j.Meta,
|
j.Miles,
|
||||||
)
|
j.Meta,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
out := ""
|
||||||
|
clients := config.Clients(j.Pickup.Date)
|
||||||
|
for k := range clients {
|
||||||
|
log.Printf("job multiline: %+v contains %s then use %v", clients[k].States, j.Pickup.State, k)
|
||||||
|
if strings.Contains(fmt.Sprint(clients[k].States), j.Pickup.State) {
|
||||||
|
if len(out) > 0 {
|
||||||
|
out += "\n\n"
|
||||||
|
}
|
||||||
|
out += foo(k)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -100,7 +100,6 @@ func (ntg NTGVision) search(states []config.State) (io.ReadCloser, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ntg NTGVision) refreshAuth() error {
|
func (ntg NTGVision) refreshAuth() error {
|
||||||
time.Sleep(time.Minute * 2) // TODO
|
|
||||||
b, _ := json.Marshal(map[string]string{
|
b, _ := json.Marshal(map[string]string{
|
||||||
"username": config.Get().Brokers.NTG.Username,
|
"username": config.Get().Brokers.NTG.Username,
|
||||||
"password": config.Get().Brokers.NTG.Password,
|
"password": config.Get().Brokers.NTG.Password,
|
||||||
@@ -110,7 +109,7 @@ func (ntg NTGVision) refreshAuth() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
setNTGHeaders(request)
|
setNTGHeaders(request)
|
||||||
resp, err := http.DefaultClient.Do(request)
|
resp, err := do(request)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -139,8 +138,7 @@ func (ntg NTGVision) _search(states []config.State) (io.ReadCloser, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
c := http.Client{Timeout: time.Minute}
|
resp, err := do(request)
|
||||||
resp, err := c.Do(request)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
6
broker/testdata/ntgvision_response.json
vendored
6
broker/testdata/ntgvision_response.json
vendored
@@ -19,11 +19,11 @@
|
|||||||
{
|
{
|
||||||
"id": 4650338,
|
"id": 4650338,
|
||||||
"sDate": "01/12/22",
|
"sDate": "01/12/22",
|
||||||
"sCity": "Somewhere",
|
"sCity": "Advance",
|
||||||
"sState": "OH",
|
"sState": "NC",
|
||||||
"sdh": null,
|
"sdh": null,
|
||||||
"cDate": "01/13/22",
|
"cDate": "01/13/22",
|
||||||
"cCity": "SomewhereElse",
|
"cCity": "Atlanta",
|
||||||
"cState": "GA",
|
"cState": "GA",
|
||||||
"cdh": null,
|
"cdh": null,
|
||||||
"stopCnt": 2,
|
"stopCnt": 2,
|
||||||
|
|||||||
89
config.json
89
config.json
@@ -1,29 +1,77 @@
|
|||||||
{
|
{
|
||||||
"Name": "pa",
|
|
||||||
"Interval": {
|
"Interval": {
|
||||||
"Email": "10s..30s",
|
"Input": "15s..20s",
|
||||||
"OK": "6h0m0s..6h0m0s",
|
"OK": "6h0m0s..6h0m0s",
|
||||||
"Error": "6h0m0s..6h0m0s"
|
"Error": "6h0m0s..6h0m0s"
|
||||||
},
|
},
|
||||||
"States": [
|
"Images": {
|
||||||
"FL",
|
"ClientID": "d9ac7cabe813d10",
|
||||||
"GA",
|
"ClientSecret": "9d0b3d82800b30ca88f595d3bcd6985f627d7d82",
|
||||||
"NC"
|
"RefreshToken": "171417741bf762b99b0b9f9137491b7a69874a77",
|
||||||
],
|
"AccessToken": "e63db98f92d2db7ac7f56914a2030c889b378e9b",
|
||||||
|
"RefreshURI": "https://api.imgur.com/oauth2/token",
|
||||||
|
"RefreshFormat": "refresh_token=%s\u0026client_id=%s\u0026client_secret=%s\u0026grant_type=refresh_token",
|
||||||
|
"RefreshMethod": "POST",
|
||||||
|
"UploadURI": "https://api.imgur.com/3/image?name=something.jpeg",
|
||||||
|
"UploadMethod": "POST"
|
||||||
|
},
|
||||||
|
"Maps": {
|
||||||
|
"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
|
||||||
|
},
|
||||||
|
"Clients": {
|
||||||
|
"bel": {
|
||||||
|
"States": [
|
||||||
|
"NC"
|
||||||
|
],
|
||||||
|
"IDs": {
|
||||||
|
"Matrix": "@bel:synapse.home.blapointe.com"
|
||||||
|
},
|
||||||
|
"Available": 1612328400
|
||||||
|
},
|
||||||
|
"broc": {
|
||||||
|
"States": [
|
||||||
|
"FL",
|
||||||
|
"NC"
|
||||||
|
],
|
||||||
|
"IDs": {
|
||||||
|
"Matrix": "@belandbroc:matrix.org"
|
||||||
|
},
|
||||||
|
"Available": 5642452800
|
||||||
|
},
|
||||||
|
"caleb": {
|
||||||
|
"States": [
|
||||||
|
"FL"
|
||||||
|
],
|
||||||
|
"IDs": {
|
||||||
|
"Matrix": "@belandbroc:matrix.org"
|
||||||
|
},
|
||||||
|
"Available": -62135596800
|
||||||
|
},
|
||||||
|
"pa": {
|
||||||
|
"States": [
|
||||||
|
"NC"
|
||||||
|
],
|
||||||
|
"IDs": {
|
||||||
|
"Matrix": "@belandbroc:matrix.org"
|
||||||
|
},
|
||||||
|
"Available": -62135596800
|
||||||
|
}
|
||||||
|
},
|
||||||
"Storage": [
|
"Storage": [
|
||||||
"map"
|
"files",
|
||||||
|
"/tmp/play"
|
||||||
],
|
],
|
||||||
"Client": "breellocaldev@gmail.com",
|
|
||||||
"Message": {
|
"Message": {
|
||||||
"Matrix": {
|
"Matrix": {
|
||||||
"ReceiveEnabled": true,
|
"ReceiveEnabled": true,
|
||||||
"Client": "@belandbroc:matrix.org",
|
"Mock": false,
|
||||||
"Mock": true,
|
"Homeserver": "https://synapse.home.blapointe.com",
|
||||||
"Homeserver": "https://matrix-client.matrix.org",
|
"Username": "@bel:synapse.home.blapointe.com",
|
||||||
"Username": "@breellocaldev:matrix.org",
|
"Token": "MDAyOGxvY2F0aW9uIHN5bmFwc2UuaG9tZS5ibGFwb2ludGUuY29tCjAwMTNpZGVudGlmaWVyIGtleQowMDEwY2lkIGdlbiA9IDEKMDAzMmNpZCB1c2VyX2lkID0gQGJlbDpzeW5hcHNlLmhvbWUuYmxhcG9pbnRlLmNvbQowMDE2Y2lkIHR5cGUgPSBhY2Nlc3MKMDAyMWNpZCBub25jZSA9IFpXTTtCaTNBODdtSTpsZkAKMDAyZnNpZ25hdHVyZSBX37kStY2wt_ftMfEYPfk1ADMJ6ZVfZsro9ic3weZ25Ao",
|
||||||
"Token": "syt_YnJlZWxsb2NhbGRldg_HTewKMMePdEcLvceAKEz_2fHsHa",
|
|
||||||
"Device": "TGNIOGKATZ",
|
"Device": "TGNIOGKATZ",
|
||||||
"Room": "!rMvyKroCAJMRqFwTwC:matrix.org"
|
"Room": "!WbawbZxHqnxxfhvcSj:synapse.home.blapointe.com"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Once": true,
|
"Once": true,
|
||||||
@@ -34,14 +82,5 @@
|
|||||||
"Username": "noeasyrunstrucking@gmail.com",
|
"Username": "noeasyrunstrucking@gmail.com",
|
||||||
"Password": "thumper123"
|
"Password": "thumper123"
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
"Emailer": {
|
|
||||||
"From": "breellocaldev@gmail.com",
|
|
||||||
"SMTP": "",
|
|
||||||
"POP3": "",
|
|
||||||
"IMAP": "imap.gmail.com:993",
|
|
||||||
"Password": "gojfkkfrkmtxzyro",
|
|
||||||
"Limit": 0
|
|
||||||
},
|
|
||||||
"EmailerEnabled": false
|
|
||||||
}
|
}
|
||||||
@@ -3,26 +3,39 @@ package config
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"local/sandbox/contact/contact"
|
|
||||||
"local/storage"
|
"local/storage"
|
||||||
"os"
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Name string
|
|
||||||
Interval struct {
|
Interval struct {
|
||||||
Email Duration
|
Input Duration
|
||||||
OK Duration
|
OK Duration
|
||||||
Error Duration
|
Error Duration
|
||||||
}
|
}
|
||||||
States []State
|
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
|
||||||
|
Dropoff bool
|
||||||
|
}
|
||||||
|
Clients map[string]Client
|
||||||
Storage []string
|
Storage []string
|
||||||
Client string
|
|
||||||
Message struct {
|
Message struct {
|
||||||
Matrix struct {
|
Matrix struct {
|
||||||
ReceiveEnabled bool
|
ReceiveEnabled bool
|
||||||
Client string
|
|
||||||
Mock bool
|
Mock bool
|
||||||
Homeserver string
|
Homeserver string
|
||||||
Username string
|
Username string
|
||||||
@@ -40,13 +53,19 @@ type Config struct {
|
|||||||
Password string
|
Password string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Emailer contact.Emailer
|
|
||||||
EmailerEnabled bool
|
|
||||||
|
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
db storage.DB
|
db storage.DB
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Client struct {
|
||||||
|
States []State
|
||||||
|
IDs struct {
|
||||||
|
Matrix string
|
||||||
|
}
|
||||||
|
Available Time
|
||||||
|
}
|
||||||
|
|
||||||
var live Config
|
var live Config
|
||||||
|
|
||||||
func configPath() string {
|
func configPath() string {
|
||||||
@@ -57,6 +76,31 @@ func configPath() string {
|
|||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Clients(t time.Time) map[string]Client {
|
||||||
|
clients := Get().Clients
|
||||||
|
result := map[string]Client{}
|
||||||
|
for k := range clients {
|
||||||
|
if clients[k].Available.Get().IsZero() || t.After(clients[k].Available.Get()) {
|
||||||
|
result[k] = clients[k]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func AllStates() []State {
|
||||||
|
statem := map[State]struct{}{}
|
||||||
|
for _, v := range Clients(time.Now().Add(time.Hour * 24 * 365)) {
|
||||||
|
for _, state := range v.States {
|
||||||
|
statem[state] = struct{}{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
states := make([]State, 0, len(statem)+1)
|
||||||
|
for k := range statem {
|
||||||
|
states = append(states, k)
|
||||||
|
}
|
||||||
|
return states
|
||||||
|
}
|
||||||
|
|
||||||
func Refresh() error {
|
func Refresh() error {
|
||||||
b, err := ioutil.ReadFile(configPath())
|
b, err := ioutil.ReadFile(configPath())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ type Duration struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d Duration) Get() time.Duration {
|
func (d Duration) Get() time.Duration {
|
||||||
|
if d.least == 0 {
|
||||||
|
d.least = time.Second
|
||||||
|
}
|
||||||
jitter := d.most - d.least
|
jitter := d.most - d.least
|
||||||
if jitter >= time.Second {
|
if jitter >= time.Second {
|
||||||
jitter = time.Second * time.Duration(rand.Int()%int(jitter.Seconds()))
|
jitter = time.Second * time.Duration(rand.Int()%int(jitter.Seconds()))
|
||||||
|
|||||||
23
config/time.go
Normal file
23
config/time.go
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Time time.Time
|
||||||
|
|
||||||
|
func (t Time) Get() time.Time {
|
||||||
|
return time.Time(t)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t Time) MarshalJSON() ([]byte, error) {
|
||||||
|
return json.Marshal(t.Get().Unix())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *Time) UnmarshalJSON(b []byte) error {
|
||||||
|
var d int64
|
||||||
|
err := json.Unmarshal(b, &d)
|
||||||
|
*t = Time(time.Unix(d, 0))
|
||||||
|
return err
|
||||||
|
}
|
||||||
22
config/time_test.go
Normal file
22
config/time_test.go
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
package config
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestTimeMarshal(t *testing.T) {
|
||||||
|
now := time.Now()
|
||||||
|
nowt := Time(now)
|
||||||
|
var other Time
|
||||||
|
if b, err := json.Marshal(nowt); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
} else if len(b) < 5 {
|
||||||
|
t.Fatal(string(b))
|
||||||
|
} else if err := json.Unmarshal(b, &other); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
} else if now.Unix() != other.Get().Unix() {
|
||||||
|
t.Fatal(other.Get().Unix(), now.Unix())
|
||||||
|
}
|
||||||
|
}
|
||||||
228
main.go
228
main.go
@@ -4,12 +4,12 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"local/storage"
|
"local/storage"
|
||||||
"local/truckstop/broker"
|
"local/truckstop/broker"
|
||||||
"local/truckstop/config"
|
"local/truckstop/config"
|
||||||
"local/truckstop/message"
|
"local/truckstop/message"
|
||||||
"log"
|
"log"
|
||||||
|
"net/url"
|
||||||
"regexp"
|
"regexp"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -20,20 +20,19 @@ import (
|
|||||||
var stateFinder = regexp.MustCompile(`[A-Za-z]+`)
|
var stateFinder = regexp.MustCompile(`[A-Za-z]+`)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
if err := config.Refresh(); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
if err := matrixrecv(); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
lock := &sync.Mutex{}
|
lock := &sync.Mutex{}
|
||||||
go func() {
|
go func() {
|
||||||
for {
|
for {
|
||||||
time.Sleep(config.Get().Interval.Email.Get())
|
time.Sleep(config.Get().Interval.Input.Get())
|
||||||
if err := config.Refresh(); err != nil {
|
if err := config.Refresh(); err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
} else {
|
} else {
|
||||||
if config.Get().EmailerEnabled {
|
|
||||||
lock.Lock()
|
|
||||||
if err := email(); err != nil {
|
|
||||||
log.Print(err)
|
|
||||||
}
|
|
||||||
lock.Unlock()
|
|
||||||
}
|
|
||||||
if config.Get().Message.Matrix.ReceiveEnabled {
|
if config.Get().Message.Matrix.ReceiveEnabled {
|
||||||
lock.Lock()
|
lock.Lock()
|
||||||
if err := matrixrecv(); err != nil {
|
if err := matrixrecv(); err != nil {
|
||||||
@@ -58,63 +57,151 @@ func matrixrecv() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
states := map[config.State]struct{}{}
|
func() {
|
||||||
for _, msg := range messages {
|
log.Printf("looking for help")
|
||||||
if len(states) > 0 {
|
printed := false
|
||||||
continue
|
for _, msg := range messages {
|
||||||
|
if !strings.HasPrefix(msg.Content, "!help") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
key := fmt.Sprintf("help_%d", msg.Timestamp.Unix())
|
||||||
|
db := config.Get().DB()
|
||||||
|
if !printed {
|
||||||
|
if _, err := db.Get(key); err == storage.ErrNotFound {
|
||||||
|
log.Printf("sending help")
|
||||||
|
help := fmt.Sprintf("commands:\n...`!help`...print this help\n...`!state nc NC nC Nc`...set states for self\n...`!available 2022-12-31`...set date self is available for work\n\nrun a command for someone else: `!state ga @caleb`")
|
||||||
|
if err := sender.Send(help); err != nil {
|
||||||
|
log.Printf("failed to send help: %v", err)
|
||||||
|
} else {
|
||||||
|
printed = true
|
||||||
|
if err := db.Set(key, []byte{'k'}); err != nil {
|
||||||
|
log.Printf("failed to mark help given @%s: %v", key, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err := db.Set(key, []byte{'k'}); err != nil {
|
||||||
|
log.Printf("failed to mark help given @%s: %v", key, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for _, state := range parseOutStates([]byte(msg)) {
|
}()
|
||||||
states[state] = struct{}{}
|
func() {
|
||||||
|
log.Printf("looking for states")
|
||||||
|
db := config.Get().DB()
|
||||||
|
states := map[string]map[config.State]struct{}{}
|
||||||
|
for _, msg := range messages {
|
||||||
|
key := fmt.Sprintf("states_%d", msg.Timestamp.Unix())
|
||||||
|
if !strings.HasPrefix(msg.Content, "!state") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if _, ok := states[msg.Sender]; ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if _, err := db.Get(key); err == storage.ErrNotFound {
|
||||||
|
states[msg.Sender] = map[config.State]struct{}{}
|
||||||
|
for _, state := range parseOutStates([]byte(msg.Content)) {
|
||||||
|
states[msg.Sender][state] = struct{}{}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err := db.Set(key, []byte{'k'}); err != nil {
|
||||||
|
log.Printf("failed to mark state gathered @%s: %v", key, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
setNewStates(states)
|
||||||
setNewStates(states)
|
}()
|
||||||
|
func() {
|
||||||
|
log.Printf("looking for pauses")
|
||||||
|
db := config.Get().DB()
|
||||||
|
pauses := map[string]time.Time{}
|
||||||
|
for _, msg := range messages {
|
||||||
|
key := fmt.Sprintf("pauses_%d", msg.Timestamp.Unix())
|
||||||
|
if !strings.HasPrefix(msg.Content, "!available ") {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if _, ok := pauses[msg.Sender]; ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if _, err := db.Get(key); err == storage.ErrNotFound {
|
||||||
|
t, err := time.ParseInLocation(
|
||||||
|
"2006-01-02",
|
||||||
|
strings.TrimSpace(strings.TrimPrefix(msg.Content, "!available ")),
|
||||||
|
time.Local,
|
||||||
|
)
|
||||||
|
if err == nil {
|
||||||
|
pauses[msg.Sender] = t
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err := db.Set(key, []byte{'k'}); err != nil {
|
||||||
|
log.Printf("failed to mark state gathered @%s: %v", key, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setNewPauses(pauses)
|
||||||
|
}()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func setNewStates(states map[config.State]struct{}) {
|
func setNewPauses(pauses map[string]time.Time) {
|
||||||
|
if len(pauses) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.Printf("set new pauses: %+v", pauses)
|
||||||
|
conf := *config.Get()
|
||||||
|
changed := map[string]time.Time{}
|
||||||
|
for client, pause := range pauses {
|
||||||
|
clientconf := conf.Clients[client]
|
||||||
|
if clientconf.Available.Get().Unix() == pause.Unix() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
clientconf.Available = config.Time(pause)
|
||||||
|
conf.Clients[client] = clientconf
|
||||||
|
changed[client] = pause
|
||||||
|
}
|
||||||
|
if len(changed) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.Printf("updating config new pauses: %+v", conf)
|
||||||
|
config.Set(conf)
|
||||||
|
for client, pause := range changed {
|
||||||
|
if err := sendNewPause(client, pause); err != nil {
|
||||||
|
log.Printf("failed to send new pause %s/%+v: %v", client, pause, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func setNewStates(states map[string]map[config.State]struct{}) {
|
||||||
if len(states) == 0 {
|
if len(states) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
newstates := []config.State{}
|
|
||||||
for k := range states {
|
|
||||||
newstates = append(newstates, k)
|
|
||||||
}
|
|
||||||
sort.Slice(newstates, func(i, j int) bool {
|
|
||||||
return newstates[i] < newstates[j]
|
|
||||||
})
|
|
||||||
conf := *config.Get()
|
conf := *config.Get()
|
||||||
if fmt.Sprint(newstates) == fmt.Sprint(conf.States) {
|
changed := map[string][]config.State{}
|
||||||
|
for client, clientStates := range states {
|
||||||
|
newstates := []config.State{}
|
||||||
|
for k := range clientStates {
|
||||||
|
newstates = append(newstates, k)
|
||||||
|
}
|
||||||
|
sort.Slice(newstates, func(i, j int) bool {
|
||||||
|
return newstates[i] < newstates[j]
|
||||||
|
})
|
||||||
|
clientconf := conf.Clients[client]
|
||||||
|
if fmt.Sprint(newstates) == fmt.Sprint(clientconf.States) {
|
||||||
|
message.NewMatrix().Send(fmt.Sprintf("%s: still searching for %+v", client, newstates))
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
clientconf.States = newstates
|
||||||
|
conf.Clients[client] = clientconf
|
||||||
|
changed[client] = newstates
|
||||||
|
}
|
||||||
|
if len(changed) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
conf.States = newstates
|
|
||||||
log.Printf("updating config new states: %+v", conf)
|
log.Printf("updating config new states: %+v", conf)
|
||||||
config.Set(conf)
|
config.Set(conf)
|
||||||
}
|
for client, states := range changed {
|
||||||
|
if err := sendNewStates(client, states); err != nil {
|
||||||
func email() error {
|
log.Printf("failed to send new states %s/%+v: %v", client, states, err)
|
||||||
log.Printf("checking email...")
|
|
||||||
ch, err := config.Get().Emailer.ReadIMAP()
|
|
||||||
if err != nil {
|
|
||||||
ch, err = config.Get().Emailer.ReadIMAP()
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
states := map[config.State]struct{}{}
|
|
||||||
for email := range ch {
|
|
||||||
if len(states) > 0 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if !strings.Contains(email.Header.Get("From"), config.Get().Client) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
b, _ := ioutil.ReadAll(email.Body)
|
|
||||||
for _, state := range parseOutStates(b) {
|
|
||||||
states[state] = struct{}{}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setNewStates(states)
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseOutStates(b []byte) []config.State {
|
func parseOutStates(b []byte) []config.State {
|
||||||
@@ -142,6 +229,7 @@ func _main() error {
|
|||||||
log.Println(err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
if config.Get().Once {
|
if config.Get().Once {
|
||||||
|
time.Sleep(time.Second)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -192,7 +280,7 @@ func once() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getJobs() ([]broker.Job, error) {
|
func getJobs() ([]broker.Job, error) {
|
||||||
states := config.Get().States
|
states := config.AllStates()
|
||||||
ntg := broker.NewNTGVision()
|
ntg := broker.NewNTGVision()
|
||||||
if config.Get().Brokers.NTG.Mock {
|
if config.Get().Brokers.NTG.Mock {
|
||||||
ntg = ntg.WithMock()
|
ntg = ntg.WithMock()
|
||||||
@@ -229,5 +317,39 @@ func dropBanlistJobs(jobs []broker.Job) ([]broker.Job, error) {
|
|||||||
|
|
||||||
func sendJob(job broker.Job) error {
|
func sendJob(job broker.Job) error {
|
||||||
sender := message.NewMatrix()
|
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
|
||||||
|
if maps.Pickup {
|
||||||
|
pickup := fmt.Sprintf("%s,%s", url.QueryEscape(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 {
|
||||||
|
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 {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func sendNewStates(client string, states []config.State) error {
|
||||||
|
sender := message.NewMatrix()
|
||||||
|
return sender.Send(fmt.Sprintf("%s: now searching for loads from: %+v", client, states))
|
||||||
|
}
|
||||||
|
|
||||||
|
func sendNewPause(client string, pause time.Time) error {
|
||||||
|
sender := message.NewMatrix()
|
||||||
|
return sender.Send(fmt.Sprintf("%s: only searching for loads on and after %s", client, pause.Format("2006-01-02")))
|
||||||
}
|
}
|
||||||
|
|||||||
90
message/images.go
Normal file
90
message/images.go
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
package message
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"local/truckstop/config"
|
||||||
|
"log"
|
||||||
|
"mime/multipart"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
var ErrBadAuth = errors.New("auth has failed")
|
||||||
|
|
||||||
|
func UploadImage(b []byte) (string, error) {
|
||||||
|
path, err := uploadImage(b)
|
||||||
|
if err == ErrBadAuth {
|
||||||
|
if err := refreshToken(); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
path, err = uploadImage(b)
|
||||||
|
}
|
||||||
|
return path, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func refreshToken() error {
|
||||||
|
return errors.New("not impl")
|
||||||
|
}
|
||||||
|
|
||||||
|
func uploadImage(b []byte) (string, error) {
|
||||||
|
images := config.Get().Images
|
||||||
|
buff := bytes.NewBuffer(nil)
|
||||||
|
writer := multipart.NewWriter(buff)
|
||||||
|
name := "name"
|
||||||
|
if u, err := url.Parse(images.UploadURI); err != nil {
|
||||||
|
} else if s, ok := u.Query()["name"]; !ok {
|
||||||
|
} else {
|
||||||
|
name = s[0]
|
||||||
|
log.Printf("found name in upload uri: %s", name)
|
||||||
|
}
|
||||||
|
part, err := writer.CreateFormFile("image", name)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
if n, err := part.Write(b); err != nil {
|
||||||
|
return "", err
|
||||||
|
} else if n < len(b) {
|
||||||
|
return "", errors.New("short write")
|
||||||
|
}
|
||||||
|
writer.Close()
|
||||||
|
|
||||||
|
request, err := http.NewRequest(
|
||||||
|
images.UploadMethod,
|
||||||
|
images.UploadURI,
|
||||||
|
buff,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
request.Header.Set("Authorization", "Bearer "+images.AccessToken)
|
||||||
|
request.Header.Set("Content-Type", writer.FormDataContentType())
|
||||||
|
|
||||||
|
c := &http.Client{Timeout: time.Minute}
|
||||||
|
response, err := c.Do(request)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
defer response.Body.Close()
|
||||||
|
b, _ = ioutil.ReadAll(response.Body)
|
||||||
|
switch response.StatusCode {
|
||||||
|
case http.StatusOK:
|
||||||
|
case 401, 403:
|
||||||
|
return "", ErrBadAuth
|
||||||
|
default:
|
||||||
|
return "", fmt.Errorf("error uploading image: (%d) %s", response.StatusCode, b)
|
||||||
|
}
|
||||||
|
var result struct {
|
||||||
|
Data struct {
|
||||||
|
Link string `json:"link"`
|
||||||
|
} `json:"data"`
|
||||||
|
}
|
||||||
|
if err := json.Unmarshal(b, &result); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return result.Data.Link, nil
|
||||||
|
}
|
||||||
27
message/images_test.go
Normal file
27
message/images_test.go
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package message
|
||||||
|
|
||||||
|
import (
|
||||||
|
"io/ioutil"
|
||||||
|
"local/truckstop/config"
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestImageUpload(t *testing.T) {
|
||||||
|
if os.Getenv("INTEGRATION") == "" {
|
||||||
|
t.Skip("$INTEGRATION not set")
|
||||||
|
}
|
||||||
|
os.Setenv("CONFIG", "../config.json")
|
||||||
|
b, err := ioutil.ReadFile("./testdata/whatever.jpg")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if err := config.Refresh(); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
got, err := UploadImage(b)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
t.Log(got)
|
||||||
|
}
|
||||||
@@ -1,8 +1,15 @@
|
|||||||
package message
|
package message
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"local/truckstop/config"
|
"local/truckstop/config"
|
||||||
"log"
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"regexp"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/matrix-org/gomatrix"
|
"github.com/matrix-org/gomatrix"
|
||||||
)
|
)
|
||||||
@@ -13,7 +20,6 @@ type Matrix struct {
|
|||||||
username string
|
username string
|
||||||
token string
|
token string
|
||||||
room string
|
room string
|
||||||
client string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMatrix() Matrix {
|
func NewMatrix() Matrix {
|
||||||
@@ -24,7 +30,6 @@ func NewMatrix() Matrix {
|
|||||||
token: conf.Token,
|
token: conf.Token,
|
||||||
room: conf.Room,
|
room: conf.Room,
|
||||||
mock: conf.Mock,
|
mock: conf.Mock,
|
||||||
client: conf.Client,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,31 +37,63 @@ func (m Matrix) getclient() (*gomatrix.Client, error) {
|
|||||||
return gomatrix.NewClient(m.homeserver, m.username, m.token)
|
return gomatrix.NewClient(m.homeserver, m.username, m.token)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m Matrix) Receive() ([]string, error) {
|
func (m Matrix) Receive() ([]Message, error) {
|
||||||
if m.mock {
|
if m.mock {
|
||||||
log.Printf("matrix.Receive()")
|
log.Printf("matrix.Receive()")
|
||||||
return []string{"FL, GA, NC"}, nil
|
messages := make([]Message, 0)
|
||||||
|
for k := range config.Get().Clients {
|
||||||
|
messages = append(messages, Message{Timestamp: time.Now(), Sender: k, Content: "!state OH"})
|
||||||
|
if k == "bel" {
|
||||||
|
messages = append(messages, Message{Timestamp: time.Now(), Sender: k, Content: "!help"})
|
||||||
|
}
|
||||||
|
if k == "broc" {
|
||||||
|
messages = append(messages, Message{Timestamp: time.Now(), Sender: k, Content: "!available 2148-10-" + fmt.Sprint(time.Now().Unix()%28)})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return messages, nil
|
||||||
|
}
|
||||||
|
clients := config.Get().Clients
|
||||||
|
matrixIDs := map[string]struct{}{}
|
||||||
|
for k := range clients {
|
||||||
|
matrixIDs[clients[k].IDs.Matrix] = struct{}{}
|
||||||
|
}
|
||||||
|
if len(matrixIDs) == 0 {
|
||||||
|
return nil, nil
|
||||||
}
|
}
|
||||||
c, err := m.getclient()
|
c, err := m.getclient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
messages := make([]string, 0)
|
messages := make([]Message, 0)
|
||||||
result, err := c.Messages(m.room, "", "", 'b', 50)
|
result, err := c.Messages(m.room, "", "", 'b', 50)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
for _, event := range result.Chunk {
|
for _, event := range result.Chunk {
|
||||||
if event.Sender != m.client {
|
if _, ok := matrixIDs[event.Sender]; !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
switch event.Type {
|
switch event.Type {
|
||||||
case "m.room.message":
|
case "m.room.message":
|
||||||
b, ok := event.Body()
|
b, ok := event.Body()
|
||||||
if ok {
|
if ok {
|
||||||
messages = append(messages, b)
|
messages = append(messages, Message{Timestamp: time.Unix(0, event.Timestamp*int64(time.Millisecond)), Sender: event.Sender, Content: strings.TrimSpace(b)})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err != nil {
|
clientChange := regexp.MustCompile("@[a-z]+$")
|
||||||
return nil, err
|
for i := range messages {
|
||||||
|
if found := clientChange.FindString(messages[i].Content); found != "" {
|
||||||
|
messages[i].Content = strings.TrimSpace(strings.ReplaceAll(messages[i].Content, found, ""))
|
||||||
|
messages[i].Sender = found[1:]
|
||||||
|
} else {
|
||||||
|
for k, v := range config.Get().Clients {
|
||||||
|
if v.IDs.Matrix == messages[i].Sender {
|
||||||
|
messages[i].Sender = k
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
messages[i].Content = strings.TrimSpace(messages[i].Content)
|
||||||
}
|
}
|
||||||
return messages, nil
|
return messages, nil
|
||||||
}
|
}
|
||||||
@@ -73,3 +110,36 @@ func (m Matrix) Send(text string) error {
|
|||||||
_, err = c.SendText(m.room, text)
|
_, err = c.SendText(m.room, text)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m Matrix) SendImage(uri string) error {
|
||||||
|
if m.mock {
|
||||||
|
log.Printf("matrix.SendImage(%s)", uri)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
response, err := http.Get(uri)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if response.StatusCode != http.StatusOK {
|
||||||
|
b, _ := ioutil.ReadAll(response.Body)
|
||||||
|
response.Body.Close()
|
||||||
|
return fmt.Errorf("failed to get %s: (%d) %s", uri, response.StatusCode, b)
|
||||||
|
}
|
||||||
|
b, err := ioutil.ReadAll(response.Body)
|
||||||
|
response.Body.Close()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
c, err := m.getclient()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
mediaUpload, err := c.UploadToContentRepo(bytes.NewReader(b), "image/jpeg", int64(len(b)))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
publicURI := mediaUpload.ContentURI
|
||||||
|
resp, err := c.SendImage(m.room, "img", publicURI)
|
||||||
|
log.Printf("sent image %s => %s: %+v", uri, publicURI, resp)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,14 @@
|
|||||||
package message
|
package message
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
type Sender interface {
|
type Sender interface {
|
||||||
Send(string) error
|
Send(string) error
|
||||||
Receive() ([]string, error)
|
Receive() ([]Message, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type Message struct {
|
||||||
|
Sender string
|
||||||
|
Content string
|
||||||
|
Timestamp time.Time
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
message/testdata/whatever.jpg
vendored
Normal file
BIN
message/testdata/whatever.jpg
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
5
testdata/index.html
vendored
Normal file
5
testdata/index.html
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<img src='https://maps.googleapis.com/maps/api/staticmap?center=Advance,NC&zoom=13&size=400x400&maptype=roadmap&key=AIzaSyBkACm-LQkoSfsTO5_XAzBVZE9-JQzcNkg'/>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
48
todo.yaml
48
todo.yaml
@@ -1,21 +1,47 @@
|
|||||||
todo:
|
todo:
|
||||||
- modify old items once no longer available
|
- no hard code jpeg or have it in multiple places
|
||||||
- many users -> 1 ntg query
|
- todo: switch house to selfhosted for rate limit
|
||||||
- accept after date
|
tags: now
|
||||||
- "caleb: my-usual-stuff" to alias
|
- mark consumed;; save scroll id for matrix
|
||||||
- rate LIMIT
|
- TEST its falling apart
|
||||||
|
- test each !command callbacks to matrix
|
||||||
|
- change matrix so I test my custom logic even if I dont fetch remote
|
||||||
|
- warn/err/etc. on clobbering ids.matrix since clients can mess with one another
|
||||||
|
- modify old items once no longer available; drop stale jobs good candidate but requires new matrix interaction
|
||||||
- more than NTG
|
- more than NTG
|
||||||
- accept pause commands
|
|
||||||
- rate limit brokers
|
|
||||||
- write to matrix on config change like states
|
|
||||||
- todo: filter out jobs like CA
|
- todo: filter out jobs like CA
|
||||||
subtasks:
|
subtasks:
|
||||||
- banlist criteria like vendors, brokers, metadata
|
- banlist criteria like vendors, brokers, metadata
|
||||||
- quiet hours
|
|
||||||
- setup ma on element
|
|
||||||
- accept states via element for one system
|
|
||||||
- set up copy for caleb, broc
|
- set up copy for caleb, broc
|
||||||
done:
|
done:
|
||||||
|
- setup ma on element !!fluffychat
|
||||||
|
- !help,
|
||||||
|
- !states optional but explicit option
|
||||||
|
- TEST; convert pauseuntil to search results only on and after target date
|
||||||
|
- pause until => !busy until
|
||||||
|
- 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
|
||||||
|
subtasks:
|
||||||
|
- DONE; yandex; key 9baa3e42-c6e5-4eb5-a891-05ffcede6a25 yandex maps
|
||||||
|
- google; key AIzaSyBkACm-LQkoSfsTO5_XAzBVZE9-JQzcNkg
|
||||||
|
- 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
|
||||||
|
- accept pause commands
|
||||||
|
- accept states via element for one system
|
||||||
|
- write to matrix on config change like states
|
||||||
|
- rate LIMIT
|
||||||
|
- rate limit brokers
|
||||||
|
- many users -> 1 ntg query
|
||||||
|
- multi client
|
||||||
|
- rm email
|
||||||
|
- send matrix msg on config change
|
||||||
- setup pa on element
|
- setup pa on element
|
||||||
- configurable email interval
|
- configurable email interval
|
||||||
- jitter on intervals, including dedicated err span
|
- jitter on intervals, including dedicated err span
|
||||||
|
|||||||
BIN
whatever.jpg
Normal file
BIN
whatever.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 50 KiB |
Reference in New Issue
Block a user