本文整理汇总了Golang中Kari/irc.IRC.Rated方法的典型用法代码示例。如果您正苦于以下问题:Golang IRC.Rated方法的具体用法?Golang IRC.Rated怎么用?Golang IRC.Rated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kari/irc.IRC
的用法示例。
在下文中一共展示了IRC.Rated方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: checkUpdates
func checkUpdates(bot *irc.IRC, source string, context string) {
var manga Manga
var uri, message string
var watched map[string]MangaEntry
loadWatched(&manga)
switch source {
case "mangafox":
uri = "http://mangafox.me/rss/latest_manga_chapters.xml"
watched = manga.MangaFox
case "mangastream":
uri = "http://mangastream.com/rss"
watched = manga.MangaStream
}
data, err := web.Get(&uri)
if err != "" {
logger.Error(err)
return
}
var entries map[string]MangaEntry
entries, perr := parseRSS(data, source)
if perr != nil {
logger.Error(perr.Error())
return
}
keys := getKeys(source)
updates := make([]irc.RatedMessage, 0)
var method string
var newEntry MangaEntry
for title, entry := range entries {
for _, key := range keys {
if strings.Index(title, key) > -1 {
if entry.Date > watched[key].Date {
// update found
switch source {
case "mangastream":
message = fmt.Sprintf("%s is out! \\o/ ~ %s ~ %q",
entry.Title, entry.Link, entry.Desc)
newEntry = MangaEntry{
Manga: entry.Title[:len(key)],
Title: entry.Title,
Date: entry.Date,
Desc: entry.Desc,
Link: entry.Link,
Announce: watched[key].Announce,
}
case "mangafox":
message = fmt.Sprintf("%s is out! \\o/ ~ %s", entry.Title, entry.Link)
newEntry = MangaEntry{
Manga: entry.Title[:len(key)],
Title: entry.Title,
Date: entry.Date,
Link: entry.Link,
Announce: watched[key].Announce,
}
}
delete(watched, key)
watched[key] = newEntry
if context != "" && !lib.HasElementString(watched[key].Announce, context) {
if context[0:1] == "#" {
method = "say"
} else {
method = "notice"
}
updates = append(updates, irc.RatedMessage{
Method: method,
Target: context,
Message: message,
})
}
for _, target := range watched[key].Announce {
if target[0:1] == "#" {
method = "say"
} else {
method = "notice"
}
updates = append(updates, irc.RatedMessage{
Method: method,
Target: target,
Message: message,
})
}
}
}
}
}
if len(updates) > 0 {
bot.Rated(&updates)
saveWatched(&manga)
} else if context != "" {
bot.Say(context, "Nothing new. :\\")
}
}