public void cmdCCinfo(string message) { if (message == "") { sendToUser("Syntax: ccinfo <channel>", true, false, false); } else { ClubChannel info = ClubChannel.LoadChannel(message); if (info == null) { sendToUser("Channel \"" + message + "\" not found", true, false, false); } else { string userlist = ""; string output = "{bold}{cyan}---[{red}Channel info{cyan}]".PadRight(103, '-') + "{reset}\r\n"; output += "{bold}{red} Name: {reset}" + info.PreColour + "[" + info.NameColour + info.Name + info.PreColour + "]{reset}\r\n"; output += "{bold}{red}Owner: {reset}" + info.Owner + "\r\n"; output += "{bold}{red} Info: {reset}" + info.MainColour + info.Description + "{reset}\r\n"; output += "{bold}{red}Users: {reset}"; foreach (string u in info.Users) { userlist += ", " + u; } output += (userlist == "" ? "None" : userlist.Substring(2)); output += "\r\n{bold}{cyan}".PadRight(92, '-') + "{reset}\r\n"; sendToUser(output, true, false, false); } } }
public void cmdCCSing(string message) { if (message == "" || message.IndexOf(" ") == -1) { sendToUser("Syntax: cs <channel> <message>", true, false, false); } else { string[] split = message.Split(new char[] { ' ' }, 2); ClubChannel targ = ClubChannel.LoadChannel(split[0]); if (myPlayer.ClubChannelMute) { sendToUser("You cannot send to channels if you have them muted", true, false, false); } else if (targ == null) { sendToUser("Channel \"" + split[0] + "\" not found", true, false, false); } else if (!targ.OnChannel(myPlayer.UserName)) { sendToUser("You are not on channel \"" + targ.Name + "\"", true, false, false); } else { sendToChannel(targ.Name, myPlayer.UserName + " sings ./ " + split[1] + " ./", false); } } }
public void cmdCCdesc(string message) { if (message == "") { sendToUser("Syntax: ccdesc <channel> <description>", true, false, false); } else { string chanName; string chanDesc = ""; if (message.IndexOf(" ") == -1) { chanName = message; } else { string[] split = message.Split(new char[] { ' ' }, 2); chanName = split[0]; chanDesc = split[1]; } if (ClubChannel.LoadChannel(chanName) == null) { sendToUser("Channel \"" + chanName + "\" not found", true, false, false); } else { clubChannels = ClubChannel.LoadAllChannels(); bool found = false; foreach (ClubChannel c in clubChannels) { if (c.Name.ToLower() == chanName.ToLower()) { found = true; if (c.Owner.ToLower() != myPlayer.UserName.ToLower() && myPlayer.PlayerRank < (int)Player.Rank.Admin) { sendToUser("Sorry, you are not the owner of the channel", true, false, false); } else { c.Description = chanDesc; sendToUser(chanDesc == "" ? "You remove the description for channel \"" + c.Name + "\"" : "You set the description for channel \"" + c.Name + "\" to \"" + chanDesc + "\"", true, false, false); c.SaveChannel(); } } } if (!found) { sendToUser("Strange ... you shouldn't be here ...", true, false, false); } else { clubChannels = ClubChannel.LoadAllChannels(); } } } }
public void cmdCCnCol(string message) { if (message == "" || message.IndexOf(" ") == -1) { sendToUser("Syntax: ccncol <channel> <colour code>", true, false, false); } else { string[] split = message.Split(new char[] { ' ' }, 2); if (ClubChannel.LoadChannel(split[0]) == null) { sendToUser("Channel \"" + split[0] + "\" not found", true, false, false); } else { clubChannels = ClubChannel.LoadAllChannels(); bool found = false; foreach (ClubChannel c in clubChannels) { if (c.Name.ToLower() == split[0].ToLower()) { found = true; if (c.Owner.ToLower() != myPlayer.UserName.ToLower() && myPlayer.PlayerRank < (int)Player.Rank.Admin) { sendToUser("Sorry, you are not the owner of the channel", true, false, false); } else if (AnsiColour.Colorise(split[1], true) != "") { sendToUser("That is not a valid colour code"); } else { c.NameColour = split[1]; sendToUser("Name colour set for channel \"" + c.Name + "\"", true, false, false); c.SaveChannel(); } } } if (!found) { sendToUser("Strange ... you shouldn't be here ...", true, false, false); } else { clubChannels = ClubChannel.LoadAllChannels(); } } } }
public void cmdCCwho(string message) { if (message == "") { sendToUser("Syntax: ccwho <channel>", true, false, false); } else { ClubChannel c = ClubChannel.LoadChannel(message); if (c == null) { sendToUser("Channel \"" + message + "\" not found", true, false, false); } else if (!c.OnChannel(myPlayer.UserName) && myPlayer.PlayerRank < (int)Player.Rank.Admin) { sendToUser("You are not on channel \"" + c.Name + "\"", true, false, false); } else { string output = "{bold}{cyan}---[{red}CCWho{cyan}]".PadRight(103, '-') + "{reset}\r\nListening on channel \"" + c.Name + "\"\r\n"; string users = ""; if (isOnline(c.Owner)) { foreach (Connection conn in connections) { if (conn.socket.Connected && conn.myPlayer != null && conn.myPlayer.UserName.ToLower() == c.Owner.ToLower() && !conn.myPlayer.ClubChannelMute) { users += ", " + conn.myPlayer.ColourUserName; } } } foreach (string user in c.Users) { foreach (Connection conn in connections) { if (conn.socket.Connected && conn.myPlayer != null && conn.myPlayer.UserName.ToLower() == user.ToLower() && !conn.myPlayer.ClubChannelMute) { users += ", " + conn.myPlayer.ColourUserName; } } } sendToUser(output + (users == "" ? "None" : users.Substring(2)) + "\r\n{bold}{cyan}".PadRight(94, '-') + "{reset}", true, false, false); } } }
private void sendToChannel(string channel, string message, bool nohistory) { ClubChannel chan = ClubChannel.LoadChannel(channel); if (chan == null) { sendToUser("Error sending to channel", true, false, false); } else { foreach (Connection c in connections) { if (c.socket.Connected && c.myState >= 10 && c.myPlayer != null && chan.OnChannel(c.myPlayer.UserName) && !c.myPlayer.ClubChannelMute && !c.myPlayer.InEditor) { c.sendToUser(chan.FormatMessage(message), true, c.myPlayer.UserName != myPlayer.UserName, nohistory); } } } }
public void cmdCCrname(string message) { if (message == "" || message.IndexOf(" ") == -1) { sendToUser("Syntax: ccrname <channel name> <new name>", true, false, false); } else { string[] split = message.Split(new char[] { ' ' }); ClubChannel test = ClubChannel.LoadChannel(split[1]); if (test != null) { sendToUser("Channel \"" + split[1] + "\" already exists", true, false, false); } else { bool found = false; foreach (ClubChannel c in clubChannels) { if (c.Name.ToLower() == split[0]) { found = true; c.Name = split[1]; c.SaveChannel(); sendToUser("Channel \"" + split[0] + "\" renamed to \"" + split[1] + "\"", true, false, false); logToFile(myPlayer.UserName + " renames channel \"" + split[0] + "\" to \"" + split[1] + "\"", "channel"); } } if (!found) { sendToUser("Channel \"" + split[0] + "\" not found", true, false, false); } else { clubChannels = ClubChannel.LoadAllChannels(); } } } }
public void cmdCCjoin(string message) { if (message == "" || message.IndexOf(" ") == -1) { sendToUser("Syntax: ccjoin <channel> <player>", true, false, false); } else { string[] split = message.Split(new char[] { ' ' }, 2); string[] target = matchPartial(split[1]); if (target.Length == 0) { sendToUser("Player \"" + split[1] + "\" not found", true, false, false); } else if (target.Length > 1) { sendToUser("Multiple matches found: " + target.ToString() + " - Please use more letters", true, false, false); } else if (ClubChannel.LoadChannel(split[0]) == null) { sendToUser("Channel \"" + split[0] + "\" not found", true, false, false); } else { clubChannels = ClubChannel.LoadAllChannels(); bool found = false; foreach (ClubChannel c in clubChannels) { if (c.Name.ToLower() == split[0].ToLower()) { found = true; if (c.Owner.ToLower() != myPlayer.UserName.ToLower() && myPlayer.PlayerRank < (int)Player.Rank.Admin) { sendToUser("Sorry, you are not the owner of the channel", true, false, false); } else if (myPlayer.UserName.ToLower() == target[0].ToLower()) { sendToUser("You cannot remove yourself from this channel", true, false, false); } else { if (c.OnChannel(target[0])) { sendToUser("Player \"" + target[0] + "\" removed from channel \"" + c.Name + "\"", true, false, false); if (isOnline(target[0])) { sendToUser("You have been removed from channel \"" + c.Name + "\"", target[0], true, false, true, false); } c.RemovePlayer(target[0]); c.SaveChannel(); } else { sendToUser("Player \"" + target[0] + "\" added to channel \"" + c.Name + "\"", true, false, false); if (isOnline(target[0])) { sendToUser("You have been added to channel \"" + c.Name + "\"", target[0], true, false, true, false); } c.AddPlayer(target[0]); c.SaveChannel(); } } } } if (!found) { sendToUser("Strange - something has gone a bit wrong", true, false, false); } else { clubChannels = ClubChannel.LoadAllChannels(); } } } }