本文整理汇总了Golang中github.com/fluffle/goirc/client.Conn.Who方法的典型用法代码示例。如果您正苦于以下问题:Golang Conn.Who方法的具体用法?Golang Conn.Who怎么用?Golang Conn.Who使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/fluffle/goirc/client.Conn
的用法示例。
在下文中一共展示了Conn.Who方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: reportAllNowPlaying
func reportAllNowPlaying(irc *client.Conn, asker, channel string) {
if !(strings.HasPrefix(channel, "#") || strings.HasPrefix(channel, "&")) {
log.Println("User", asker, "asked What's Playing...... via PM")
irc.Privmsg(channel, fmt.Sprintf("%s: this only works on channels", asker))
return
}
log.Println("User", asker, "requested What's Playing on channel", channel)
if !checkIdentified(irc, asker) {
r := fmt.Sprintf("%s: you must be identified with NickServ to use this command", asker)
log.Println(r)
irc.Privmsg(channel, r)
return
}
if _, ok := whoChannel[channel]; ok {
log.Println("Channel", channel, "is already executing a What's Playing request")
return
}
whoChannel[channel] = make(chan bool, 1)
go irc.Who(channel)
for _ = range whoChannel[channel] { // wait until channel is closed
}
delete(whoChannel, channel)
reportChan := make(chan bool)
totalReport := len(whoResult[channel]) - 1
msg := fmt.Sprintf("Reporting now playing for %d nicks in channel %s", totalReport, channel)
log.Println(msg)
irc.Notice(asker, msg)
for _, nick := range whoResult[channel] {
if nick != irc.Me().Nick {
n := nick
go func() {
rateLimit <- true
reportChan <- reportNowPlaying(irc, channel, asker, n, true)
<-rateLimit
}()
}
}
delete(whoResult, channel)
okCount, totalCount := 0, 0
for r := range reportChan {
if r {
okCount++
}
if totalCount++; totalCount == totalReport {
break
}
}
close(reportChan)
msg = fmt.Sprintf("Reported for %d of %d nicks", okCount, totalCount)
log.Println(msg)
irc.Notice(asker, msg)
return
}