move log message out of plugins
This commit is contained in:
parent
10cc1f957b
commit
6e665970b1
10
main.go
10
main.go
@ -18,10 +18,11 @@ import (
|
||||
func main() {
|
||||
var username, password, userID, accessToken, server, db, avatar, botOwner string
|
||||
var key, value, get string
|
||||
var setup, doc bool
|
||||
var setup, doc, debug bool
|
||||
|
||||
flag.BoolVar(&doc, "doc", false, "print plugin information and exit")
|
||||
flag.BoolVar(&setup, "s", false, "setup account")
|
||||
flag.BoolVar(&debug, "debug", false, "print debug messages")
|
||||
|
||||
flag.StringVar(&avatar, "avatar", "", "set the avatar of the bot to specified url")
|
||||
flag.StringVar(&db, "db", "db", "full path to database directory")
|
||||
@ -206,8 +207,15 @@ func main() {
|
||||
|
||||
}
|
||||
if p.Match(username, post) {
|
||||
log.Printf("%s: responding to '%s'", p.Name(), ev.Sender)
|
||||
p.SetStore(store)
|
||||
|
||||
start := time.Now()
|
||||
p.RespondText(cli, ev, username, post)
|
||||
elapsed := time.Since(start)
|
||||
if debug {
|
||||
log.Printf("%s took %s to run\n", p.Name(), elapsed)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package plugins
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"math/rand"
|
||||
"net/url"
|
||||
"regexp"
|
||||
@ -120,7 +119,6 @@ func (h *Beer) SetStore(s PluginStore) {}
|
||||
func (h *Beer) RespondText(c *gomatrix.Client, ev *gomatrix.Event, user, post string) {
|
||||
beer := h.fix(post)
|
||||
if beer != "" {
|
||||
log.Printf("%s: responding to '%s'", h.Name(), ev.Sender)
|
||||
var beers = &BeerResp{}
|
||||
u := fmt.Sprintf("%s%s",
|
||||
"https://data.opendatasoft.com/api/records/1.0/search?dataset=open-beer-database%40public-us&q=",
|
||||
|
@ -1,7 +1,6 @@
|
||||
package plugins
|
||||
|
||||
import (
|
||||
"log"
|
||||
"math/rand"
|
||||
"regexp"
|
||||
"time"
|
||||
@ -49,7 +48,6 @@ func (h *BotSnack) SetStore(s PluginStore) {}
|
||||
func (h *BotSnack) RespondText(c *gomatrix.Client, ev *gomatrix.Event, user, post string) {
|
||||
u := NameRE.ReplaceAllString(user, "$1")
|
||||
if ToMe(u, post) {
|
||||
log.Printf("%s: responding to '%s'", h.Name(), ev.Sender)
|
||||
SendText(c, ev.RoomID, h.resp())
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package plugins
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"time"
|
||||
@ -63,8 +62,6 @@ func (h *Feder) RespondText(c *gomatrix.Client, ev *gomatrix.Event, user, post s
|
||||
|
||||
homeServer = u.Hostname()
|
||||
|
||||
log.Printf("%s: responding to '%s'", h.Name(), ev.Sender)
|
||||
|
||||
furl := fmt.Sprintf("%s%s",
|
||||
"https://federationtester.matrix.org/api/report?server_name=",
|
||||
url.PathEscape(homeServer),
|
||||
|
@ -2,7 +2,6 @@ package plugins
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"regexp"
|
||||
|
||||
"github.com/matrix-org/gomatrix"
|
||||
@ -35,7 +34,6 @@ func (h *Hi) SetStore(s PluginStore) {}
|
||||
func (h *Hi) RespondText(c *gomatrix.Client, ev *gomatrix.Event, user, post string) {
|
||||
s := NameRE.ReplaceAllString(ev.Sender, "$1")
|
||||
|
||||
log.Printf("%s: responding to '%s'", h.Name(), ev.Sender)
|
||||
SendText(c, ev.RoomID, fmt.Sprintf("hi %s!", s))
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@ package plugins
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"github.com/matrix-org/gomatrix"
|
||||
@ -43,11 +42,9 @@ func (h *HighFive) RespondText(c *gomatrix.Client, ev *gomatrix.Event, user, pos
|
||||
s := NameRE.ReplaceAllString(ev.Sender, "$1")
|
||||
|
||||
if strings.Contains(post, rightFive()) {
|
||||
log.Printf("%s: responding to '%s'", h.Name(), ev.Sender)
|
||||
SendText(c, ev.RoomID, fmt.Sprintf("\\o %s", s))
|
||||
}
|
||||
if strings.Contains(post, leftFive()) {
|
||||
log.Printf("%s: responding to '%s'", h.Name(), ev.Sender)
|
||||
SendText(c, ev.RoomID, fmt.Sprintf("%s o/", s))
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package plugins
|
||||
|
||||
import (
|
||||
"log"
|
||||
"math/rand"
|
||||
"regexp"
|
||||
"time"
|
||||
@ -48,7 +47,6 @@ func (h *LoveYou) SetStore(s PluginStore) {}
|
||||
|
||||
// RespondText to love events
|
||||
func (h *LoveYou) RespondText(c *gomatrix.Client, ev *gomatrix.Event, user, post string) {
|
||||
log.Printf("%s: responding to '%s'", h.Name(), ev.Sender)
|
||||
SendText(c, ev.RoomID, h.resp())
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@ package plugins
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"regexp"
|
||||
|
||||
"github.com/matrix-org/gomatrix"
|
||||
@ -51,7 +50,6 @@ func (h *OpenBSDMan) SetStore(s PluginStore) {}
|
||||
func (h *OpenBSDMan) RespondText(c *gomatrix.Client, ev *gomatrix.Event, user, post string) {
|
||||
page := h.fix(post)
|
||||
if page != "" {
|
||||
log.Printf("%s: responding to '%s'", h.Name(), ev.Sender)
|
||||
SendText(c, ev.RoomID, fmt.Sprintf("https://man.openbsd.org/%s", page))
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package plugins
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"regexp"
|
||||
|
||||
@ -35,7 +34,6 @@ func (p *Snap) SetStore(s PluginStore) {}
|
||||
|
||||
// RespondText to looking up of federation check requests
|
||||
func (p *Snap) RespondText(c *gomatrix.Client, ev *gomatrix.Event, user, post string) {
|
||||
log.Printf("%s: responding to '%s'", p.Name(), ev.Sender)
|
||||
resp, err := http.Get("https://ftp.usa.openbsd.org/pub/OpenBSD/snapshots/amd64/BUILDINFO")
|
||||
if err != nil {
|
||||
SendText(c, ev.RoomID, fmt.Sprintf("%s", err))
|
||||
|
@ -2,7 +2,6 @@ package plugins
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"regexp"
|
||||
|
||||
"github.com/matrix-org/gomatrix"
|
||||
@ -35,7 +34,6 @@ func (h *Source) SetStore(s PluginStore) {}
|
||||
func (h *Source) RespondText(c *gomatrix.Client, ev *gomatrix.Event, user, post string) {
|
||||
s := NameRE.ReplaceAllString(ev.Sender, "$1")
|
||||
|
||||
log.Printf("%s: responding to '%s'", h.Name(), ev.Sender)
|
||||
SendText(c, ev.RoomID, fmt.Sprintf("%s: %s ;D", s, "https://git.sr.ht/~qbit/mcchunkie"))
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@ package plugins
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"math/rand"
|
||||
"regexp"
|
||||
"time"
|
||||
@ -46,7 +45,6 @@ func (h *Thanks) RespondText(c *gomatrix.Client, ev *gomatrix.Event, user, post
|
||||
|
||||
rand.Seed(time.Now().Unix())
|
||||
|
||||
log.Printf("%s: responding to '%s'", h.Name(), ev.Sender)
|
||||
SendText(c, ev.RoomID, a[rand.Intn(len(a))])
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@ package plugins
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"regexp"
|
||||
"runtime"
|
||||
|
||||
@ -41,7 +40,6 @@ func (v *Version) SetStore(s PluginStore) {}
|
||||
func (v *Version) RespondText(c *gomatrix.Client, ev *gomatrix.Event, user, post string) {
|
||||
s := NameRE.ReplaceAllString(ev.Sender, "$1")
|
||||
|
||||
log.Printf("%s: responding to '%s'", v.Name(), ev.Sender)
|
||||
SendText(c, ev.RoomID, v.print(s))
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"regexp"
|
||||
@ -167,7 +166,6 @@ func (h *Weather) fix(msg string) string {
|
||||
func (h *Weather) RespondText(c *gomatrix.Client, ev *gomatrix.Event, user, post string) {
|
||||
weather := h.fix(post)
|
||||
if weather != "" {
|
||||
log.Printf("%s: responding to '%s'", h.Name(), ev.Sender)
|
||||
wd, err := h.get(weather)
|
||||
if err != nil {
|
||||
SendText(c, ev.RoomID, fmt.Sprintf("sorry %s, I can't look up the weather. %s", ev.Sender, err))
|
||||
|
@ -2,7 +2,6 @@ package plugins
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"regexp"
|
||||
|
||||
"github.com/matrix-org/gomatrix"
|
||||
@ -35,7 +34,6 @@ func (h *Wb) SetStore(s PluginStore) {}
|
||||
func (h *Wb) RespondText(c *gomatrix.Client, ev *gomatrix.Event, user, post string) {
|
||||
s := NameRE.ReplaceAllString(ev.Sender, "$1")
|
||||
|
||||
log.Printf("%s: responding to '%s'", h.Name(), ev.Sender)
|
||||
SendText(c, ev.RoomID, fmt.Sprintf("thanks %s!", s))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user