public void Kill(WinterBot bot, TwitchUser user, string cmd, string value) { bot.WriteDiagnostic(DiagnosticFacility.Info, "Bot killed by streamer."); WinterBotSource.Log.Kill(); bot.Shutdown(); }
static void Main(string[] args) { if (!Debugger.IsAttached) AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Options options = new Options(GetIniFile(args)); if (string.IsNullOrEmpty(options.Channel) || string.IsNullOrEmpty(options.Username) || string.IsNullOrEmpty(options.Password)) { MessageBox.Show("You must first fill in a stream, user, and oauth password to use WinterBot.\n\nPlease follow the instructions here:\nhttps://github.com/DarkAutumn/WinterBot/wiki/Getting-Started", "WinterBot needs configuration!"); Environment.Exit(1); } s_errorFile = options.DataDirectory; string thisExe = Assembly.GetExecutingAssembly().Location; var verInfo = FileVersionInfo.GetVersionInfo(thisExe); string version = string.Format("{0}.{1}", verInfo.ProductMajorPart, verInfo.FileMinorPart); Console.Title = "WinterBot: " + options.Channel; Console.WriteLine("Winterbot {0}", version); Console.WriteLine("Using data folder: {0}", GetDataFolder(options.DataDirectory)); Console.WriteLine("Press Q to quit safely."); Console.WriteLine(); WinterBot bot = new WinterBot(options, options.Channel, options.Username, options.Password); LoadPlugins(options, bot); bot.Connected += delegate(WinterBot b) { WriteLine("Connected to channel: {0}", options.Channel); }; bot.MessageReceived += delegate(WinterBot b, TwitchUser user, string text) { s_messages++; }; bot.ChatClear += delegate(WinterBot b, TwitchUser user) { WriteLine("Chat Clear: {0}", user.Name); }; bot.UserBanned += delegate(WinterBot b, TwitchUser user) { WriteLine("Banned: {0}", user.Name); }; bot.UserTimedOut += delegate(WinterBot b, TwitchUser user, int duration) { WriteLine("Timeout: {0} for {1} seconds", user.Name, duration); }; bot.DiagnosticMessage += delegate(WinterBot b, DiagnosticFacility f, string msg) { WriteLine("Diagnostics: {0}", msg); }; bot.Tick += bot_Tick; Thread t = new Thread(bot.Go); t.Start(); Console.CancelKeyPress += delegate(object sender, ConsoleCancelEventArgs e) { bot.Shutdown(); Environment.Exit(0); }; while (true) { ConsoleKeyInfo key = Console.ReadKey(true); if (key.Key == ConsoleKey.Q) { bot.Shutdown(); Environment.Exit(0); } } }
public void Stop() { m_bot.Shutdown(); }