예제 #1
0
파일: main.go 프로젝트: raindevteam/rain
func main() {
	conf, err := rbot.ReadConfig(config)
	if err != nil {
		panic(err)
	}

	bot := rbot.NewBot(rain.Version(), conf)

	setup.Default(bot)
	bot.DefaultConnect()

	// Logs privmsgs from connected channels
	bot.AddListener("PRIVMSG", func(msg *irc.Message) {
		fmt.Println(msg.Trailing)
	})

	reason, err := bot.WaitForQuit()

	if err != nil {
		fmt.Printf("Quit Error: %s\n", reason)
		os.Exit(1)
	}

	fmt.Printf("Quit: %s\n", reason)
}
예제 #2
0
파일: main.go 프로젝트: raindevteam/rain
func main() {
	if len(os.Args) < 2 {
		program := strings.TrimSuffix(filepath.Base(os.Args[0]), ".exe")
		fmt.Println("Usage: " + program + " config.json")
		os.Exit(1)
	}

	rconf, err := rbot.ReadConfig(os.Args[1])
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	bot := rbot.NewBot(rain.Version(), rconf)
	setup.Default(bot)

	bot.EnableModules()
	bot.DefaultConnectWithMsg("Connecting...", "Done")

	reason, err := bot.WaitForQuit()
	if err != nil {
		fmt.Printf("Quit Error: %s\n", reason)
		os.Exit(1)
	}

	fmt.Printf("Quit: %s\n", reason)
}
예제 #3
0
파일: main.go 프로젝트: raindevteam/rain
func main() {
	flag.Usage = func() {
		program := strings.TrimSuffix(filepath.Base(os.Args[0]), ".exe")
		fmt.Println("Usage: " + program + " [-i | -h] config.json")
		flag.PrintDefaults()
	}

	if len(os.Args) < 2 {
		flag.Usage()
		os.Exit(1)
	}

	flag.Parse()

	confarg := 1
	if *i {
		confarg = 2
	}
	rconf, err := rbot.ReadConfigFile(os.Args[confarg])
	if err != nil {
		panic(err)
	}

	var (
		preConnectMsg, postConnectMsg string
		bot                           *rbot.Bot
	)

	if *i {
		preConnectMsg, postConnectMsg = "", ""
		bot = cbot.NewCLIBot(rconf)
	} else {
		preConnectMsg, postConnectMsg = "Connecting... ", "Done"
		bot = rbot.NewBot(rain.Version(), rconf)
	}

	setup.Default(bot)
	bot.EnableModules()
	bot.DefaultConnectWithMsg(preConnectMsg, postConnectMsg)

	reason, err := bot.WaitForQuit()

	if err != nil {
		fmt.Printf("Quit Error: %s\n", reason)
		os.Exit(1)
	}

	fmt.Printf("Quit: %s\n", reason)
}
예제 #4
0
파일: main.go 프로젝트: raindevteam/rain
func main() {
	app := cli.NewApp()
	app.Name = "rain"
	app.Usage = "Command line tool for the management of everything Rain"
	app.Version = rain.Version()

	app.Commands = []cli.Command{
		rain.CommandInstall,
		rain.CommandModule,
		rain.CommandConfig,
		rain.CommandDepends,
		rain.CommandVersion,
	}

	app.Run(os.Args)
}
예제 #5
0
파일: bot.go 프로젝트: raindevteam/rain
// RainVersion returns the library version
func (b *Bot) RainVersion() string {
	return rain.Version()
}