Skip to content

Instantly share code, notes, and snippets.

@cjwebb
Created November 20, 2014 20:04
Show Gist options
  • Save cjwebb/07d368b932deb6b8aecd to your computer and use it in GitHub Desktop.
Save cjwebb/07d368b932deb6b8aecd to your computer and use it in GitHub Desktop.
Log into IRC and display chat
package main
import (
"net"
"net/textproto"
"fmt"
"log"
"bufio"
)
func main() {
conn, err := net.Dial("tcp", "chat.freenode.net:6667")
if err != nil {
log.Fatal("unable to connect to IRC server ", err)
}
log.Printf("Connected to IRC Server")
conn.Write([]byte("PASS yourpassword\r\n"))
conn.Write([]byte("NICK yournick\r\n"))
conn.Write([]byte("JOIN #go-nuts\r\n"))
conn.Write([]byte("JOIN #clojure\r\n"))
defer conn.Close()
reader := bufio.NewReader(conn)
tp := textproto.NewReader(reader)
for {
line, err := tp.ReadLine()
if err != nil {
break
}
fmt.Printf("%s\n", line)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment