wurgurboo: add banter module
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
@@ -8,6 +8,7 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"math/rand"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
@@ -20,6 +21,8 @@ import (
|
||||
)
|
||||
|
||||
func main() {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
|
||||
shortlink := NewShortLink(filepath.Join(os.Getenv("STATE_DIRECTORY"), "links.txt"))
|
||||
http.HandleFunc("/l/", shortlink.HandleRequest)
|
||||
listener, err := net.FileListener(os.Stdin)
|
||||
@@ -57,6 +60,11 @@ func main() {
|
||||
Logger: hbot.Logger{Verbosef: log.Printf, Errorf: log.Printf},
|
||||
Password: os.Getenv("WURGURBOO_PASSWORD"),
|
||||
})
|
||||
banter := NewBanter(channel, bot.Nick())
|
||||
bot.AddTrigger(hbot.Trigger{
|
||||
Condition: func(b *hbot.Bot, m *hbot.Message) bool { return m.Command == "PRIVMSG" },
|
||||
Action: banter.Handle,
|
||||
})
|
||||
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, syscall.SIGINT, syscall.SIGTERM)
|
||||
@@ -86,7 +94,7 @@ func main() {
|
||||
log.Printf("New commit %s in %s", commit.Commit.ID, commit.RepoTitle)
|
||||
short := shortlink.New(commit.Commit.Link.Href)
|
||||
seenCommits[sc] = short
|
||||
bot.Msg(channel, fmt.Sprintf("\x01ACTION found a new commit in \x0303%s\x0f - \x0306%s\x0f - %s\x01",
|
||||
bot.Action(channel, fmt.Sprintf("found a new commit in \x0303%s\x0f - \x0306%s\x0f - %s",
|
||||
sc.repo, sc.subject,
|
||||
fmt.Sprintf("https://w-g.pw/l/%s", short)),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user