1
0
Fork 0
mirror of https://github.com/fluffle/goirc synced 2025-07-10 23:39:23 +00:00

Fixes for recent versions of Go.

Simplifying getStringMsg().
This commit is contained in:
Yves Junqueira 2010-08-22 02:23:07 +08:00 committed by Alex Bramley
parent cc35817517
commit 1503d7b9db
2 changed files with 16 additions and 28 deletions

View file

@ -80,7 +80,7 @@ func (conn *Conn) initialise() {
// Connect the IRC connection object to "host[:port]" which should be either
// a hostname or an IP address, with an optional port defaulting to 6667.
// You can also provide an optional connect password.
func (conn *Conn) Connect(host string, pass ...) os.Error {
func (conn *Conn) Connect(host string, pass ...string) os.Error {
if conn.connected {
return os.NewError(fmt.Sprintf("irc.Connect(): already connected to %s, cannot connect to %s", conn.Host, host))
}
@ -113,7 +113,7 @@ func (conn *Conn) Connect(host string, pass ...) os.Error {
}
// dispatch a nicely formatted os.Error to the error channel
func (conn *Conn) error(s string, a ...) { conn.Err <- os.NewError(fmt.Sprintf(s, a)) }
func (conn *Conn) error(s string, a ...interface{}) { conn.Err <- os.NewError(fmt.Sprintf(s, a)) }
// copied from http.client for great justice
func hasPort(s string) bool { return strings.LastIndex(s, ":") > strings.LastIndex(s, "]") }
@ -142,7 +142,7 @@ func (conn *Conn) send() {
// so sleep for the current line's time value before sending it
time.Sleep(linetime)
}
if err := conn.io.WriteString(line + "\r\n"); err != nil {
if _, err := conn.io.WriteString(line + "\r\n"); err != nil {
conn.error("irc.send(): %s", err.String())
conn.shutdown()
break
@ -161,8 +161,7 @@ func (conn *Conn) recv() {
conn.shutdown()
break
}
// chop off \r\n
s = s[0 : len(s)-2]
s = strings.Trim(s, "\r\n")
fmt.Println("<- " + s)
line := &Line{Raw: s}
@ -193,7 +192,7 @@ func (conn *Conn) recv() {
if len(args) > 1 {
line.Text = args[1]
}
args = strings.Split(args[0], " ", 0)
args = strings.Split(args[0], " ", -1)
line.Cmd = strings.ToUpper(args[0])
if len(args) > 1 {
line.Args = args[1:len(args)]