mirror of https://github.com/velour/catbase.git
counter: maybe finish this feature
This commit is contained in:
parent
5de82d96e4
commit
f2153bf0b4
|
@ -86,9 +86,9 @@ func (p *CounterPlugin) mkIncrementByNAPI(direction int) func(w http.ResponseWri
|
|||
personalMsg = fmt.Sprintf("\nMessage: %s", inputMsg)
|
||||
}
|
||||
|
||||
//chs := p.cfg.GetArray("channels", []string{p.cfg.Get("channels", "none")})
|
||||
chs := p.cfg.GetMap("counter.channelItems", map[string]string{})
|
||||
if len(chs) == 0 {
|
||||
ch, ok := chs[itemName]
|
||||
if len(chs) == 0 || !ok {
|
||||
return
|
||||
}
|
||||
req := &bot.Request{
|
||||
|
@ -98,7 +98,7 @@ func (p *CounterPlugin) mkIncrementByNAPI(direction int) func(w http.ResponseWri
|
|||
User: &u,
|
||||
// Noting here that we're only going to do goals in a "default"
|
||||
// channel even if it should send updates to others.
|
||||
Channel: chs[itemName],
|
||||
Channel: ch,
|
||||
Body: fmt.Sprintf("%s += %d", itemName, delta),
|
||||
Time: time.Now(),
|
||||
},
|
||||
|
@ -119,8 +119,8 @@ func (p *CounterPlugin) mkIncrementByNAPI(direction int) func(w http.ResponseWri
|
|||
|
||||
func (p *CounterPlugin) mkIncrementAPI(delta int) func(w http.ResponseWriter, r *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
userName := chi.URLParam(r, "user")
|
||||
itemName := chi.URLParam(r, "item")
|
||||
userName, _ := url.QueryUnescape(chi.URLParam(r, "user"))
|
||||
itemName, _ := url.QueryUnescape(chi.URLParam(r, "item"))
|
||||
|
||||
secret, pass, ok := r.BasicAuth()
|
||||
if !ok || !p.b.CheckPassword(secret, pass) {
|
||||
|
@ -164,7 +164,11 @@ func (p *CounterPlugin) mkIncrementAPI(delta int) func(w http.ResponseWriter, r
|
|||
personalMsg = fmt.Sprintf("\nMessage: %s", inputMsg)
|
||||
}
|
||||
|
||||
chs := p.cfg.GetArray("channels", []string{p.cfg.Get("channels", "none")})
|
||||
chs := p.cfg.GetMap("counter.channelItems", map[string]string{})
|
||||
ch, ok := chs[itemName]
|
||||
if len(chs) == 0 || !ok {
|
||||
return
|
||||
}
|
||||
req := &bot.Request{
|
||||
Conn: p.b.DefaultConnector(),
|
||||
Kind: bot.Message,
|
||||
|
@ -172,7 +176,7 @@ func (p *CounterPlugin) mkIncrementAPI(delta int) func(w http.ResponseWriter, r
|
|||
User: &u,
|
||||
// Noting here that we're only going to do goals in a "default"
|
||||
// channel even if it should send updates to others.
|
||||
Channel: chs[0],
|
||||
Channel: ch,
|
||||
Body: fmt.Sprintf("%s += %d", itemName, delta),
|
||||
Time: time.Now(),
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue