예제 #1
0
파일: main.go 프로젝트: Kaioshi/Kari
func main() {
	conf := &config.Config{}
	conf.Parse()
	info := &globals.Info{}
	bot := &irc.IRC{Config: *conf, Info: *info}

	// required
	core.Register(bot)
	ial.Register(bot)
	alias.Register(conf)
	aliasfrontend.Register(bot)

	// optional - comment out if you don't want 'em
	google.Register(bot)
	youtube.Register(bot)
	urbandictionary.Register(bot)
	manga.Register(bot)
	titlesnarfer.Register(bot)

	timer.AddEvent("Garbage Collect", 15, lib.GC)

	bot.Start()
}
예제 #2
0
파일: manga.go 프로젝트: Kaioshi/Kari
func Register(bot *irc.IRC) {
	defer logger.Info(lib.TimeTrack(time.Now(), "Loading the MangaStream plugin"))

	timer.AddEvent("Checking Manga Sources", 900, func() {
		checkUpdates(bot, "mangafox", "")
		checkUpdates(bot, "mangastream", "")
	})

	events.CmdListen(&events.CmdListener{
		Commands: []string{"mangastream", "ms"},
		Help:     "Manages the MangaStream release watcher",
		Syntax: fmt.Sprintf("%sms <add/remove/list> <manga title> - Example: %sms add One Piece",
			bot.Config.Prefix, bot.Config.Prefix),
		Callback: func(input *events.Params) {
			if len(input.Args) == 0 {
				bot.Say(input.Context, events.Help("ms", "syntax"))
				return
			}
			var manga Manga
			loadWatched(&manga)
			switch strings.ToLower(input.Args[0]) {
			case "list":
				if len(manga.MangaStream) == 0 {
					bot.Say(input.Context, "I'm not watching for any MangaStream releases right now. :<")
					return
				}
				var titles string
				for _, entry := range manga.MangaStream {
					if entry.Manga == "" {
						titles += entry.Title + ", "
					} else {
						titles += entry.Manga + ", "
					}
				}
				bot.Say(input.Context, fmt.Sprintf("I'm currently watching for %s updates to %s.",
					"MangaStream", titles[:len(titles)-2]))
			case "add":
				if len(input.Args) < 2 {
					bot.Say(input.Context, events.Help("ms", "syntax"))
					return
				}
				bot.Say(input.Context, addManga(&manga, strings.Join(input.Args[1:], " "), input.Context, "MangaStream", bot))
			case "remove":
				if len(input.Args) < 2 {
					bot.Say(input.Context, events.Help("ms", "syntax"))
					return
				}
				bot.Say(input.Context, removeManga(&manga, strings.Join(input.Args[1:], " "), "MangaStream"))
			case "check":
				checkUpdates(bot, "mangastream", input.Context)
			}
		}})

	events.CmdListen(&events.CmdListener{ // not sure how to make this neat yet ^ v
		Commands: []string{"mangafox", "mf"},
		Help:     "Manages the MangaFox release watcher",
		Syntax: fmt.Sprintf("%smf <add/remove/list> <manga title> - Example: %smf add One Piece",
			bot.Config.Prefix, bot.Config.Prefix),
		Callback: func(input *events.Params) {
			if len(input.Args) == 0 {
				bot.Say(input.Context, events.Help("mf", "syntax"))
				return
			}
			var manga Manga
			loadWatched(&manga)
			switch strings.ToLower(input.Args[0]) {
			case "list":
				if len(manga.MangaFox) == 0 {
					bot.Say(input.Context, "I'm not watching for any MangaFox releases right now. :<")
					return
				}
				var titles string
				for _, entry := range manga.MangaFox {
					if entry.Manga == "" {
						titles += entry.Title + ", "
					} else {
						titles += entry.Manga + ", "
					}
				}
				bot.Say(input.Context, fmt.Sprintf("I'm currently watching for %s updates to %s.",
					"MangaFox", titles[:len(titles)-2]))
			case "add":
				if len(input.Args) < 2 {
					bot.Say(input.Context, events.Help("mf", "syntax"))
					return
				}
				bot.Say(input.Context, addManga(&manga, strings.Join(input.Args[1:], " "), input.Context, "MangaFox", bot))
			case "remove":
				if len(input.Args) < 2 {
					bot.Say(input.Context, events.Help("mf", "syntax"))
					return
				}
				bot.Say(input.Context, removeManga(&manga, strings.Join(input.Args[1:], " "), "MangaFox"))
			case "check":
				checkUpdates(bot, "mangafox", input.Context)
			}
		}})
}