本文整理匯總了Golang中github.com/fluffle/goirc/client.Conn.Quit方法的典型用法代碼示例。如果您正苦於以下問題:Golang Conn.Quit方法的具體用法?Golang Conn.Quit怎麽用?Golang Conn.Quit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/fluffle/goirc/client.Conn
的用法示例。
在下文中一共展示了Conn.Quit方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ui
func ui(con *irc.Conn, in chan string) {
curr_chan := ""
for input := range in {
if input[0] == '/' {
// is a command
var cmd string
cmdend := strings.Index(input, " ")
if cmdend > 0 {
cmd = input[:cmdend]
} else {
cmd = input
}
switch cmd {
case "/join":
if len(input) > cmdend {
channel := input[cmdend+1:]
if channel[0] != '#' {
channel = "#" + channel
}
curr_chan = channel
con.Join(channel)
} else {
fmt.Println("Please specify the channel")
}
case "/quit":
fmt.Println("Bye!")
con.Quit()
case "/goto":
curr_chan = input[cmdend+1:]
case "/list":
break
case "/nick":
if cmdend > 0 {
con.Nick(input[cmdend+1:])
} else {
fmt.Println("Too few arguments")
}
default:
fmt.Println("Unknown command")
}
fmt.Printf("\n%s: ", curr_chan)
} else {
con.Privmsg(curr_chan, input)
fmt.Printf("%s: ", curr_chan)
}
}
fmt.Println("Closing connection. kthxbai!")
con.Quit()
}
示例2: restart
func restart(conn *irc.Conn, nick *irc.Nick, args, channel string) {
owner, _ := auth.String(conn.Network, "owner")
if owner == user(nick) {
cmd := exec.Command("./rbot")
here, _ := os.Getwd()
cmd.Dir = here
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err := cmd.Start()
if err != nil {
say(conn, channel, "Unable to start new process: %s", err)
return
}
conn.Quit("Restarting.")
time.Sleep(50)
os.Exit(0)
}
}