greeting function
This commit is contained in:
parent
1f3c48fca2
commit
48ad301517
|
@ -5,12 +5,11 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"time"
|
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
irc "gopkg.in/irc.v3"
|
irc "gopkg.in/irc.v3"
|
||||||
)
|
)
|
||||||
|
@ -21,7 +20,6 @@ var r = rand.New(s)
|
||||||
var channel string
|
var channel string
|
||||||
var victim string
|
var victim string
|
||||||
|
|
||||||
|
|
||||||
func HandleRequest(ctx context.Context) (string, error) {
|
func HandleRequest(ctx context.Context) (string, error) {
|
||||||
// So i was too lazy to get rid of the boilerplate
|
// So i was too lazy to get rid of the boilerplate
|
||||||
// Set up IRC connection
|
// Set up IRC connection
|
||||||
|
@ -46,7 +44,7 @@ func HandleRequest(ctx context.Context) (string, error) {
|
||||||
config := irc.ClientConfig{
|
config := irc.ClientConfig{
|
||||||
Nick: insults[r.Intn(len(insults))],
|
Nick: insults[r.Intn(len(insults))],
|
||||||
User: hostname,
|
User: hostname,
|
||||||
Name: victim + "'s thunder buddy",
|
Name: "dabbing on " + victim,
|
||||||
Handler: irc.HandlerFunc(handleIRCCon), // See below for callback
|
Handler: irc.HandlerFunc(handleIRCCon), // See below for callback
|
||||||
}
|
}
|
||||||
client := irc.NewClient(conn, config)
|
client := irc.NewClient(conn, config)
|
||||||
|
@ -81,7 +79,15 @@ func handleIRCCon(c *irc.Client, m *irc.Message) {
|
||||||
c.Write("NICK " + nick)
|
c.Write("NICK " + nick)
|
||||||
} else if text[len(text)-1] == "invite" {
|
} else if text[len(text)-1] == "invite" {
|
||||||
c.Write("INVITE " + victim + " " + channel)
|
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",
|
||||||
|
},
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue