private void OnVoteCastCommand(BotShell bot, CommandArgs e) { if (!this._running) { bot.SendPrivateMessage(e.SenderID, "There is nothing to votes for at this time."); return; } string main = bot.Users.GetMain(e.Sender); lock (this._joined) { if (this._joined.ContainsKey(main)) { bot.SendPrivateMessage(e.SenderID, "You have already cast your vote in this election."); return; } this._joined.Add(main, e.Sender); switch (e.Command) { case "vote yes": _yes++; break; case "vote no": _no++; break; case "vote abstain": _abs++; break; } bot.SendPrivateMessage(e.SenderID, "You have cast your vote."); } }
private void OnRaidAddCommand(BotShell bot, CommandArgs e) { if (e.Args.Length < 1) { bot.SendReply(e, "Correct Usage: raid add [username]"); return; } if (!this._core.Running) { bot.SendReply(e, "There is currently no raid active"); return; } string raider = Format.UppercaseFirst(e.Args[0]); if (!bot.PrivateChannel.IsOn(raider)) { bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, raider) + " is required to be on the private channel to join the raid"); return; } if (this._core.IsRaider(raider)) { bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, raider) + " is already in the raid"); return; } lock (this._bans) { string main = bot.Users.GetMain(raider); if (this._bans.ContainsKey(main)) { bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, raider) + " is currently banned from the raid"); return; } } int credits = 0; int max = 0; bool charged = false; if (this.CreditsEnabled && !this.WithdrawCredit(bot, raider, out credits, out max, out charged)) { bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, raider) + " doesn't have enough raid credits to join this raid"); return; } this._core.AddRaider(raider, false); bot.SendPrivateChannelMessage(bot.ColorHighlight + HTML.CreateColorString(bot.ColorHeaderHex, raider) + " has been manually added to the raid"); bot.SendPrivateMessage(raider, bot.ColorHighlight + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender) + " has added you to the raid"); this._core.Log(raider, e.Sender, this.InternalName, "raiders", string.Format("{0} has been added the raid (Points: {1})", raider, this._core.GetPoints(raider))); if (charged) { bot.SendPrivateMessage(raider, bot.ColorHighlight + "You have been charged a raid credit for this raid. You have used " + HTML.CreateColorString(bot.ColorHeaderHex, credits + "/" + max) + " raid credits for this type of raid"); this._core.Log(raider, e.Sender, this.InternalName, "credits", string.Format("{0} has been charged a raid credit (Credits Left: {1})", raider, credits)); } }
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 OnRaidBanCommand(BotShell bot, CommandArgs e) { int duration = 0; try { if (e.Args.Length < 2) { throw new Exception(); } duration = Convert.ToInt32(e.Args[1]); if (duration < 1) { throw new Exception(); } } catch { bot.SendReply(e, "Correct Usage: raid ban [username] [minutes]"); return; } string character = Format.UppercaseFirst(e.Args[0]); if (bot.GetUserID(character) < 100) { bot.SendReply(e, "No such user: "******"The duration of your suspension has been set to " + HTML.CreateColorString(bot.ColorHeaderHex, banned.Duration.ToString()) + " minutes by " + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender)); bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, character + "'s") + " raid ban duration has been updated to " + HTML.CreateColorString(bot.ColorHeaderHex, banned.Duration.ToString()) + " minutes"); this._core.Log(character, e.Sender, this.InternalName, "bans", string.Format("{0}'s raid ban duration has been updated to {1} minutes", character, banned.Duration)); } else { bot.SendPrivateMessage(character, bot.ColorHighlight + "Your access to the raid has been suspended for " + HTML.CreateColorString(bot.ColorHeaderHex, banned.Duration.ToString()) + " minutes by " + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender)); bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, character) + " has been banned from the raid for " + HTML.CreateColorString(bot.ColorHeaderHex, banned.Duration.ToString()) + " minutes"); this._core.Log(character, e.Sender, this.InternalName, "bans", string.Format("{0} has banned from the raid for {1} minutes", character, banned.Duration)); } this._bans.Add(main, banned); } }
public override void OnPluginMessage(BotShell bot, PluginMessage message) { try { if (message.Command != "announce") { return; } if (message.Args.Length < 3) { return; } string group = (string)message.Args[0]; if (group == null || group == string.Empty) { return; } string source = (string)message.Args[1]; if (source == null || source == string.Empty) { return; } string sender = (string)message.Args[2]; if (sender == null || sender == string.Empty) { return; } string msg = (string)message.Args[3]; if (msg == null || msg == string.Empty) { return; } string formattedMessage = bot.ColorHighlight + "Message from " + HTML.CreateColorString(bot.ColorHeaderHex, sender) + " on " + HTML.CreateColorString(bot.ColorHeaderHex, source) + " »» " + bot.ColorNormal + msg; string[] members = this._friendsList.GetOnlineMembers(group, true); bot.SendPrivateMessage(sender, bot.ColorHighlight + "Sending out an announcement to " + HTML.CreateColorString(bot.ColorHeaderHex, members.Length.ToString()) + " members"); foreach (string member in members) { bot.SendPrivateMessage(bot.GetUserID(member), formattedMessage, AoLib.Net.PacketQueue.Priority.Low, true); } members = this._friendsList.GetOnlineMembers(group, false); bot.SendReplyMessage(this.InternalName, message, (object)members); } catch (Exception ex) { Console.WriteLine(ex.ToString()); throw new Exception("exception", ex); } }
private void OnRaidKickCommand(BotShell bot, CommandArgs e) { if (e.Args.Length < 1) { bot.SendReply(e, "Correct Usage: raid kick [username] [reason]"); return; } if (!this._core.Running) { bot.SendReply(e, "There is currently no raid active"); return; } string raider = Format.UppercaseFirst(e.Args[0]); if (!this._core.IsRaider(raider)) { bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, raider) + " is not in the raid"); return; } string reason = "No reason specified"; if (e.Words.Length > 1) { reason = e.Words[1]; } this._core.RemoveRaider(raider, false); if (this.KickedEvent != null) { this.KickedEvent(this, new RaidEventArgs(raider)); } bot.SendPrivateChannelMessage(bot.ColorHighlight + HTML.CreateColorString(bot.ColorHeaderHex, raider) + " has been kicked from the raid"); bot.SendPrivateMessage(raider, bot.ColorHighlight + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender) + " has kicked you to the raid with the following reason: " + HTML.CreateColorString(bot.ColorHeaderHex, reason)); this._core.Log(raider, e.Sender, this.InternalName, "raiders", string.Format("{0} has been kicked from the raid (Points: {1})", raider, this._core.GetPoints(e.Sender))); if (bot.Configuration.GetBoolean(this.InternalName, "autoban", false)) { string main = bot.Users.GetMain(raider); Raider banned = new Raider(); banned.Character = raider; banned.Duration = bot.Configuration.GetInteger(this.InternalName, "banduration", 5); banned.Time = DateTime.Now; lock (this._bans) { this._bans.Add(main, banned); } bot.SendPrivateMessage(raider, bot.ColorHighlight + "Your access to the raid has been automatically suspended for " + HTML.CreateColorString(bot.ColorHeaderHex, banned.Duration.ToString()) + " minutes"); bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, raider) + " has automatically been banned from the raid for " + HTML.CreateColorString(bot.ColorHeaderHex, banned.Duration.ToString()) + " minutes"); this._core.Log(raider, e.Sender, this.InternalName, "bans", string.Format("{0} has automatically banned from the raid for {1} minutes", raider, banned.Duration)); } }
private void Events_PrivateMessageEvent(BotShell bot, PrivateMessageArgs e) { if (e.Self) { return; } if (!this._sendTell) { return; } if (string.IsNullOrEmpty(this._message)) { return; } if (this.ReceivedMessage(e.Sender)) { return; } if (this._skipOne) { this._skipOne = false; return; } if (!bot.Users.Authorized(e.Sender, bot.Commands.GetRight("motd", CommandType.Tell))) { return; } bot.SendPrivateMessage(e.SenderID, bot.ColorHighlight + "Message of the day: " + bot.ColorNormal + this._message); this._database.ExecuteNonQuery(string.Format("INSERT INTO motd VALUES ('{0}')", e.Sender)); }
private void OnTasksAddCommand(BotShell bot, CommandArgs e) { if (e.Args.Length < 2) { bot.SendReply(e, "Correct Usage: tasks add [username] [task]"); return; } string username = Format.UppercaseFirst(e.Args[0]); if (bot.GetUserID(username) < 100) { bot.SendReply(e, "No such user: "******" isn't online right now"); return; } string task = e.Words[1]; this._database.ExecuteNonQuery("DELETE FROM tasks WHERE username = '******'"); this._database.ExecuteNonQuery(string.Format("INSERT INTO tasks (username, task) VALUES ('{0}', '{1}')", username, Config.EscapeString(task))); bot.SendReply(e, "You have assigned a task to " + HTML.CreateColorString(bot.ColorHeaderHex, username)); bot.SendPrivateChannelMessage(bot.ColorHighlight + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender) + " has assigned " + HTML.CreateColorString(bot.ColorHeaderHex, username) + " the following task: " + HTML.CreateColorString(bot.ColorHeaderHex, task)); bot.SendPrivateMessage(username, bot.ColorHighlight + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender) + " has assigned you the following task: " + HTML.CreateColorString(bot.ColorHeaderHex, task)); }
private void OnMassCommand(BotShell bot, CommandArgs e, bool invite) { if (e.Words.Length < 1) { bot.SendReply(e, "Correct Usage: " + e.Command + " [message]"); return; } string[] members = this.GetOnlineMembers(); if (invite) { bot.SendReply(e, "Sending out an mass invite to " + HTML.CreateColorString(bot.ColorHeaderHex, members.Length.ToString()) + " members"); } else { bot.SendReply(e, "Sending out an announcement to " + HTML.CreateColorString(bot.ColorHeaderHex, members.Length.ToString()) + " members"); } string message = bot.ColorHighlight + "Message from " + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender) + " »» " + bot.ColorNormal + e.Words[0]; foreach (string member in members) { if (invite && !bot.PrivateChannel.IsOn(member)) { bot.PrivateChannel.Invite(member); } } foreach (string member in members) { bot.SendPrivateMessage(bot.GetUserID(member), message, AoLib.Net.PacketQueue.Priority.Low, true); } }
private void OnRaidUnbanCommand(BotShell bot, CommandArgs e) { if (e.Args.Length < 1) { bot.SendReply(e, "Correct Usage: raid unban [username]"); return; } string character = Format.UppercaseFirst(e.Args[0]); if (bot.GetUserID(character) < 100) { bot.SendReply(e, "No such user: "******" is not banned from this raid"); return; } character = this._bans[main].Character; this._bans.Remove(main); bot.SendPrivateMessage(character, this._bot.ColorHighlight + "Your access to the raid has been restored by " + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender)); bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, character) + " has been unbanned from the raid"); this._core.Log(character, e.Sender, this.InternalName, "bans", string.Format("{0} has been unbanned from the raid", character)); } }
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 OnVoteStopCommand(BotShell bot, CommandArgs e) { if ((this._admin.IndexOf(e.Sender, 0) >= 0) || (bot.Users.GetUser(e.Sender) >= UserLevel.Leader)) { if (!this._running) { bot.SendPrivateMessage(e.SenderID, "There is no election to stop"); return; } lock (this._joined) { bot.SendPrivateMessage(e.SenderID, "You have ended the election"); if ((_quorum > 0) && (this._yes + this._no + this._abs < this._quorum)) { bot.SendPrivateChannelMessage(bot.ColorHighlight + "The election has been aborted due to lack of quorum."); } else { string result = "no"; int require = (this._yes + this._no) * (this._percentage / 100); if (this._yes >= require) { result = "yes"; } bot.SendPrivateChannelMessage("The election has ended for: " + _description); bot.SendPrivateChannelMessage("Election result is: " + result); } this._running = false; this._admin = null; this._joined.Clear(); this._yes = 0; this._no = 0; this._abs = 0; } } else { bot.SendPrivateMessage(e.SenderID, e.Sender + " was not the person who started the vote or does not have sufficient privileges to end the voting."); return; } }
private void Events_UserLogonEvent(BotShell bot, UserLogonArgs e) { if (e.First) { return; } if (e.Sections.Contains("guestlist")) { bot.SendPrivateMessage(e.SenderID, bot.ColorHighlight + "You have been invited to the private channel because you're on this bot's guestlist. To remove yourself from the guestlist use: " + HTML.CreateColorString(bot.ColorHeaderHex, "/tell " + bot.Character + " guestlist remove")); bot.PrivateChannel.Invite(e.SenderID); } }
private void OnVoteAbortCommand(BotShell bot, CommandArgs e) { if ((this._admin.IndexOf(e.Sender, 0) >= 0) || (bot.Users.GetUser(e.Sender) >= UserLevel.Leader)) { if (!this._running) { bot.SendPrivateMessage(e.SenderID, "There is election to abort"); return; } this._running = false; this._admin = null; lock (this._joined) this._joined.Clear(); bot.SendPrivateChannelMessage(bot.ColorHighlight + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender) + " has aborted the election"); bot.SendPrivateMessage(e.SenderID, "You aborted the election"); } else { bot.SendPrivateMessage(e.SenderID, e.Sender + " was not the person who started the election and/or does not have sufficient privileges to stop the election."); return; } }
private void OnPrivateMessageEvent(BotShell bot, PrivateMessageArgs e) { if (!this._enabled) { return; } if (bot.Users.Authorized(e.Sender, UserLevel.Member)) { return; } WhoisResult whois = e.SenderWhois; if (whois == null || !whois.Success) { return; } if (this._factions.Count > 0 && !this._factions.Contains(whois.Stats.Faction)) { return; } if (this._levels.Count > 0 && !this._levels.Contains(whois.Stats.Level)) { return; } if (this._defenderRanks.Count > 0 && !this._defenderRanks.Contains(whois.Stats.DefenderLevel)) { return; } if (this._professions.Count > 0 && !this._professions.Contains(whois.Stats.Profession)) { return; } if (this._breeds.Count > 0 && !this._breeds.Contains(whois.Stats.Breed)) { return; } if (this._genders.Count > 0 && !this._genders.Contains(whois.Stats.Gender)) { return; } bot.Users.AddUser(e.Sender, UserLevel.Member); if (this._guestlist) { bot.FriendList.Add("guestlist", e.Sender); } bot.SendPrivateMessage(e.SenderID, bot.ColorHighlight + "You have been automatically added as member of this bot"); }
private void OnVoteStartCommand(BotShell bot, CommandArgs e) { if (this._running && (e.Words.Length >= 3)) { bot.SendPrivateMessage(e.SenderID, "An election has already been started."); } if (!this._running && (e.Words.Length >= 3)) { if (!int.TryParse(e.Args[0], out _quorum)) { _quorum = 0; } if (!int.TryParse(e.Args[1], out _percentage)) { switch (e.Args[1]) { case "majority": _percentage = 51; break; case "supermajority": _percentage = 67; break; case "unanimous": _percentage = 100; break; } } if (_percentage == 0) { _percentage = 51; } _description = e.Args[2]; for (int iter = 2; iter < e.Args.Length; iter++) { _description = _description + " " + e.Args[iter]; } this._admin = e.Sender; this._running = true; _yes = 0; _no = 0; _abs = 0; } this.OnVoteStatusCommand(bot, e); }
private void Events_UserLogonEvent(BotShell bot, UserLogonArgs e) { if (!this._sendLogon) { return; } if (string.IsNullOrEmpty(this._message)) { return; } if (!e.Sections.Contains("notify")) { return; } bot.SendPrivateMessage(e.SenderID, bot.ColorHighlight + "Message of the day: " + bot.ColorNormal + this._message); }
private void OnPointsCommand(BotShell bot, CommandArgs e) { string raider; bool other = false; if (e.Args.Length > 0 && (bot.Users.GetUser(e.Sender) > bot.Commands.GetRight(e.Command, e.Type) || bot.Users.GetUser(e.Sender) == UserLevel.SuperAdmin)) { other = true; } if (other) { raider = bot.Users.GetMain(e.Args[0]); } else { raider = bot.Users.GetMain(e.Sender); } double points = this._core.GetPoints(raider); if (points < this._core.MinimumPoints) { if (other) { bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, raider) + " doesn't have any points"); } else { bot.SendReply(e, "You don't have any points"); } return; } if (other) { bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, raider) + " has " + HTML.CreateColorString(bot.ColorHeaderHex, points.ToString()) + " points"); } else if (e.Type == CommandType.Tell) { bot.SendPrivateMessage(e.Sender, bot.ColorHighlight + "You have " + HTML.CreateColorString(bot.ColorHeaderHex, points.ToString()) + " points", AoLib.Net.PacketQueue.Priority.Low, true); } else { bot.SendReply(e, "You have " + HTML.CreateColorString(bot.ColorHeaderHex, points.ToString()) + " points"); } }
private void UserJoinChannelEvent(BotShell bot, UserJoinChannelArgs e) { if (!e.Local) { return; } lock (this._lds) { if (this._lds.ContainsKey(e.Sender)) { if (this._core.AddRaider(e.Sender, false)) { bot.SendPrivateChannelMessage(bot.ColorHighlight + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender) + " has rejoined the raid"); bot.SendPrivateMessage(e.SenderID, bot.ColorHighlight + "Welcome back. You have automatically rejoined the raid"); this._core.Log(e.Sender, null, this.InternalName, "raiders", string.Format("{0} has automatically rejoined the raid (Points: {1})", e.Sender, this._core.GetPoints(e.Sender))); } this._lds.Remove(e.Sender); } } }
public override void OnCommand(BotShell bot, CommandArgs e) { if (e.Command != "broadcast") { return; } if (e.Args.Length < 1) { bot.SendReply(e, "Correct Usage: broadcast [message]"); return; } string[] members = this._friendsList.GetOnlineMembers(); string formattedMessage = bot.ColorHighlight + "Broadcast from " + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender) + " »» " + bot.ColorNormal + e.Words[0].Trim(); bot.SendReply(e, "Sending out a broadcast to " + HTML.CreateColorString(bot.ColorHeaderHex, members.Length.ToString()) + " members"); foreach (string member in members) { bot.SendPrivateMessage(bot.GetUserID(member), formattedMessage, AoLib.Net.PacketQueue.Priority.Low, true); } }
public override void OnCommand(BotShell bot, CommandArgs e) { switch (e.Command) { case "members clear": if (e.Args.Length == 0 || e.Args[0] != "confirm") { bot.SendReply(e, "This command will remove ALL members. If you wish to continue use: /tell " + bot.Character + " members clear confirm"); break; } bot.Users.RemoveAll(); bot.SendReply(e, "All members have been removed"); break; case "members add": case "members remove": case "members promote": case "members demote": if (e.Args.Length < 1) { bot.SendReply(e, "Correct Usage: " + e.Command + " [username]"); break; } if (bot.GetUserID(e.Args[0]) < 1) { bot.SendReply(e, "No such user: "******"members add": if (bot.Users.UserExists(username, bot.GetUserID(username))) { bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(username)) + " is already a member of this bot"); break; } if (bot.Users.IsAlt(username)) { bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(username)) + " is register as alt on this bot"); break; } if (bot.Users.AddUser(username, UserLevel.Member, e.Sender)) { bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(username)) + " has been added to this bot"); } else { bot.SendReply(e, "An unknown error has occurred"); } break; case "members remove": if (bot.Users.IsAlt(username)) { bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(username)) + " is alt and can't be removed using this command"); break; } if (!bot.Users.UserExists(username)) { bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(username)) + " is not a member of this bot"); break; } bot.Users.RemoveUser(username); bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(username)) + " has been removed from this bot"); break; case "members promote": if (!bot.Users.UserExists(username)) { bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(username)) + " is not a member of this bot"); break; } UserLevel promotelevel = bot.Users.GetUser(username); if (promotelevel >= bot.Users.GetUser(e.Sender)) { bot.SendReply(e, "You can't promote a user to a higher rank than your own rank!"); break; } try { promotelevel = (UserLevel)((int)promotelevel * 2); if (promotelevel != UserLevel.Disabled) { if (bot.Users.SetUser(username, promotelevel)) { bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(username)) + " has been promoted to " + HTML.CreateColorString(bot.ColorHeaderHex, promotelevel.ToString())); break; } } } catch { } bot.SendReply(e, "An unknown error has occurred"); break; case "members demote": if (!bot.Users.UserExists(username)) { bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(username)) + " is not a member of this bot"); break; } UserLevel demotelevel = bot.Users.GetUser(username); if (demotelevel > bot.Users.GetUser(e.Sender)) { bot.SendReply(e, "You can't demote a user that outranks you!"); break; } if (bot.Admin.ToLower() == username.ToLower()) { bot.SendReply(e, "You can't demote the main bot administrator!"); bot.SendPrivateMessage(bot.Admin, bot.ColorHeader + e.Sender + bot.ColorHighlight + " attempted to demote you!"); break; } try { demotelevel = (UserLevel)((int)demotelevel / 2); if (demotelevel != UserLevel.Guest) { if (bot.Users.SetUser(username, demotelevel)) { bot.SendReply(e, HTML.CreateColorString(bot.ColorHeaderHex, Format.UppercaseFirst(username)) + " has been demoted to " + HTML.CreateColorString(bot.ColorHeaderHex, demotelevel.ToString())); break; } } else { bot.SendReply(e, "You can't demote a user to a rank below member!"); break; } } catch { } bot.SendReply(e, "An unknown error has occurred"); break; } break; case "alts add": this.OnAltsAddCommand(bot, e); break; case "alts remove": this.OnAltsRemoveCommand(bot, e); break; case "alts admin add": this.OnAltsAdminAddCommand(bot, e); break; case "alts admin remove": this.OnAltsAdminRemoveCommand(bot, e); break; } }
private void OnRaidJoinCommand(BotShell bot, CommandArgs e) { if (!bot.PrivateChannel.IsOn(e.Sender)) { bot.SendReply(e, "You're required to be on the private channel to join the raid"); return; } if (!this._core.Running) { bot.SendReply(e, "There is currently no raid active"); return; } if (this._core.IsRaider(e.Sender)) { bot.SendReply(e, "You're already in the raid"); return; } if (this._core.Locked) { bot.SendReply(e, "The raid is currently locked"); return; } string username = bot.Users.GetMain(e.Sender); if (this._core.IsRaider(username)) { bot.SendReply(e, "You already have a character on this raid"); return; } lock (this._bans) { if (this._bans.ContainsKey(username)) { bot.SendReply(e, "Your access to the raid has been temporarily disabled"); return; } } if (this.AltsLevelReq > 0 || this.MainsLevelReq > 0) { int level = 0; WhoisResult whois = XML.GetWhois(e.Sender, bot.Dimension); if (whois != null && whois.Success) { level = whois.Stats.Level; } if (bot.Users.IsAlt(e.Sender)) { if (level < this.AltsLevelReq) { bot.SendReply(e, "Alts are required to be at least level " + HTML.CreateColorString(bot.ColorHeaderHex, this.AltsLevelReq.ToString()) + " in order to join the raid"); return; } } else { if (level < this.MainsLevelReq) { bot.SendReply(e, "Mains are required to be at least level " + HTML.CreateColorString(bot.ColorHeaderHex, this.MainsLevelReq.ToString()) + " in order to join the raid"); return; } } } int credits = 0; int max = 0; bool charged = false; if (this.CreditsEnabled && !this.WithdrawCredit(bot, username, out credits, out max, out charged)) { bot.SendReply(e, "You don't have enough raid credits to join this raid"); return; } this._core.AddRaider(e.Sender, true); if (charged) { bot.SendPrivateMessage(e.Sender, bot.ColorHighlight + "You have been charged a raid credit for this raid. You have used " + HTML.CreateColorString(bot.ColorHeaderHex, credits + "/" + max) + " raid credits for this type of raid"); this._core.Log(e.Sender, null, this.InternalName, "credits", string.Format("{0} has been charged a raid credit (Credits Left: {1})", e.Sender, credits)); } }
private void Events_PrivateChannelMessageEvent(BotShell bot, PrivateChannelMessageArgs e) { if (e.Self == true) { return; } if (bot.Configuration.GetBoolean(this.InternalName, "inccommands", true) == false) { if (e.Command == true) { return; } } if (bot.Configuration.GetBoolean(this.InternalName, "limmune", true) == true) { if (bot.Users.GetUser(e.Sender) == UserLevel.Leader) { return; } } if (bot.Configuration.GetBoolean(this.InternalName, "aimmune", true) == true) { if (bot.Users.GetUser(e.Sender) == UserLevel.Admin) { return; } } if (bot.Configuration.GetBoolean(this.InternalName, "saimmune", true) == true) { if (bot.Users.GetUser(e.Sender) == UserLevel.SuperAdmin) { return; } } if (Flooder.ContainsKey(e.SenderID)) { Flooder[e.SenderID].FloodCount += 1; Flooder[e.SenderID].LastSaid = TimeStamp.Now; // Handles the Pure FloodPart long TimeDiff = Flooder[e.SenderID].LastSaid - Flooder[e.SenderID].FirstSaid; if (TimeDiff <= bot.Configuration.GetInteger(this.InternalName, "flooddelay", 5) && bot.Configuration.GetInteger(this.InternalName, "flooddelay", 5) != 0) { if (bot.Configuration.GetInteger(this.InternalName, "floodkick", 7) != 0 && Flooder[e.SenderID].Kick == false && Flooder[e.SenderID].FloodCount >= bot.Configuration.GetInteger(this.InternalName, "floodkick", 7)) { Flooder[e.SenderID].Kick = true; if (bot.PrivateChannel.IsOn(e.SenderID)) { bot.PrivateChannel.Kick(e.Sender); bot.SendPrivateChannelMessage(bot.ColorHighlight + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender) + " has been removed from the private channel for flooding"); bot.SendPrivateMessage(e.Sender, bot.ColorHighlight + "You have been removed from the private channel for flooding!", false); } } else if (bot.Configuration.GetInteger(this.InternalName, "floodwarning", 5) != 0 && Flooder[e.SenderID].FloodCount >= bot.Configuration.GetInteger(this.InternalName, "floodwarning", 5) && Flooder[e.SenderID].Warning == false && Flooder[e.SenderID].Kick == false) { Flooder[e.SenderID].Warning = true; bot.SendPrivateMessage(e.Sender, bot.ColorHighlight + "Warning! You're close to being kicked for flooding", false); } } else { Flooder[e.SenderID].FloodCount = 0; Flooder[e.SenderID].FirstSaid = TimeStamp.Now; Flooder[e.SenderID].Warning = false; } // End of flood part // Handles the Repeation part if (e.Message.ToLower() == Flooder[e.SenderID].LastLine.ToLower()) { Flooder[e.SenderID].RepeatCount += 1; if (bot.Configuration.GetInteger(this.InternalName, "repeatkick", 4) != 0 && Flooder[e.SenderID].RepeatCount >= bot.Configuration.GetInteger(this.InternalName, "repeatkick", 4) && Flooder[e.SenderID].Kick == false) { Flooder[e.SenderID].Kick = true; if (bot.PrivateChannel.IsOn(e.SenderID)) { bot.PrivateChannel.Kick(e.Sender); bot.SendPrivateChannelMessage(bot.ColorHighlight + HTML.CreateColorString(bot.ColorHeaderHex, e.Sender) + " has been removed from the private channel for repeating"); bot.SendPrivateMessage(e.Sender, bot.ColorHighlight + "You have been removed from the private channel for repeating!", false); } } else if (bot.Configuration.GetInteger(this.InternalName, "repeatwarning", 3) != 0 && Flooder[e.SenderID].RepeatCount >= bot.Configuration.GetInteger(this.InternalName, "repeatwarning", 3) && Flooder[e.SenderID].Warning == false && Flooder[e.SenderID].Kick == false) { Flooder[e.SenderID].Warning = true; bot.SendPrivateMessage(e.Sender, bot.ColorHighlight + "Warning! You're close to being kicked for repeating", false); } } else { Flooder[e.SenderID].RepeatCount = 1; } Flooder[e.SenderID].LastLine = e.Message; // End of repeat part } else { Flooder.Add(e.SenderID, new Flooders(e.Sender, TimeStamp.Now, TimeStamp.Now, 1, false, false, e.Message, 1)); } }
public override void OnCommand(BotShell bot, CommandArgs e) { // make !status display various stats of the bot and the current state of all slaves and their friendslists, also include links to relog etc switch (e.Command) { case "shutdown": bot.SendOrganizationMessage(bot.ColorHighlight + "System »» Shutting Down"); bot.SendPrivateMessage(e.SenderID, bot.ColorHighlight + "System »» Shutting Down", AoLib.Net.PacketQueue.Priority.Urgent, true); bot.SendPrivateChannelMessage(bot.ColorHighlight + "System »» Shutting Down"); System.Threading.Thread.Sleep(1000); bot.Shutdown(); break; case "restart": if (!bot.CoreConnected) { bot.SendReply(e, "Restart is not available"); return; } bot.SendOrganizationMessage(bot.ColorHighlight + "System »» Rebooting"); bot.SendPrivateMessage(e.SenderID, bot.ColorHighlight + "System »» Rebooting", AoLib.Net.PacketQueue.Priority.Urgent, true); bot.SendPrivateChannelMessage(bot.ColorHighlight + "System »» Rebooting"); System.Threading.Thread.Sleep(1000); bot.Restart(); break; case "core": this.OnCoreCommand(bot, e); break; case "core shutdown": case "core start": case "core restart": if (e.Args.Length < 1 || !e.Args[0].Contains("@")) { bot.SendReply(e, "Usage: " + e.Command + " [bot@dimension]"); return; } if (!bot.Master) { bot.SendReply(e, "This bot is not a master bot"); return; } CoreCommand command; if (e.Command == "core shutdown") { command = CoreCommand.Shutdown; } else if (e.Command == "core start") { command = CoreCommand.Start; } else { command = CoreCommand.Restart; } MessageResult result = bot.SendCoreMessage(this.InternalName, e.Args[0].ToLower(), command); switch (result) { case MessageResult.Success: bot.SendReply(e, "Your command has been relayed to the core and will be executed shortly"); break; case MessageResult.InvalidTarget: bot.SendReply(e, "The target you specified appeared to be invalid"); break; case MessageResult.NotConnected: bot.SendReply(e, "Unable to connect to the core in order to issue this command"); break; default: bot.SendReply(e, "An unknown error prevented your command from being executed"); break; } break; case "core clean": bot.Clean(); bot.SendReply(e, "Memory cleaning routines have been executed"); break; } }
private void VoteUsage(CommandArgs e) { _bot.SendPrivateMessage(e.SenderID, "Correct Usage: vote start [quorum] [percentage] [description]"); _bot.SendPrivateMessage(e.SenderID, "A quorum of zero (0) indicates no quorum is needed."); }