mirror of https://github.com/velour/catbase.git
Compare commits
No commits in common. "c44ada3061073bc3e7038b62e436f468d2eea885" and "9cecccfcdddf0a4c39288f907c48dd0b842c09c9" have entirely different histories.
c44ada3061
...
9cecccfcdd
|
@ -5,7 +5,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/velour/catbase/bot/user"
|
"github.com/velour/catbase/bot/user"
|
||||||
"io"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -45,8 +45,6 @@ func (p *CounterPlugin) mkIncrementByNAPI(direction int) func(w http.ResponseWri
|
||||||
delta, err := strconv.Atoi(chi.URLParam(r, "delta"))
|
delta, err := strconv.Atoi(chi.URLParam(r, "delta"))
|
||||||
if err != nil || delta == 0 {
|
if err != nil || delta == 0 {
|
||||||
delta = direction
|
delta = direction
|
||||||
} else {
|
|
||||||
delta = delta * direction
|
|
||||||
}
|
}
|
||||||
|
|
||||||
secret, pass, ok := r.BasicAuth()
|
secret, pass, ok := r.BasicAuth()
|
||||||
|
@ -83,7 +81,7 @@ func (p *CounterPlugin) mkIncrementByNAPI(direction int) func(w http.ResponseWri
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
body, _ := io.ReadAll(r.Body)
|
body, _ := ioutil.ReadAll(r.Body)
|
||||||
postData := map[string]string{}
|
postData := map[string]string{}
|
||||||
err = json.Unmarshal(body, &postData)
|
err = json.Unmarshal(body, &postData)
|
||||||
personalMsg := ""
|
personalMsg := ""
|
||||||
|
@ -112,13 +110,7 @@ func (p *CounterPlugin) mkIncrementByNAPI(direction int) func(w http.ResponseWri
|
||||||
}
|
}
|
||||||
msg := fmt.Sprintf("%s changed their %s counter by %d for a total of %d via the amazing %s API. %s",
|
msg := fmt.Sprintf("%s changed their %s counter by %d for a total of %d via the amazing %s API. %s",
|
||||||
userName, itemName, delta, item.Count+delta*direction, p.cfg.Get("nick", "catbase"), personalMsg)
|
userName, itemName, delta, item.Count+delta*direction, p.cfg.Get("nick", "catbase"), personalMsg)
|
||||||
if !ok {
|
for _, ch := range chs {
|
||||||
chs := p.cfg.GetArray("counter.channels", []string{})
|
|
||||||
for _, ch := range chs {
|
|
||||||
p.b.Send(p.b.DefaultConnector(), bot.Message, ch, msg)
|
|
||||||
req.Msg.Channel = ch
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
p.b.Send(p.b.DefaultConnector(), bot.Message, ch, msg)
|
p.b.Send(p.b.DefaultConnector(), bot.Message, ch, msg)
|
||||||
req.Msg.Channel = ch
|
req.Msg.Channel = ch
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue