Created
November 20, 2014 20:04
-
-
Save cjwebb/07d368b932deb6b8aecd to your computer and use it in GitHub Desktop.
Log into IRC and display chat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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