private void RequestSbState(BotShell bot, string user) { ShadowbreedState state; lock (this.Shadowbreeds) { if (!this.Shadowbreeds.ContainsKey(user.ToLower())) { return; } state = this.Shadowbreeds[user.ToLower()]; } RichTextWindow window = new RichTextWindow(bot); window.AppendTitle("Shadowbreed"); window.AppendHighlight("Intro"); window.AppendLineBreak(); window.AppendNormal("You have been requested to set your Shadowbreed state."); window.AppendLineBreak(); window.AppendNormal("Your current Shadowbreed state is: "); window.AppendRawString(this.ColorizeState(state)); window.AppendLineBreak(); window.AppendNormal("Please select one of the following states that best suits your situation."); window.AppendLineBreak(2); window.AppendHighlight("Up "); window.AppendNormal("["); window.AppendBotCommand("Set", "sb set " + user + " up"); window.AppendNormal("] "); window.AppendLineBreak(); window.AppendNormal("Your Shadowbreed is up and available to use."); window.AppendLineBreak(); window.AppendNormal("You're alive and present at the raid."); window.AppendLineBreak(2); window.AppendHighlight("Down "); window.AppendNormal("["); window.AppendBotCommand("Set", "sb set " + user + " down"); window.AppendNormal("] "); window.AppendLineBreak(); window.AppendNormal("Your Shadowbreed is not up and can't be used."); window.AppendLineBreak(); window.AppendNormal("You're alive and present at the raid."); window.AppendLineBreak(2); window.AppendHighlight("Unavailable "); window.AppendNormal("["); window.AppendBotCommand("Set", "sb set " + user + " unavailable"); window.AppendNormal("] "); window.AppendLineBreak(); window.AppendNormal("You don't have a Shadowbreed."); window.AppendLineBreak(); window.AppendNormal("Or you're not present at the raid."); bot.SendPrivateMessage(user, bot.ColorHighlight + "Please set your Shadowbreed state »» " + window.ToString(), AoLib.Net.PacketQueue.Priority.Urgent, true); }
private void OnSecurityCommand(BotShell bot, CommandArgs e) { bot.SendReply(e, "Gathering Data. This can take several minutes. Please stand by..."); RichTextWindow window = new RichTextWindow(bot); window.AppendTitle("Invalid ID's / Rerolled Characters"); List <SecurityProcessItem> members = new List <SecurityProcessItem>(); lock (this._database.Connection) { using (IDbCommand command = this._database.Connection.CreateCommand()) { command.CommandText = "SELECT username as name, userID as id, 'Main' as type FROM members UNION SELECT altname, altID, 'Alt' FROM alts ORDER BY name"; IDataReader reader = command.ExecuteReader(); while (reader.Read()) { string username = reader.GetString(0); UInt32 userID = (UInt32)reader.GetInt64(1); string type = reader.GetString(2); members.Add(new SecurityProcessItem(username, userID, type)); } reader.Close(); } } foreach (SecurityProcessItem member in members) { UInt32 realID = bot.GetUserID(member.Username); if (realID == 0) { window.AppendHighlight(member.Username); window.AppendNormalStart(); window.AppendString(" (" + member.Type + ") ("); window.AppendColorString(RichTextWindow.ColorRed, "Deleted"); window.AppendString(") ["); window.AppendBotCommand("Account", "account " + member.Username); window.AppendString("]"); window.AppendColorEnd(); window.AppendLineBreak(); } else if (realID != member.UserID) { window.AppendHighlight(member.Username); window.AppendNormalStart(); window.AppendString(" (Current=" + member.UserID + " Real=" + realID + ") (" + member.Type + ") ("); window.AppendColorString(RichTextWindow.ColorOrange, "Invalid ID"); window.AppendString(") ["); window.AppendBotCommand("Account", "account " + member.Username); window.AppendString("] ["); window.AppendBotCommand("Fix", "security fixid " + member.Username); window.AppendString("]"); window.AppendColorEnd(); window.AppendLineBreak(); } } bot.SendReply(e, "Security Report »» ", window); }
private void OnGlyphsCommand(BotShell bot, CommandArgs e) { RichTextWindow window = new RichTextWindow(bot); window.AppendTitle(); string raffle = string.Empty; bool empty = true; lock (this._items) { foreach (KeyValuePair <int, string> kvp in this._items) { window.AppendHeader(kvp.Value); int i = 0; lock (this._database.Connection) { using (IDbCommand command = this._database.Connection.CreateCommand()) { command.CommandText = "SELECT id, looter, time FROM glyphs WHERE item = " + kvp.Key + " AND visible = 'true'"; IDataReader reader = command.ExecuteReader(); while (reader.Read()) { i++; window.AppendNormal(Format.DateTime(reader.GetInt64(2), FormatStyle.Compact) + " "); window.AppendHighlight(reader.GetString(1)); window.AppendLineBreak(); empty = false; } reader.Close(); } } if (i == 0) { window.AppendHighlight("None"); window.AppendLineBreak(); } window.AppendLineBreak(); raffle += " " + i; } } if (!empty) { window.AppendHeader("Options"); window.AppendBotCommand("Start Raffle", "glyphs raffle" + raffle); window.AppendLineBreak(); window.AppendBotCommand("Clear List", "glyphs clear"); bot.SendReply(e, "Glyphs List »» ", window); } else { bot.SendReply(e, "The glyphs list is current empty"); } }
private void OnVoteStatusCommand(BotShell bot, CommandArgs e) { if (!this._running) { bot.SendPrivateMessage(e.SenderID, "There is nothing to vote on."); } else { RichTextWindow window = new RichTextWindow(bot); window.AppendTitle(this._admin + " has initiated an election!"); window.AppendLineBreak(); window.AppendString("You are being asked to vote for or against the following topic:"); window.AppendLineBreak(); window.AppendLineBreak(); window.AppendString(_description); window.AppendLineBreak(); window.AppendNormalStart(); window.AppendString("["); window.AppendBotCommand("Yes", "vote yes"); window.AppendString("] ["); window.AppendBotCommand("No", "vote no"); window.AppendString("] ["); window.AppendBotCommand("Abstain", "vote abstain"); window.AppendString("]"); window.AppendLineBreak(); window.AppendLineBreak(); window.AppendString("There are currently " + Convert.ToString(_yes + _no) + " votes. "); if ((_quorum > 0) && (_yes + _no + _abs < _quorum)) { window.AppendString("Quorum has not yet been met."); } else { window.AppendString("Quorum has been met."); } if ((e.Sender == this._admin) || (bot.Users.GetUser(e.Sender) >= UserLevel.Leader)) { window.AppendLineBreak(); window.AppendLineBreak(); window.AppendString("Quorum is currently: " + Convert.ToString(_quorum) + " with a " + Convert.ToString(_percentage) + "% approval in order to win this election."); window.AppendLineBreak(); window.AppendString("["); window.AppendBotCommand("End Voting", "vote stop"); window.AppendString("] ["); window.AppendBotCommand("Abort Voting", "vote abort"); window.AppendString("]"); } string output = string.Format("{1}{2}{0} has initiated an election »» ", bot.ColorHighlight, bot.ColorHeader, this._admin) + window.ToString(); // bot.SendPrivateChannelMessage(output); bot.SendPrivateMessage(e.SenderID, output); } }
private void OnRaidBansCommand(BotShell bot, CommandArgs e) { if (!this._core.Running) { bot.SendReply(e, "There is currently no raid active"); return; } lock (this._bans) { if (this._bans.Count < 1) { bot.SendReply(e, "Nobody is banned from the raid"); return; } RichTextWindow window = new RichTextWindow(bot); window.AppendTitle("Raid Bans"); foreach (KeyValuePair <string, Raider> kvp in this._bans) { TimeSpan ts = (new TimeSpan(0, kvp.Value.Duration, 0)) - (DateTime.Now - kvp.Value.Time); window.AppendHighlight(Math.Floor(ts.TotalMinutes).ToString("##00") + ":" + ts.Seconds.ToString("00")); window.AppendNormal(" - "); window.AppendHighlight(kvp.Value.Character + " "); if (kvp.Value.Character != kvp.Key) { window.AppendNormal("(Main: " + kvp.Key + ") "); } window.AppendNormal("["); window.AppendBotCommand("Unban", "raid unban " + kvp.Key); window.AppendNormal("]"); window.AppendLineBreak(); } bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, this._bans.Count.ToString()) + " Raid Bans »» ", window); } }
private void OnCommandsCommand(BotShell bot, CommandArgs e) { RichTextWindow window = new RichTextWindow(bot); window.AppendTitle("Command Rights"); foreach (string plugin in bot.Plugins.GetPlugins()) { if (bot.Plugins.GetState(plugin) == PluginState.Loaded) { string[] commands = bot.Commands.GetCommands(plugin); if (commands.Length > 0) { PluginLoader loader = bot.Plugins.GetLoader(plugin); window.AppendNormalStart(); window.AppendString("["); window.AppendBotCommand("Configure", "commands " + plugin.ToLower()); window.AppendString("] "); window.AppendColorEnd(); window.AppendHighlight(loader.Name); window.AppendNormal(" (" + commands.Length + " commands)"); window.AppendLineBreak(); } } } bot.SendReply(e, "Commands »» ", window); }
private void OnConfigurationCommand(BotShell bot, CommandArgs e) { string[] plugins = bot.Configuration.ListRegisteredPlugins(); if (plugins == null || plugins.Length == 0) { bot.SendReply(e, "No configuration entries registered"); return; } RichTextWindow window = new RichTextWindow(bot); window.AppendTitle("Configuration"); foreach (string plugin in plugins) { PluginLoader loader = bot.Plugins.GetLoader(plugin); window.AppendNormalStart(); window.AppendString("["); window.AppendBotCommand("Configure", "configuration " + plugin.ToLower()); window.AppendString("] "); window.AppendColorEnd(); window.AppendHighlight(loader.Name); window.AppendNormal(" (" + bot.Configuration.List(plugin).Length + " settings)"); window.AppendLineBreak(); } bot.SendReply(e, "Configuration »» ", window); }
private void OnRosterResetCommand(BotShell bot, CommandArgs e) { if (e.Args.Length > 0) { if (e.Args[0].ToLower() == "confirm") { this._database.ExecuteNonQuery("DELETE FROM members"); bot.SendReply(e, "Roster list cleared"); return; } } RichTextWindow window = new RichTextWindow(bot); window.AppendTitle("Clear Cached Roster List"); window.AppendNormal("Warning! This will clear the local roster list!"); window.AppendLineBreak(); window.AppendNormal("This list is used to determine changes in the organization's member list."); window.AppendLineBreak(); window.AppendNormal("Clearing this list will NOT remove any members from the bot!"); window.AppendLineBreak(); window.AppendNormal("After clearing this list, the next roster update will see every member of the organization as a new member."); window.AppendLineBreak(); window.AppendNormal("Resetting the cached roster list can be used to resolve some sync issues but may also leave 'ghost' members behind."); window.AppendLineBreak(); window.AppendNormal("Use this command with caution!"); window.AppendLineBreak(2); window.AppendBotCommand("Reset List Now", "roster reset confirm"); bot.SendReply(e, "Roster Reset »» " + window.ToString()); }
private void StartedEvent(object sender, EventArgs e) { if (this.CreditsEnabled) { if (!this._core.Locked) { this._core.Locked = true; //this._bot.SendPrivateChannelMessage(this._bot.ColorHighlight + "The raid has been " + HTML.CreateColorString(RichTextWindow.ColorRed, "locked") + " pending raid credits type selection"); } this.CreditsType = -1; RichTextWindow window = new RichTextWindow(this._bot); window.AppendTitle("Raid Credits Selection"); window.AppendHighlight("The raid credits system has been enabled."); window.AppendLineBreak(); window.AppendHighlight("Please select which type of raid credits should be used for this raid."); window.AppendLineBreak(2); lock (this._database.Connection) { using (IDbCommand command = this._database.Connection.CreateCommand()) { command.CommandText = "SELECT type, name, description, credits FROM credits_types"; IDataReader reader = command.ExecuteReader(); while (reader.Read()) { window.AppendHeader(reader.GetString(1)); window.AppendHighlight(reader.GetString(2)); window.AppendLineBreak(); window.AppendNormal("["); window.AppendBotCommand("Select", "raid credits " + reader.GetInt32(0)); window.AppendNormal("]"); window.AppendLineBreak(2); } reader.Close(); } } window.AppendHeader("No Credits"); window.AppendHighlight("Selecting this option will cause no raid credits to be charged this raid."); window.AppendLineBreak(); window.AppendHighlight("This option is useful for unannounced or unplanned raids."); window.AppendLineBreak(); window.AppendNormal("["); window.AppendBotCommand("Select", "raid unlock"); window.AppendNormal("]"); window.AppendLineBreak(2); this._bot.SendPrivateChannelMessage(this._bot.ColorHighlight + "Please select raid credits type »» " + window.ToString()); } }
private void OnCallersCommand(BotShell bot, CommandArgs e) { if (this.Callers.Count < 1) { bot.SendReply(e, "There are no assigned callers"); return; } RichTextWindow callersWindow = new RichTextWindow(bot); callersWindow.AppendTitle("Callers"); string assistAll = string.Empty; lock (this.Callers) { foreach (string caller in this.Callers) { callersWindow.AppendHighlight(Format.UppercaseFirst(caller)); callersWindow.AppendNormalStart(); callersWindow.AppendString(" ["); callersWindow.AppendCommand("Assist", "/assist " + caller); callersWindow.AppendString("] ["); callersWindow.AppendCommand("Macro", "/macro " + caller + " /assist " + caller); callersWindow.AppendString("] ["); callersWindow.AppendBotCommand("Remove", "callers remove " + caller); callersWindow.AppendString("]"); callersWindow.AppendColorEnd(); callersWindow.AppendLineBreak(); assistAll += "/assist " + caller + "\\n "; } } callersWindow.AppendLineBreak(); callersWindow.AppendHeader("Options"); callersWindow.AppendHighlight("Assist All: "); callersWindow.AppendCommand("Click", assistAll.Substring(0, assistAll.Length - 3)); callersWindow.AppendLineBreak(); callersWindow.AppendHighlight("Assist All Macro: "); callersWindow.AppendNormal("/macro assist " + assistAll.Substring(0, assistAll.Length - 3)); callersWindow.AppendLineBreak(); callersWindow.AppendHighlight("Clear List: "); callersWindow.AppendBotCommand("Click", "callers remove all"); bot.SendReply(e, "Callers »» ", callersWindow); }
private void OnHelpCommand(BotShell bot, CommandArgs e) { RichTextWindow window = new RichTextWindow(bot); window.AppendTitle("VhaBot Help"); bool found = false; foreach (string plugin in bot.Plugins.GetPlugins()) { if (bot.Plugins.IsLoaded(plugin)) { string[] commands = bot.Commands.GetCommands(plugin); List <string> helpCommands = new List <string>(); foreach (string command in commands) { CommandRights rights = bot.Commands.GetRights(command); if (rights.Help && !rights.IsAlias) { helpCommands.Add(command); } } helpCommands.Sort(); if (helpCommands.Count > 0) { PluginLoader loader = bot.Plugins.GetLoader(plugin); window.AppendHighlight(loader.Name); window.AppendLineBreak(); window.AppendNormalStart(); int i = 0; foreach (string command in helpCommands) { window.AppendBotCommand(Format.UppercaseFirst(command), "help " + command); i++; if (i < helpCommands.Count) { window.AppendString(", "); } } window.AppendColorEnd(); window.AppendLineBreak(2); found = true; } } } if (found) { bot.SendReply(e, "VhaBot Help »» ", window); } else { bot.SendReply(e, "No help available"); } }
private void OnAuctionCommand(BotShell bot, CommandArgs e) { if (!this._running) { bot.SendReply(e, "There is currently no auction running"); return; } RichTextWindow window = new RichTextWindow(bot); window.AppendTitle("Auction"); window.AppendHighlight("Item: "); window.AppendNormalStart(); window.AppendRawString(this._item); window.AppendString(" ["); window.AppendBotCommand("Abort", "auction abort"); window.AppendString("]"); window.AppendColorEnd(); window.AppendLineBreak(); window.AppendHighlight("High Bidder: "); if (this._currentBid > 0) { window.AppendNormal(this._bidder); window.AppendLineBreak(); window.AppendHighlight("High Bid: "); window.AppendNormal(this._currentBid.ToString()); } else { window.AppendNormal("N/A"); } window.AppendLineBreak(); double points = this._core.GetPoints(e.Sender); if (points > this._core.MinimumPoints) { window.AppendHighlight("Your Points: "); if (points > this._currentBid) { window.AppendColorString(RichTextWindow.ColorGreen, points.ToString()); } else { window.AppendColorString(RichTextWindow.ColorRed, points.ToString()); } window.AppendLineBreak(); } window.AppendHighlight("Time Left: "); window.AppendNormal(this._timeLeft.ToString() + " seconds"); window.AppendLineBreak(); bot.SendReply(e, "Auction »» ", window); }
public void OnLinksCommand(BotShell bot, CommandArgs e) { RichTextWindow window = new RichTextWindow(bot); window.AppendTitle(); int links = 0; using (IDbCommand command = this._database.Connection.CreateCommand()) { command.CommandText = "SELECT id, category, link, description FROM links ORDER BY category, description"; IDataReader reader = command.ExecuteReader(); string lastCategory = ""; while (reader.Read()) { int id = reader.GetInt32(0); string category = reader.GetString(1); string link = reader.GetString(2); string description = reader.GetString(3); if (category != lastCategory) { if (links > 0) { window.AppendLineBreak(); } window.AppendHeader(category); lastCategory = category; } window.AppendHighlight(description); window.AppendNormalStart(); window.AppendString(" ["); window.AppendCommand("Visit", "/start " + link); window.AppendString("] ["); window.AppendBotCommand("Remove", "links remove " + id); window.AppendString("]"); window.AppendColorEnd(); window.AppendLineBreak(); links++; } } if (links > 0) { bot.SendReply(e, "Links and Bookmarks »» ", window); } else { bot.SendReply(e, "There are currently no links in the database"); } }
private void CreateSelectLine(BotShell bot, ref RichTextWindow window, string command) { CommandRights rights = bot.Commands.GetRights(command); command = command.Replace(" ", "_"); this.CreateSelectPanel(ref window, rights.PrivateMessage, "commands set " + command + " tell"); window.AppendString(" "); this.CreateSelectPanel(ref window, rights.PrivateChannel, "commands set " + command + " pg"); window.AppendString(" "); this.CreateSelectPanel(ref window, rights.Organization, "commands set " + command + " org"); window.AppendHighlight(" " + Format.UppercaseFirst(command.Replace("_", " "))); window.AppendNormalStart(); window.AppendString(" ["); window.AppendBotCommand("Reset", "commands reset " + command); window.AppendString("]"); window.AppendColorEnd(); }
private void OnTasksCommand(BotShell bot, CommandArgs e) { string message = "Tasks"; RichTextWindow window = new RichTextWindow(bot); window.AppendTitle("Tasks"); bool found = false; using (IDbCommand command = this._database.Connection.CreateCommand()) { command.CommandText = "SELECT username, task FROM tasks ORDER BY username"; IDataReader reader = command.ExecuteReader(); while (reader.Read()) { found = true; window.AppendHighlight(reader.GetString(0) + ": "); window.AppendNormal(reader.GetString(1).Trim() + " ["); window.AppendBotCommand("Remove", "tasks remove " + reader.GetString(0)); window.AppendNormal("]"); window.AppendLineBreak(); if (e.Sender == reader.GetString(0)) { message = "You have been assigned the following task: " + HTML.CreateColorString(bot.ColorHeaderHex, reader.GetString(1)); } } reader.Close(); } if (!found) { bot.SendReply(e, "No tasks assigned"); } else { bot.SendReply(e, message + " »» ", window); } }
private void CreateSelectPanel(ref RichTextWindow window, UserLevel right, string command) { command = command.Trim(); window.AppendNormalStart(); window.AppendString("["); window.AppendBotCommand("D", command + " Disabled", (right == UserLevel.Disabled)); window.AppendString(" "); window.AppendBotCommand("G", command + " Guest", (right == UserLevel.Guest)); window.AppendString(" "); window.AppendBotCommand("M", command + " Member", (right == UserLevel.Member)); window.AppendString(" "); window.AppendBotCommand("L", command + " Leader", (right == UserLevel.Leader)); window.AppendString(" "); window.AppendBotCommand("A", command + " Admin", (right == UserLevel.Admin)); window.AppendString(" "); window.AppendBotCommand("S", command + " SuperAdmin", (right == UserLevel.SuperAdmin)); window.AppendString("]"); window.AppendColorEnd(); }
private void OnRaidListCommand(BotShell bot, CommandArgs e) { if (!this._core.Running) { bot.SendReply(e, "There is currently no raid active"); return; } RaidCore.Raider[] raiders = this._core.GetRaiders(); if (raiders.Length == 0) { bot.SendReply(e, "There is currently nobody on the raid"); return; } RichTextWindow window = new RichTextWindow(bot); window.AppendTitle("Raiders List"); SortedDictionary <string, Dictionary <RaidCore.Raider, WhoisResult> > sorted = new SortedDictionary <string, Dictionary <RaidCore.Raider, WhoisResult> >(); foreach (RaidCore.Raider raider in raiders) { WhoisResult whois = XML.GetWhois(raider.Character, bot.Dimension); if (whois == null || !whois.Success) { whois = new WhoisResult(); whois.Name = new WhoisResult_Name(); whois.Name.Nickname = raider.Character; whois.Stats = new WhoisResult_Stats(); whois.Stats.Level = 0; whois.Stats.Profession = "Unknown"; whois.Stats.DefenderLevel = 0; } if (!sorted.ContainsKey(whois.Stats.Profession)) { sorted.Add(whois.Stats.Profession, new Dictionary <RaidCore.Raider, WhoisResult>()); } sorted[whois.Stats.Profession].Add(raider, whois); } foreach (KeyValuePair <string, Dictionary <RaidCore.Raider, WhoisResult> > kvp in sorted) { window.AppendHighlight(kvp.Key); window.AppendLineBreak(); foreach (KeyValuePair <RaidCore.Raider, WhoisResult> raider in kvp.Value) { window.AppendNormalStart(); window.AppendString("- " + raider.Key.Character); if (raider.Key.Main != raider.Key.Character) { window.AppendString(" (" + raider.Key.Main + ")"); } if (raider.Value.Stats.Profession != "Unknown") { window.AppendString(" (L " + raider.Value.Stats.Level + "/" + raider.Value.Stats.DefenderLevel + ")"); } if (!raider.Key.OnRaid) { window.AppendString(" ("); window.AppendColorString(RichTextWindow.ColorRed, "Inactive"); window.AppendString(")"); } window.AppendString(" ["); window.AppendCommand("Check", "/assist " + raider.Key.Character); window.AppendString("] ["); window.AppendBotCommand("Kick", "raid kick " + raider.Key.Character); window.AppendString("] "); window.AppendColorEnd(); window.AppendLineBreak(true); } window.AppendLineBreak(); } bot.SendReply(e, "Raiders List »» ", window); }
public void BuildList(BotShell bot, string[] users, ref RichTextWindow window, ref int results, string profs) { if (window == null) { return; } if (users.Length == 0) { return; } SortedDictionary <string, SortedDictionary <string, WhoisResult> > list = new SortedDictionary <string, SortedDictionary <string, WhoisResult> >(); Dictionary <string, WhoisResult> whoisResults = new Dictionary <string, WhoisResult>(); foreach (string user in users) { if (user == null || user == string.Empty) { continue; } string header; WhoisResult whois = XML.GetWhois(user, bot.Dimension); if (profs != null && profs != string.Empty) { if (whois == null || whois.Stats == null) { continue; } if (!whois.Stats.Profession.StartsWith(profs, StringComparison.CurrentCultureIgnoreCase)) { continue; } } if (whois != null && whois.Stats != null) { if (this.DisplayMode == "Level") { header = whois.Stats.Level.ToString(); } else { header = whois.Stats.Profession; } if (!whoisResults.ContainsKey(user.ToLower())) { whoisResults.Add(user.ToLower(), whois); } } else if (this.DisplayMode == "Level") { header = "0"; } else { header = "Unknown"; } if (this.DisplayMode == "Alphabetical") { header = user.ToUpper().ToCharArray()[0].ToString(); } if (!list.ContainsKey(header)) { list.Add(header, new SortedDictionary <string, WhoisResult>()); } list[header].Add(user, whois); } results = 0; foreach (KeyValuePair <string, SortedDictionary <string, WhoisResult> > prof in list) { if (this.DisplayHeaders == "Text") { window.AppendHighlight(prof.Key); window.AppendLineBreak(); } else if (this.DisplayHeaders == "Icons") { window.AppendImage("GFX_GUI_FRIENDLIST_SPLITTER"); window.AppendLineBreak(); window.AppendIcon(Icons[prof.Key]); window.AppendHighlight(prof.Key); window.AppendLineBreak(); window.AppendImage("GFX_GUI_FRIENDLIST_SPLITTER"); window.AppendLineBreak(); } foreach (KeyValuePair <string, WhoisResult> user in prof.Value) { // Name window.AppendNormalStart(); window.AppendString(" "); int level = 0; int ailevel = 0; string name = Format.UppercaseFirst(user.Key); // Level if (user.Value != null && user.Value.Stats != null) { level = user.Value.Stats.Level; ailevel = user.Value.Stats.DefenderLevel; } if (level < 10) { window.AppendColorString("000000", "00"); } else if (level < 100) { window.AppendColorString("000000", "0"); } window.AppendString(level + " "); if (ailevel < 10) { window.AppendColorString("000000", "0"); } window.AppendColorString(RichTextWindow.ColorGreen, ailevel + " "); window.AppendString(name); // Organization bool displayOrganization = false; if (this.DisplayOrganization == "Always") { displayOrganization = true; } if (this.DisplayOrganization == "Foreign") { displayOrganization = true; if (bot.InOrganization && whoisResults.ContainsKey(name.ToLower()) && whoisResults[name.ToLower()].InOrganization && bot.Organization == whoisResults[name.ToLower()].Organization.Name) { displayOrganization = false; } } if (displayOrganization) { if (!whoisResults.ContainsKey(name.ToLower())) { window.AppendString(" (Unknown)"); } else if (whoisResults[name.ToLower()].InOrganization) { window.AppendString(" (" + whoisResults[name.ToLower()].Organization.ToString() + ")"); } else { window.AppendString(" (Not Guilded)"); } } // Rank if (this.DisplayRanks) { UserLevel userLevel = bot.Users.GetUser(name); if (userLevel > UserLevel.Member) { window.AppendString(" ("); window.AppendColorString(RichTextWindow.ColorRed, bot.Users.GetUser(name).ToString()); window.AppendString(")"); } } // Alts if (this.DisplayAlts) { string main = bot.Users.GetMain(name); string[] alts = bot.Users.GetAlts(main); if (alts.Length > 0) { window.AppendString(" :: "); if (main == name) { window.AppendBotCommand("Alts", "alts " + main); } else { window.AppendBotCommand(main + "'s Alts", "alts " + main); } } } // Afk if (this.DisplayAfk) { lock (this.Afk) { if (this.Afk.ContainsKey(name)) { window.AppendString(" :: "); window.AppendColorString(RichTextWindow.ColorRed, "AFK"); } } } window.AppendColorEnd(); window.AppendLineBreak(); results++; } if (this.DisplayHeaders == "Text" || this.DisplayHeaders == "Icons") { window.AppendLineBreak(); } } if (this.DisplayHeaders == "Off") { window.AppendLineBreak(); } }
public override void OnCommand(BotShell bot, CommandArgs e) { if (e.FromSlave && e.Type == CommandType.PrivateChannel) { return; } switch (e.Command) { case "lock": if (this._locked) { bot.SendReply(e, "The private channel already is locked"); return; } this._lockedBy = e.Sender; this._locked = true; string lockMessage = bot.ColorHeader + e.Sender + bot.ColorHighlight + " has locked the private channel"; this.SendMessage(bot, lockMessage); break; case "unlock": if (!this._locked) { bot.SendReply(e, "The private channel already is unlocked"); return; } this._locked = false; string unlockMessage = bot.ColorHeader + e.Sender + bot.ColorHighlight + " has unlocked the private channel"; this.SendMessage(bot, unlockMessage); break; case "join": if (bot.PrivateChannel.IsOn(e.SenderID)) { bot.SendReply(e, "You already are on the private channel"); return; } if (this._locked && bot.Users.GetUser(e.Sender) < UserLevel.Leader) { bot.SendReply(e, "The private channel is currently locked by " + bot.ColorHeader + this._lockedBy); return; } bot.SendReply(e, "Inviting you to the private channel"); bot.PrivateChannel.Invite(e.SenderID); break; case "leave": if (!bot.PrivateChannel.IsOn(e.SenderID)) { bot.SendReply(e, "You're not on the private channel"); return; } if (e.Type != CommandType.PrivateChannel) { bot.SendReply(e, "Kicking you from the private channel"); } // Remove a user from the vhabot raid system before letting him leave if (bot.Plugins.IsLoaded("raidcore")) { bot.SendPluginMessageAndWait(this.InternalName, "raidcore", "RemoveRaider", 1000, e.Sender); } bot.PrivateChannel.Kick(e.SenderID); break; case "invite": if (e.Args.Length < 1) { bot.SendReply(e, "Correct Usage: invite [username]"); break; } if (bot.GetUserID(e.Args[0]) < 1) { bot.SendReply(e, "No such user: "******" already is on the private channel"); break; } if (this._locked && bot.Users.GetUser(e.Sender) < UserLevel.Leader) { bot.SendReply(e, "The private channel is currently locked by " + bot.ColorHeader + this._lockedBy); return; } bot.SendReply(e, "Inviting " + HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(e.Args[0])) + " to the private channel"); bot.PrivateChannel.Invite(e.Args[0]); break; case "kick": if (e.Args.Length < 1) { bot.SendReply(e, "Correct Usage: kick [username]"); break; } if (e.Args[0].ToLower() == "all") { bot.SendReply(e, "Clearing the private channel"); bot.PrivateChannel.KickAll(); break; } if (bot.GetUserID(e.Args[0]) < 1) { bot.SendReply(e, "No such user: "******" isn't on the private channel"); break; } if (bot.Users.GetMain(e.Args[0]).Equals(bot.Admin, StringComparison.CurrentCultureIgnoreCase)) { bot.SendReply(e, "You can't kick the bot owner"); break; } if (bot.Users.GetUser(e.Args[0]) > bot.Users.GetUser(e.Sender)) { bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(e.Args[0])) + " outranks you"); break; } // Remove a user from the vhabot raid system before kicking them if (bot.Plugins.IsLoaded("RaidCore")) { bot.SendPluginMessageAndWait(this.InternalName, "raidcore", "RemoveRaider", 1000, e.Args[0]); } bot.SendReply(e, "Kicking " + HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(e.Args[0])) + " from the private channel"); bot.PrivateChannel.Kick(e.Args[0]); break; case "guestlist": string[] guestlist = bot.FriendList.List("guestlist"); if (guestlist.Length == 0) { bot.SendReply(e, "There are no users on the guestlist"); break; } RichTextWindow window = new RichTextWindow(bot); window.AppendTitle("Guestlist"); foreach (string guest in guestlist) { window.AppendHighlight(Format.UppercaseFirst(guest)); window.AppendNormalStart(); window.AppendString(" ["); window.AppendBotCommand("Remove", "guestlist remove " + guest); window.AppendString("]"); window.AppendColorEnd(); window.AppendLineBreak(); } bot.SendReply(e, guestlist.Length + " Guests »» ", window); break; case "guestlist add": if (e.Args.Length < 1) { bot.SendReply(e, "Correct Usage: guestlist add [username]"); break; } if (bot.GetUserID(e.Args[0]) < 1) { bot.SendReply(e, "No such user: "******"guestlist", e.Args[0])) { bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(e.Args[0])) + " already is on the guestlist"); break; } bot.FriendList.Add("guestlist", e.Args[0]); bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(e.Args[0])) + " has been added to the guestlist"); break; case "guestlist remove": if (e.Args.Length < 1) { if (bot.FriendList.IsFriend("guestlist", e.Sender)) { bot.SendReply(e, "You have been removed from the guestlist"); bot.FriendList.Remove("guestlist", e.Sender); } else { bot.SendReply(e, "You're not on the guestlist"); } break; } if (bot.GetUserID(e.Args[0]) < 1) { bot.SendReply(e, "No such user: "******"guestlist", e.Args[0])) { bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(e.Args[0])) + " is not on the guestlist"); break; } bot.FriendList.Remove("guestlist", e.Args[0]); bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(e.Args[0])) + " has been removed from the guestlist"); break; } }
private void OnPointsRewardCommand(BotShell bot, CommandArgs e) { if (!this._core.Running) { bot.SendReply(e, "There is currently no raid active"); return; } if (e.Args.Length < 1) { bot.SendReply(e, "Correct Usage: points reward [amount]"); return; } double amount = 0; try { amount = Convert.ToDouble(e.Args[0].Replace(".", ",")); } catch { } if (amount < 0.1) { bot.SendReply(e, "You need to reward at least 0,1 point"); return; } if (e.Args.Length >= 2) { RaidCore.Raider[] raiders = this._core.GetRaiders(); Dictionary <string, double> points = new Dictionary <string, double>(); switch (e.Args[1]) { case "activity": foreach (RaidCore.Raider raider in raiders) { if (raider.Activity < 1) { continue; } double reward = (float)raider.Activity / ((float)this._core.TimeRunning.TotalSeconds - (float)this._core.TimePaused.TotalSeconds) * amount; if (reward > amount) { reward = amount; } points.Add(raider.Character, Math.Round(reward, 1)); } break; case "active": foreach (RaidCore.Raider raider in raiders) { if (raider.OnRaid) { points.Add(raider.Character, amount); } } break; case "all": foreach (RaidCore.Raider raider in raiders) { points.Add(raider.Character, amount); } break; default: bot.SendReply(e, "Invalid reward mode specified"); return; } double total = 0; RichTextWindow window = new RichTextWindow(bot); window.AppendTitle("Rewarded Points"); foreach (KeyValuePair <string, double> kvp in points) { window.AppendHighlight(kvp.Value.ToString("###0.0") + " "); window.AppendNormal(kvp.Key); window.AppendLineBreak(); this._core.AddPoints(kvp.Key, kvp.Value); total += kvp.Value; this._core.Log(kvp.Key, e.Sender, this.InternalName, "points", e.Sender + " has rewarded " + kvp.Value + " points to " + kvp.Key + " (Total Points: " + this._core.GetPoints(kvp.Key) + ")"); } switch (e.Args[1]) { case "activity": bot.SendReply(e, "You have rewarded a total of " + HTML.CreateColorString(bot.ColorHeaderHex, total.ToString()) + " points to " + HTML.CreateColorString(bot.ColorHeaderHex, points.Count.ToString()) + " raiders based on their active time on the raid »» ", window); bot.SendPrivateChannelMessage(bot.ColorHighlight + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender) + " has rewarded " + HTML.CreateColorString(bot.ColorHeaderHex, amount.ToString()) + " points to all raiders based on their active time on the raid"); this._core.Log(e.Sender, e.Sender, this.InternalName, "points", e.Sender + " has rewarded " + amount + " points to " + points.Count + " raiders based on their active time on the raid (Total Points: " + total + ")"); return; case "active": bot.SendReply(e, "You have rewarded a total of " + HTML.CreateColorString(bot.ColorHeaderHex, total.ToString()) + " points to " + HTML.CreateColorString(bot.ColorHeaderHex, points.Count.ToString()) + " active raiders on the current raid »» ", window); bot.SendPrivateChannelMessage(bot.ColorHighlight + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender) + " has rewarded " + HTML.CreateColorString(bot.ColorHeaderHex, amount.ToString()) + " points to all active raiders on the current raid"); this._core.Log(e.Sender, e.Sender, this.InternalName, "points", e.Sender + " has rewarded " + amount + " points to " + points.Count + " raiders active on the current raid (Total Points: " + total + ")"); return; case "all": bot.SendReply(e, "You have rewarded a total of " + HTML.CreateColorString(bot.ColorHeaderHex, total.ToString()) + " points to " + HTML.CreateColorString(bot.ColorHeaderHex, points.Count.ToString()) + " raiders that participated in this raid »» ", window); bot.SendPrivateChannelMessage(bot.ColorHighlight + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender) + " has rewarded " + HTML.CreateColorString(bot.ColorHeaderHex, amount.ToString()) + " points to all raiders that participated on this raid"); this._core.Log(e.Sender, e.Sender, this.InternalName, "points", e.Sender + " has rewarded " + amount + " points to " + points.Count + " raiders that have participated on this raid (Total Points: " + total + ")"); return; } } else { RichTextWindow window = new RichTextWindow(bot); window.AppendTitle("Reward Points"); window.AppendNormal("You are about to reward "); window.AppendHighlight(amount.ToString()); window.AppendNormal(" points."); window.AppendLineBreak(); window.AppendNormal("Please select one of the following modes for rewarding points."); window.AppendLineBreak(2); window.AppendHighlight("Activity Based"); window.AppendLineBreak(); window.AppendNormal("This method will reward points to all raiders relative to the time they spent on the raid while it was unpaused."); window.AppendLineBreak(); window.AppendNormal("For example: If someone joined the raid for 30 minutes on a 60 minutes raid and the amount of points to be rewarded was 6, that raider would receive 3 points. Even if he wasn't at the raid at the moment the points were rewarded."); window.AppendLineBreak(); window.AppendNormal("["); window.AppendBotCommand("Reward Points", "points reward " + amount.ToString() + " activity"); window.AppendNormal("]"); window.AppendLineBreak(2); window.AppendHighlight("All Active Raiders"); window.AppendLineBreak(); window.AppendNormal("This method will reward points to all raiders that are currently active on this raid"); window.AppendLineBreak(); window.AppendNormal("For example: If someone joined the raid for 30 minutes on a 60 minutes raid and the amount of points to be rewarded was 6, that raider would receive 6 points if he was on the raid at the moment these points were rewarded."); window.AppendLineBreak(); window.AppendNormal("["); window.AppendBotCommand("Reward Points", "points reward " + amount.ToString() + " active"); window.AppendNormal("]"); window.AppendLineBreak(2); window.AppendHighlight("All Raiders"); window.AppendLineBreak(); window.AppendNormal("This method will reward points to all raiders that attended this raid"); window.AppendLineBreak(); window.AppendNormal("For example: If someone joined the raid for 30 minutes on a 60 minutes raid and the amount of points to be rewarded was 6, that raider would receive 6 points. Even if he wasn't at the raid at the moment the points were rewarded."); window.AppendLineBreak(); window.AppendNormal("["); window.AppendBotCommand("Reward Points", "points reward " + amount.ToString() + " all"); window.AppendNormal("]"); window.AppendLineBreak(2); bot.SendReply(e, "Reward Points »» ", window); } }
public void OnPluginsCommand(BotShell bot, CommandArgs e) { RichTextWindow window = new RichTextWindow(bot); RichTextWindow windowCore = new RichTextWindow(bot); RichTextWindow windowLoaded = new RichTextWindow(bot); RichTextWindow windowInstalled = new RichTextWindow(bot); RichTextWindow windowDisabled = new RichTextWindow(bot); window.AppendTitle("Plugins"); window.AppendNormal("Plugins provide functionality and features for your bot. You can load different plugins based on your needs."); window.AppendLineBreak(); window.AppendNormal("After loading plugins it's wise to open the "); window.AppendBotCommand("configuration interface", "configuration"); window.AppendNormal(" to futher configure the loaded plugins."); window.AppendLineBreak(); window.AppendNormal("If you're unsure about which plugin you need, "); window.AppendBotCommand("click here", "plugins overview"); window.AppendNormal(" to get an overview of all available plugins."); window.AppendLineBreak(2); string[] plugins = bot.Plugins.GetPlugins(); foreach (string plugin in plugins) { RichTextWindow tmpWindow; PluginState state = bot.Plugins.GetState(plugin); switch (state) { case PluginState.Core: tmpWindow = windowCore; tmpWindow.AppendNormalStart(); break; case PluginState.Loaded: tmpWindow = windowLoaded; tmpWindow.AppendNormalStart(); tmpWindow.AppendString("["); tmpWindow.AppendBotCommand("Unload", "plugins unload " + plugin); tmpWindow.AppendString("] "); break; case PluginState.Installed: tmpWindow = windowInstalled; tmpWindow.AppendNormalStart(); tmpWindow.AppendString("["); tmpWindow.AppendBotCommand("Load", "plugins load " + plugin); tmpWindow.AppendString("] ["); tmpWindow.AppendBotCommand("Uninstall", "plugins uninstall " + plugin); tmpWindow.AppendString("] "); break; default: tmpWindow = windowDisabled; tmpWindow.AppendNormalStart(); tmpWindow.AppendString("["); tmpWindow.AppendBotCommand("Install", "plugins install " + plugin); tmpWindow.AppendString("] "); break; } tmpWindow.AppendString("["); tmpWindow.AppendBotCommand("Info", "plugins info " + plugin); tmpWindow.AppendString("] "); tmpWindow.AppendColorEnd(); PluginLoader info = bot.Plugins.GetLoader(plugin); tmpWindow.AppendHighlight(info.Name); tmpWindow.AppendLineBreak(); } window.AppendHeader("Core Plugins"); if (windowCore.Text != string.Empty) { window.AppendRawString(windowCore.Text); } else { window.AppendHighlight("None"); window.AppendLineBreak(); } window.AppendLineBreak(); window.AppendHeader("Loaded"); if (windowLoaded.Text != string.Empty) { window.AppendRawString(windowLoaded.Text); } else { window.AppendHighlight("None"); window.AppendLineBreak(); } window.AppendLineBreak(); window.AppendHeader("Installed"); if (windowInstalled.Text != string.Empty) { window.AppendRawString(windowInstalled.Text); } else { window.AppendHighlight("None"); window.AppendLineBreak(); } window.AppendLineBreak(); window.AppendHeader("Disabled"); if (windowDisabled.Text != string.Empty) { window.AppendRawString(windowDisabled.Text); } else { window.AppendHighlight("None"); window.AppendLineBreak(); } bot.SendReply(e, "Plugins »» ", window); }
private void OnSbCommand(BotShell bot, CommandArgs e) { List <string> atrox = new List <string>(); List <string> nanomage = new List <string>(); List <string> opifex = new List <string>(); List <string> solitus = new List <string>(); foreach (KeyValuePair <UInt32, Friend> kvp in bot.PrivateChannel.List()) { WhoisResult whois = XML.GetWhois(kvp.Value.User, bot.Dimension); if (whois == null || whois.Stats == null || whois.Stats.Breed == null) { continue; } lock (this.Shadowbreeds) if (!this.Shadowbreeds.ContainsKey(kvp.Value.User.ToLower())) { if (whois.Stats.Level >= 205) { this.Shadowbreeds.Add(kvp.Value.User.ToLower(), ShadowbreedState.Unknown); } else { this.Shadowbreeds.Add(kvp.Value.User.ToLower(), ShadowbreedState.Unavailable); } } switch (whois.Stats.Breed.ToLower()) { case "atrox": atrox.Add(whois.Name.Nickname.ToLower()); break; case "nano": nanomage.Add(whois.Name.Nickname.ToLower()); break; case "opifex": opifex.Add(whois.Name.Nickname.ToLower()); break; case "solitus": solitus.Add(whois.Name.Nickname.ToLower()); break; } } lock (this.Shadowbreeds) { List <string> remove = new List <string>(); foreach (KeyValuePair <string, ShadowbreedState> shadowbreed in this.Shadowbreeds) { if (atrox.Contains(shadowbreed.Key.ToLower())) { continue; } if (nanomage.Contains(shadowbreed.Key.ToLower())) { continue; } if (opifex.Contains(shadowbreed.Key.ToLower())) { continue; } if (solitus.Contains(shadowbreed.Key.ToLower())) { continue; } remove.Add(shadowbreed.Key); } foreach (string shadowbreed in remove) { this.Shadowbreeds.Remove(shadowbreed); } if (this.Shadowbreeds.Count < 1) { bot.SendReply(e, "The Shadowbreeds list is empty"); return; } } RichTextWindow window = new RichTextWindow(bot); window.AppendTitle(); if (atrox.Count > 0) { window.AppendHeader("Atrox"); this.CreateSbList(bot, ref window, atrox); window.AppendLineBreak(); } if (nanomage.Count > 0) { window.AppendHeader("Nanomage"); this.CreateSbList(bot, ref window, nanomage); window.AppendLineBreak(); } if (opifex.Count > 0) { window.AppendHeader("Opifex"); this.CreateSbList(bot, ref window, opifex); window.AppendLineBreak(); } if (solitus.Count > 0) { window.AppendHeader("Solitus"); this.CreateSbList(bot, ref window, solitus); window.AppendLineBreak(); } window.AppendHeader("Options"); window.AppendBotCommand("Request Shadowbreed State", "sb get"); window.AppendLineBreak(); window.AppendBotCommand("Reset Shadowbreed List", "sb reset"); bot.SendReply(e, "Shadowbreeds »» ", window); }
private void OnTeamsAdminCommand(BotShell bot, CommandArgs e) { List <string> seen = new List <string>(); List <int> teams = new List <int>(); using (IDbCommand command = this._database.Connection.CreateCommand()) { command.CommandText = "SELECT team FROM teams GROUP BY team"; IDataReader reader = command.ExecuteReader(); while (reader.Read()) { teams.Add((int)reader.GetInt64(0)); } reader.Close(); } RichTextWindow window = new RichTextWindow(bot); window.AppendTitle("Teams Manager"); window.AppendCommand("Display Teams", "/g " + bot.Character + " " + bot.CommandSyntax + "teams"); window.AppendLineBreak(); window.AppendBotCommand("Refresh Manager", "teams admin"); window.AppendLineBreak(); window.AppendBotCommand("Clear Teams", "teams clear"); window.AppendLineBreak(); int currentTeam = -1; int currentMember = 0; using (IDbCommand command = this._database.Connection.CreateCommand()) { command.CommandText = "SELECT username, team, leader FROM teams ORDER BY team, username"; IDataReader reader = command.ExecuteReader(); while (reader.Read()) { string username = Format.UppercaseFirst(reader.GetString(0)); seen.Add(username); int team = (int)reader.GetInt64(1); bool leader = (reader.GetInt64(2) > 0); if (team != currentTeam) { currentMember = 0; currentTeam = team; window.AppendLineBreak(); window.AppendHeader("Team " + team); } currentMember++; WhoisResult whois = XML.GetWhois(username, bot.Dimension); if (whois != null && whois.Success) { window.AppendHighlight(Format.Whois(whois, FormatStyle.Compact)); } else { window.AppendHighlight(username); } window.AppendNormalStart(); if (leader) { window.AppendString(" ("); window.AppendColorString(RichTextWindow.ColorRed, "Leader"); window.AppendString(")"); } foreach (int tm in teams) { if (tm == team) { continue; } window.AppendString(" ["); window.AppendBotCommand(tm.ToString(), "teams set " + username + " " + tm); window.AppendString("]"); } if (!leader) { window.AppendString(" ["); window.AppendBotCommand("Leader", "teams leader " + username + " " + team); window.AppendString("]"); } window.AppendString(" ["); window.AppendBotCommand("Remove", "teams remove " + username); window.AppendString("]"); window.AppendString(" ["); window.AppendBotCommand("New Team", "teams start " + username); window.AppendString("]"); window.AppendColorEnd(); window.AppendLineBreak(); } reader.Close(); } window.AppendLineBreak(); window.AppendHeader("Looking for Team"); int lft = 0; List <string> list = new List <string>(); foreach (Friend user in bot.PrivateChannel.List().Values) { list.Add(user.User); } // If 'Raid :: Core' is loaded, fetch the lft list from there List <string> raiders = new List <string>(); if (bot.Plugins.IsLoaded("raidcore")) { try { ReplyMessage reply = bot.SendPluginMessageAndWait(this.InternalName, "raidcore", "GetActiveRaiders", 100); if (reply != null && reply.Args.Length > 0) { raiders = new List <string>((string[])reply.Args); } } catch { } } // Sort LFT list SortedDictionary <string, SortedDictionary <string, WhoisResult> > sorted = new SortedDictionary <string, SortedDictionary <string, WhoisResult> >(); foreach (string member in list) { WhoisResult whois = XML.GetWhois(member, bot.Dimension); if (whois == null || !whois.Success) { whois = null; } if (!sorted.ContainsKey(whois.Stats.Profession)) { sorted.Add(whois.Stats.Profession, new SortedDictionary <string, WhoisResult>()); } sorted[whois.Stats.Profession].Add(member, whois); } // Display LFT list foreach (KeyValuePair <string, SortedDictionary <string, WhoisResult> > kvp in sorted) { window.AppendHighlight(kvp.Key); window.AppendLineBreak(); foreach (KeyValuePair <string, WhoisResult> member in kvp.Value) { if (seen.Contains(member.Key)) { continue; } window.AppendNormalStart(); window.AppendString("- "); if (member.Value != null && member.Value.Success) { window.AppendString(Format.Whois(member.Value, FormatStyle.Compact)); } else { window.AppendString(member.Key); } if (raiders.Contains(member.Key)) { window.AppendString(" ["); window.AppendColorString(RichTextWindow.ColorGreen, "R"); window.AppendString("]"); } foreach (int tm in teams) { window.AppendString(" ["); window.AppendBotCommand(tm.ToString(), "teams set " + member.Key + " " + tm); window.AppendString("]"); } window.AppendString(" ["); window.AppendBotCommand("New Team", "teams start " + member.Key); window.AppendString("]"); window.AppendColorEnd(); window.AppendLineBreak(); lft++; } window.AppendLineBreak(); } if (lft == 0) { window.AppendHighlight("None"); } bot.SendReply(e, "Teams Manager »» ", window); }
private void OnConfigurationDisplayCommand(BotShell bot, CommandArgs e) { string internalName = e.Args[0].ToLower(); if (!bot.Plugins.Exists(internalName)) { bot.SendReply(e, "No such plugin!"); return; } ConfigurationEntry[] entires = bot.Configuration.List(internalName); if (entires.Length < 1) { bot.SendReply(e, "This plugin has no settings to configure"); return; } RichTextWindow window = new RichTextWindow(bot); PluginLoader loader = bot.Plugins.GetLoader(internalName); window.AppendTitle("Configuration"); foreach (ConfigurationEntry entry in entires) { window.AppendHighlight(entry.Name + ": "); window.AppendNormalStart(); string command = "configuration set " + internalName + " " + entry.Key.ToLower(); switch (entry.Type) { case ConfigType.String: string value1 = bot.Configuration.GetString(entry.Section, entry.Key, (string)entry.DefaultValue); if (entry.Values != null && entry.Values.Length > 0) { window.AppendMultiBox(command, value1, entry.StringValues); } else { window.AppendString(value1 + " ["); window.AppendCommand("Edit", "/text /tell " + bot.Character + " " + command + " [text]"); window.AppendString("]"); } break; case ConfigType.Integer: string value2 = bot.Configuration.GetInteger(entry.Section, entry.Key, (int)entry.DefaultValue).ToString(); if (entry.Values != null && entry.Values.Length > 0) { window.AppendMultiBox(command, value2, entry.StringValues); } else { window.AppendString(value2 + " ["); window.AppendCommand("Edit", "/text /tell " + bot.Character + " " + command + " [number]"); window.AppendString("]"); } break; case ConfigType.Boolean: string value3 = "Off"; if (bot.Configuration.GetBoolean(entry.Section, entry.Key, (bool)entry.DefaultValue)) { value3 = "On"; } window.AppendMultiBox(command, value3, "On", "Off"); break; case ConfigType.Username: string value4 = bot.Configuration.GetUsername(entry.Section, entry.Key, (string)entry.DefaultValue); window.AppendString(value4 + " ["); window.AppendCommand("Edit", "/text /tell " + bot.Character + " " + command + " [username]"); window.AppendString("]"); break; case ConfigType.Date: DateTime value5 = bot.Configuration.GetDate(entry.Section, entry.Key, (DateTime)entry.DefaultValue); window.AppendString(value5.ToString("dd/MM/yyyy") + " ["); window.AppendCommand("Edit", "/text /tell " + bot.Character + " " + command + " [dd]/[mm]/[yyyy]"); window.AppendString("]"); break; case ConfigType.Time: TimeSpan value6 = bot.Configuration.GetTime(entry.Section, entry.Key, (TimeSpan)entry.DefaultValue); window.AppendString(string.Format("{0:00}:{1:00}:{2:00}", Math.Floor(value6.TotalHours), value6.Minutes, value6.Seconds) + " ["); window.AppendCommand("Edit", "/text /tell " + bot.Character + " " + command + " [hh]:[mm]:[ss]"); window.AppendString("]"); break; case ConfigType.Dimension: string value7 = bot.Configuration.GetDimension(entry.Section, entry.Key, (Server)entry.DefaultValue).ToString(); window.AppendMultiBox(command, value7, Server.RubiKa.ToString(), Server.Test.ToString()); break; case ConfigType.Color: string value8 = bot.Configuration.GetColor(entry.Section, entry.Key, (string)entry.DefaultValue); window.AppendColorString(value8, value8); window.AppendString(" ["); window.AppendBotCommand("Edit", "configuration color " + internalName + " " + entry.Key.ToLower()); window.AppendString("]"); break; case ConfigType.Password: string value9 = bot.Configuration.GetPassword(entry.Section, entry.Key, (string)entry.DefaultValue); for (int i = 0; i < value9.Length; i++) { window.AppendString("*"); } window.AppendString(" ["); window.AppendCommand("Edit", "/text /tell " + bot.Character + " " + command + " [password]"); window.AppendString("]"); break; case ConfigType.Custom: string value10 = bot.Configuration.GetCustom(entry.Section, entry.Key); if (value10 != null) { window.AppendRawString(value10); } break; } window.AppendString(" ["); window.AppendBotCommand("Default", "configuration reset " + internalName + " " + entry.Key.ToLower()); window.AppendString("]"); window.AppendColorEnd(); window.AppendLineBreak(); } bot.SendReply(e, "Configuration »» " + loader.Name + " »» ", window); }
private void OnNews(BotShell bot, CommandArgs e) { try { using (IDbCommand command = this._database.Connection.CreateCommand()) { RichTextWindow window = new RichTextWindow(bot); window.AppendTitle(); bool titleSticky = false; bool titleNormal = false; Int64 lastPost = 0; command.CommandText = "SELECT [news_id], [news_name] , [news_date], [news_text], [news_icon], [news_sticky] FROM [news] ORDER BY [news_sticky] DESC, [news_date] DESC LIMIT 15"; IDataReader reader = command.ExecuteReader(); while (reader.Read()) { if (reader.GetInt64(2) > lastPost) { lastPost = reader.GetInt64(2); } if (reader.GetInt64(5) == 1) { if (!titleSticky) { window.AppendHeader("Sticky News Posts"); window.AppendLineBreak(); titleSticky = true; } } else { if (!titleNormal) { window.AppendHeader("Current News Posts"); window.AppendLineBreak(); titleNormal = true; } } window.AppendBotCommandStart("news id " + reader.GetInt64(0).ToString()); if (reader.GetInt64(5) == 1) { window.AppendImage("GFX_GUI_WINDOW_ICON_POPUP"); } else { window.AppendImage(_iconList[reader.GetInt64(4)]); } window.AppendLinkEnd(); window.AppendHighlight(" " + Format.DateTime(reader.GetInt64(2), FormatStyle.Compact) + " GMT by " + reader.GetString(1)); window.AppendLineBreak(true); window.AppendNormal(reader.GetString(3)); if ((reader.GetString(1) == e.Sender || bot.Users.Authorized(e.Sender, UserLevel.Admin))) { window.AppendLineBreak(true); window.AppendNormal("["); window.AppendBotCommand("Remove", "news remove " + reader.GetInt64(0)); window.AppendNormal("]"); } window.AppendLineBreak(2); } if (lastPost == 0) { bot.SendReply(e, "There's currently no news"); return; } else { bot.SendReply(e, "News last edited on " + HTML.CreateColorString(bot.ColorHeaderHex, Format.DateTime(lastPost, FormatStyle.Compact)) + " »» ", window); return; } } } catch { bot.SendReply(e, "Error during news fetching. Please try again later"); return; } }
private void OnNewsID(BotShell bot, CommandArgs e) { double d; if (e.Args.Length == 0) { bot.SendReply(e, "Correct Usage: news id [id]"); return; } if (double.TryParse(e.Args[0], System.Globalization.NumberStyles.Integer, _cultureInfo, out d) == true) { try { using (IDbCommand command = this._database.Connection.CreateCommand()) { command.CommandText = "SELECT [news_name], [news_sticky] FROM [news] WHERE [news_id] = " + e.Args[0]; IDataReader reader = command.ExecuteReader(); if (reader.Read()) { if ((reader.GetString(0) == e.Sender || bot.Users.Authorized(e.Sender, UserLevel.Admin)) && e.Type == CommandType.Tell) { RichTextWindow window = new RichTextWindow(bot); window.AppendTitle("News Options"); window.AppendHighlight("Sticky: "); if (reader.GetInt64(1) == 1) { window.AppendColorString(RichTextWindow.ColorGreen, "Enabled"); window.AppendNormal(" ["); window.AppendBotCommand("Disable", "news sticky " + e.Args[0] + " 0"); window.AppendNormal("]"); } else { window.AppendColorString(RichTextWindow.ColorOrange, "Disabled"); window.AppendNormal(" ["); window.AppendBotCommand("Enable", "news sticky " + e.Args[0] + " 1"); window.AppendNormal("]"); } window.AppendLineBreak(2); window.AppendHeader("Icon"); if (reader.GetInt64(1) == 1) { window.AppendNormal("There are no icons available for sticky posts"); } else { int counter = 0; foreach (string Icon in _iconList) { window.AppendBotCommandStart("news icon " + e.Args[0] + " " + counter.ToString()); window.AppendImage(Icon); window.AppendLinkEnd(); window.AppendNormal(" "); counter = counter + 1; } } bot.SendReply(e, "News Options »» ", window); return; } else { bot.SendReply(e, "You don't own this news post"); return; } } else { bot.SendReply(e, "No such news post"); return; } } } catch { bot.SendReply(e, "Error during news fetching. Please try again later"); return; } } bot.SendReply(e, "Invalid ID"); }
private void OnRaidHistoryCommand(BotShell bot, CommandArgs e) { RaidCore.Raid[] raids = this._core.GetRaids(); if (raids.Length == 0) { bot.SendReply(e, "There's no raid history available"); return; } RichTextWindow window = new RichTextWindow(bot); window.AppendTitle(); for (int i = raids.Length; i > 0; i--) { RaidCore.Raid raid = raids[i - 1]; string start; if (raid.StartTime > 0) { start = Format.DateTime(raid.StartTime, FormatStyle.Compact) + " GMT"; } else { start = "N/A"; } string stop; if (raid.StopTime > 0) { stop = Format.DateTime(raid.StopTime, FormatStyle.Compact) + " GMT"; } else { stop = "N/A"; } window.AppendHeader(start + " - " + stop); window.AppendHighlight("Started By: "); window.AppendNormal(raid.StartAdmin); window.AppendLineBreak(); window.AppendHighlight("Stopped By: "); window.AppendNormal(raid.StopAdmin); window.AppendLineBreak(); window.AppendHighlight("Duration: "); window.AppendNormal((raid.Activity / 60) + " minutes"); window.AppendLineBreak(); window.AppendHighlight("Description: "); window.AppendNormal(raid.Description); window.AppendLineBreak(); window.AppendHighlight("Raiders: "); window.AppendNormal(raid.Raiders + " ["); window.AppendBotCommand("View", "raid history " + raid.RaidID); window.AppendNormal("] ["); window.AppendBotCommand("Log", "raid logs " + raid.RaidID); window.AppendNormal("]"); // Replace with IntraBroadcast when done if (this._bot.Plugins.IsLoaded("RaidLootLog")) { window.AppendNormal(" ["); window.AppendBotCommand("Loot log", "lootlog " + raid.RaidID); window.AppendNormal("]"); } window.AppendLineBreak(2); } bot.SendReply(e, "Raid History »» ", window); }
private void OnLootCommand(BotShell bot, CommandArgs e) { if (e.Args.Length > 0) { string monster = e.Words[0].ToLower(); monster = HTML.UnescapeString(monster); int results = 0; RichTextWindow window = new RichTextWindow(bot); window.AppendTitle("Loot results for '" + monster + "'"); lock (this._database.Connection) { using (IDbCommand command = this._database.Connection.CreateCommand()) { command.CommandText = "SELECT id, name, lowid, highid, ql, icon FROM loot WHERE monster LIKE '%" + Config.EscapeString(monster).Replace(" ", "%") + "%' AND visible = 'true' ORDER BY name ASC"; //SELECT count(points), min(points), max(points), avg(points) FROM loot_history WHERE item = 244718 AND points > 0 IDataReader reader = command.ExecuteReader(); while (reader.Read()) { results++; int icon = reader.GetInt32(5); if (icon > 0) { window.AppendIcon(icon); window.AppendLineBreak(); } window.AppendItem(reader.GetString(1), reader.GetInt32(2), reader.GetInt32(3), reader.GetInt32(4)); window.AppendNormal(" ["); window.AppendBotCommand("Start Auction", "auction start item:" + reader.GetInt32(2) + ":" + reader.GetInt32(3) + ":" + reader.GetInt32(4) + " " + reader.GetString(1)); window.AppendNormal("]"); window.AppendLineBreak(2); } reader.Close(); } } if (results == 0) { bot.SendReply(e, "No loot results for '" + monster + "'"); } else { bot.SendReply(e, "Loot results for '" + monster + "' »» ", window); } return; } RichTextWindow monsters = new RichTextWindow(bot); monsters.AppendTitle("Loot Information"); lock (this._database.Connection) { using (IDbCommand command = this._database.Connection.CreateCommand()) { command.CommandText = "SELECT monster, count(*) FROM loot WHERE visible = 'true' GROUP BY monster ORDER BY monster ASC"; IDataReader reader = command.ExecuteReader(); while (reader.Read()) { monsters.AppendHighlight(reader.GetString(0)); monsters.AppendNormal(" (" + reader.GetInt32(1) + " items) ["); monsters.AppendBotCommand("View", "loot " + reader.GetString(0)); monsters.AppendNormal("]"); monsters.AppendLineBreak(); } reader.Close(); } } bot.SendReply(e, "Loot Information »» ", monsters); }
private void OnForumCommand(BotShell bot, CommandArgs e) { string username = e.Sender; if (e.Args.Length > 0) { username = Format.UppercaseFirst(e.Args[0]); } ForumAccount account = this.GetAccount(username); if (account == null) { bot.SendReply(e, "Unable to locate " + HTML.CreateColorString(bot.ColorHeaderHex, username + "'s") + " forum account"); return; } RichTextWindow window = new RichTextWindow(bot); window.AppendTitle(username + "'s Forum Account"); window.AppendHighlight("Name: "); window.AppendNormal(account.Realname); window.AppendLineBreak(); window.AppendHighlight("Primary Group: "); if (account.PrimaryGroup != string.Empty) { window.AppendNormal(account.PrimaryGroup); } else { window.AppendNormal("N/A"); } window.AppendLineBreak(); window.AppendHighlight("E-mail Address: "); window.AppendNormal(account.Email); window.AppendLineBreak(); window.AppendHighlight("Post Count: "); window.AppendNormal(account.Posts.ToString()); if (account.Rank != string.Empty) { window.AppendNormal(" (" + account.Rank + ")"); } window.AppendLineBreak(); window.AppendHighlight("Epeen: "); window.AppendNormal(account.Karma.ToString()); window.AppendLineBreak(); window.AppendHighlight("Enabled: "); if (account.Enabled) { window.AppendColorString(RichTextWindow.ColorGreen, "Yes"); } else { window.AppendColorString(RichTextWindow.ColorRed, "No"); if (username == e.Sender) { window.AppendNormal(" ["); window.AppendBotCommand("Activate", "forum activate"); window.AppendNormal("]"); } } window.AppendLineBreak(); window.AppendHighlight("Registered On: "); window.AppendNormal(Format.DateTime(account.Registered, FormatStyle.Medium)); window.AppendLineBreak(); if (account.Seen > 0) { window.AppendHighlight("Last Seen: "); TimeSpan span = TimeStamp.ToDateTime(TimeStamp.Now) - TimeStamp.ToDateTime(account.Seen); window.AppendNormal(Format.Time(span, FormatStyle.Large) + " ago"); window.AppendLineBreak(); } if (account.Groups.Count > 0) { window.AppendLineBreak(); window.AppendHeader("Additional Groups"); foreach (string group in account.Groups.Values) { window.AppendHighlight(group); window.AppendLineBreak(); } } bot.SendReply(e, username + "'s Forum Account »» " + window.ToString()); }
private void OnGlyphsRaffleCommand(BotShell bot, CommandArgs e) { if (this._raffleActive) { bot.SendReply(e, "There's currently already a glyph raffle active"); return; } Dictionary <int, int> items = new Dictionary <int, int>(); RichTextWindow window = new RichTextWindow(bot); window.AppendTitle("Glyph Raffle"); lock (this._items) { if (e.Args.Length != this._items.Count) { bot.SendReply(e, "You need to specify " + this._items.Count + " numbers"); return; } if (this._items.Count == 0) { bot.SendReply(e, "This plugin hasn't been properly configured for raffling"); return; } int i = 0; this._raffleJoined.Clear(); foreach (KeyValuePair <int, string> kvp in this._items) { try { items.Add(kvp.Key, Convert.ToInt32(e.Args[i])); if (items[kvp.Key] > 0) { window.AppendHighlight(kvp.Value + " "); window.AppendNormal("(" + items[kvp.Key].ToString() + " total) ["); window.AppendBotCommand("Join", "glyphs join " + kvp.Key); window.AppendNormal("]"); window.AppendLineBreak(); this._raffleJoined.Add(kvp.Key, new List <string>()); } } catch { this._raffleJoined.Clear(); bot.SendReply(e, "Invalid value specified: " + e.Args[i]); return; } i++; } } this._raffleTime = 60; this._raffleItems = items; this._raffleJoined = new Dictionary <int, List <string> >(); this._raffleActive = true; this._raffleTimer.Start(); this._raffleWindow = window; string output = bot.ColorHighlight + "\n¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯\n " + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender) + " has started a glyph raffle »» " + window.ToString(); lock (this._items) { foreach (KeyValuePair <int, string> kvp in this._items) { if (items[kvp.Key] > 0) { lock (this._raffleJoined) this._raffleJoined.Add(kvp.Key, new List <string>()); output += "\n " + HTML.CreateColorString(bot.ColorHeaderHex, items[kvp.Key].ToString()) + " " + kvp.Value; } } } output += "\n______________________________________________"; bot.SendPrivateChannelMessage(output); bot.SendReply(e, "You have started the glyph raffle"); }