public ForumFeed(dIRCBot _bot) { Bot = _bot; Thread thread = new Thread(new ThreadStart(MainLoop)); thread.Start(); }
public virtual void ShowToChannel(dIRCBot bot, CommandDetails command) { if (!string.IsNullOrEmpty(Group)) { bot.Chat(command.Channel.Name, bot.ColorGeneral + ":: In group: " + bot.ColorHighlightMajor + Group, 1); } if (!string.IsNullOrEmpty(Plugin)) { bot.Chat(command.Channel.Name, bot.ColorGeneral + ":: Requires the plugin(s): " + bot.ColorHighlightMajor + Plugin, 1); } if (!string.IsNullOrEmpty(Warning)) { bot.Chat(command.Channel.Name, bot.ColorGeneral + ":: WARNING: " + bot.ColorHighlightMajor + Warning, 2); } if (!string.IsNullOrEmpty(Deprecated)) { bot.Chat(command.Channel.Name, bot.ColorGeneral + ":: DEPRECATED: " + bot.ColorHighlightMajor + Deprecated, 2); } if (!string.IsNullOrEmpty(Video)) { bot.Chat(command.Channel.Name, bot.ColorGeneral + ":: Video on the subject:" + bot.ColorLink + " " + Video, 1); } if (command.Arguments.Count >= 2 && command.Arguments[1].ToLower().StartsWith("f")) { bot.Chat(command.Channel.Name, bot.ColorGeneral + ":: Found in internal file: " + FileName, 2); } }
/// <summary> /// Global program entry point. /// </summary> static void Main(string[] args) { Console.WriteLine("Initializing!"); Configuration = new YAMLConfiguration(GetConfig()); List <Task> tasks = new List <Task>(); DiscordBot = new dDiscordBot(); Task.Factory.StartNew(() => DiscordBot.Init(Configuration)); foreach (string server in Configuration.GetKeys("dircbot.irc-servers")) { Console.WriteLine("Preparing server: " + server); tasks.Add(Task.Factory.StartNew(() => { dIRCBot core = new dIRCBot(); lock (presentBotsLock) { PresentBots.Add(core); } core.ServerName = server; core.Init(); })); } while (tasks.Count > 0) { for (int i = 0; i < tasks.Count; i++) { if (tasks[i].IsCompleted) { tasks.RemoveAt(i--); } } Thread.Sleep(100); } Logger.Output(LogType.INFO, "Quitting cleanly."); }
public override void ShowToChannel(dIRCBot bot, CommandDetails command) { bot.Chat(command.Channel.Name, command.Pinger + bot.ColorGeneral + "Found: " + bot.ColorHighlightMajor + Name + ": " + Short, 2); bot.Chat(command.Channel.Name, bot.ColorGeneral + "Syntax: " + bot.ColorHighlightMajor + Info, 2); // TODO Highlight correctly! string arg = command.Arguments.Count >= 2 ? command.Arguments[1].ToLower() : ""; if (arg.StartsWith("a")) { bot.Chat(command.Channel.Name, bot.ColorGeneral + "Author: " + bot.ColorHighlightMajor + Author, 1); } if (arg.StartsWith("d")) { if (bot.Chat(command.Channel.Name, bot.ColorGeneral + "Description: " + bot.ColorHighlightMajor + Description, 3) == 0) { bot.Chat(command.Channel.Name, bot.ColorGeneral + "And more..." + bot.ColorLink + " http://mcmonkey.org/denizen/cmds" + Name); } } if (arg.StartsWith("s")) { bot.Chat(command.Channel.Name, bot.ColorGeneral + "Stability: " + bot.ColorHighlightMajor + Stable, 1); } if (arg.StartsWith("r")) { bot.Chat(command.Channel.Name, bot.ColorGeneral + "Required Arguments: " + bot.ColorHighlightMajor + Reqs, 1); } if (arg.StartsWith("t")) { int limit = 5; foreach (string str in Tags) { // TODO: Dig up tag help short description limit = bot.Chat(command.Channel.Name, bot.ColorGeneral + "Tag: " + str, limit); } if (limit == 0) { bot.Chat(command.Channel.Name, bot.ColorGeneral + "And more..." + bot.ColorLink + " http://mcmonkey.org/denizen/cmds" + Name); } } if (arg.StartsWith("u")) { int limit = 5; foreach (string str in Usage) { foreach (string use in str.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries)) { limit = bot.Chat(command.Channel.Name, bot.ColorGeneral + "Usage: " + use, limit); } } if (limit == 0) { bot.Chat(command.Channel.Name, bot.ColorGeneral + "And more..." + bot.ColorLink + " http://mcmonkey.org/denizen/cmds" + Name); } } base.ShowToChannel(bot, command); }
/// <summary> /// Global program entry point. /// </summary> static void Main(string[] args) { Console.WriteLine("Initializing!"); Configuration = new YAMLConfiguration(GetConfig()); List<Task> tasks = new List<Task>(); DiscordBot = new dDiscordBot(); Task.Factory.StartNew(() => DiscordBot.Init(Configuration)); foreach (string server in Configuration.GetKeys("dircbot.irc-servers")) { Console.WriteLine("Preparing server: " + server); tasks.Add(Task.Factory.StartNew(() => { dIRCBot core = new dIRCBot(); lock (presentBotsLock) { PresentBots.Add(core); } core.ServerName = server; core.Init(); })); } while (tasks.Count > 0) { for (int i = 0; i < tasks.Count; i++) { if (tasks[i].IsCompleted) { tasks.RemoveAt(i--); } } Thread.Sleep(100); } Logger.Output(LogType.INFO, "Quitting cleanly."); }