From 48ad301517bfa925ba611532cd5e9064fc4fdfed Mon Sep 17 00:00:00 2001 From: dave Date: Sun, 20 Oct 2019 13:08:35 -0700 Subject: [PATCH] greeting function --- cmd/swarm/main.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/cmd/swarm/main.go b/cmd/swarm/main.go index b4c5588..7e2514e 100644 --- a/cmd/swarm/main.go +++ b/cmd/swarm/main.go @@ -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", + }, + }) } }