greeting function

This commit is contained in:
dave 2019-10-20 13:08:35 -07:00
parent 1f3c48fca2
commit 48ad301517
1 changed files with 11 additions and 5 deletions

View File

@ -5,12 +5,11 @@ import (
"fmt"
"log"
"math/rand"
"time"
"net"
"os"
"strconv"
"strings"
"time"
irc "gopkg.in/irc.v3"
)
@ -21,7 +20,6 @@ var r = rand.New(s)
var channel string
var victim string
func HandleRequest(ctx context.Context) (string, error) {
// So i was too lazy to get rid of the boilerplate
// Set up IRC connection
@ -46,7 +44,7 @@ func HandleRequest(ctx context.Context) (string, error) {
config := irc.ClientConfig{
Nick: insults[r.Intn(len(insults))],
User: hostname,
Name: victim + "'s thunder buddy",
Name: "dabbing on " + victim,
Handler: irc.HandlerFunc(handleIRCCon), // See below for callback
}
client := irc.NewClient(conn, config)
@ -81,7 +79,15 @@ func handleIRCCon(c *irc.Client, m *irc.Message) {
c.Write("NICK " + nick)
} else if text[len(text)-1] == "invite" {
c.Write("INVITE " + victim + " " + channel)
sent++
} else if strings.Contains(m.Trailing(), "greetings") {
c.WriteMessage(&irc.Message{
Command: "PRIVMSG",
Params: []string{
m.Params[0],
victim + ": hi",
},
})
}
}