-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.go
67 lines (61 loc) · 1.17 KB
/
bot.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package main
import (
"bufio"
"crypto/rand"
"fmt"
"log"
"math/big"
"net"
"os"
"strings"
)
var xinga = map[string]string{
"0": "chupa essa manga",
"1": "ja sabe neh?",
"2": "cabeca de nos todos",
"3": "burrao",
"5": "maragogipe",
"6": "vc usa mac os",
"7": "macfag",
"8": "chori",
"9": "ah falo",
"10": "fodasse",
}
func random() string {
r, _ := rand.Int(rand.Reader, big.NewInt(10))
x := r.String()
return xinga[x]
}
func scanner(conn net.Conn) {
for {
scanner := bufio.NewScanner(conn)
for scanner.Scan() {
bla := scanner.Text()
if strings.Contains(bla, "!xinga") {
fmt.Fprintf(conn, "PRIVMSG #trutas :"+random()+"\n")
}
if strings.HasPrefix(bla, "PING :") {
fmt.Fprintf(conn, "PONG"+bla[4:]+"\n")
}
fmt.Println(bla)
}
if err := scanner.Err(); err != nil {
log.Fatal(err)
}
}
}
func connect() {
conn, err := net.Dial("tcp", "irc.freenode.net:6667")
if err != nil {
log.Fatal(err)
os.Exit(1)
}
fmt.Fprintf(conn, "NICK golero\n")
fmt.Fprintf(conn, "USER golero 8 * : golero\n")
fmt.Fprintf(conn, "PRIVMSG NICKSERV :IDENTIFY xxxxx\n")
fmt.Fprintf(conn, "JOIN #trutas\n")
scanner(conn)
}
func main() {
connect()
}