all repos — paprika @ eb2f22649405dd676a6c6c3cf1eedfa325fa8bef

go rewrite of taigabot

More gofmt
Anirudh Oppiliappan x@icyphox.sh
Tue, 28 Dec 2021 10:59:57 +0530
commit

eb2f22649405dd676a6c6c3cf1eedfa325fa8bef

parent

e568d23f7e187249da9d1f243b788c24c6afe0fa

3 files changed, 18 insertions(+), 19 deletions(-)

jump to
M plugins/quotes.goplugins/quotes.go

@@ -52,21 +52,21 @@ return res, nil

} func getAndIncrementQuoteTotal(txn *badger.Txn, keyPrefix []byte) (int, error) { -total, err := getQuoteTotal(txn, keyPrefix) -if err == badger.ErrKeyNotFound { - total = 0 -} else if err != nil { - return 0, err -} -total++ -return total, txn.Set(keyPrefix, []byte(strconv.Itoa(total))) + total, err := getQuoteTotal(txn, keyPrefix) + if err == badger.ErrKeyNotFound { + total = 0 + } else if err != nil { + return 0, err + } + total++ + return total, txn.Set(keyPrefix, []byte(strconv.Itoa(total))) } func findQuotes(nick string, keyPrefix, search []byte) (string, error) { -var ( - num int - total int - quote string + var ( + num int + total int + quote string ) err := database.DB.DB.View(func(txn *badger.Txn) error {

@@ -157,9 +157,9 @@ }

func getQuote(nick string, qnum int, keyPrefix []byte) (string, error) { var ( - num int - total int - quote string + num int + total int + quote string negative bool )

@@ -238,7 +238,7 @@ cState := getQ

var nick string keyPrefix := []byte(m.Params[0] + " ") - for i := 1 ;i < len(params); i++ { + for i := 1; i < len(params); i++ { word := params[i] back: if len(word) == 0 {

@@ -290,7 +290,7 @@ } else {

pState = parseGetParam } case parseGetParam: - if i + 1 == len(params) { + if i+1 == len(params) { qnum, err := strconv.Atoi(word) if err != nil { return findQuotes(nick, keyPrefix, []byte(word))
M plugins/weather.goplugins/weather.go

@@ -41,7 +41,6 @@ if !found {

return "", NoReply } - var loc string if len(parsed) != 2 { var err error
M plugins/youtube.goplugins/youtube.go

@@ -24,7 +24,7 @@

func (Youtube) Execute(m *irc.Message) (string, error) { parsed := strings.SplitN(m.Trailing(), " ", 2) if len(parsed) == 1 && parsed[0] == ".yt" { - return "Usage: .yt QUERY", nil + return "Usage: .yt <query>", nil } else if parsed[0] != ".yt" { return "", NoReply // ??? }