Example #1
0
        public void cmdCCdel(string message)
        {
            clubChannels = ClubChannel.LoadAllChannels();

            if (message == "")
            {
                sendToUser("Syntax: ccdel <channel name>", true, false, false);
            }
            else
            {
                bool found = false;
                List <ClubChannel> temp = clubChannels;
                for (int i = 0; i < temp.Count; i++)
                {
                    if (temp[i].Name.ToLower() == message.ToLower())
                    {
                        found = true;
                        sendToUser("Channel \"" + temp[i].Name + "\" deleted", true, false, false);
                        logToFile(myPlayer.UserName + " deletes channel \"" + temp[i].Name + "\"", "channel");
                        clubChannels[i].Delete();
                        clubChannels.RemoveAt(i);
                    }
                }
                if (!found)
                {
                    sendToUser("Channel \"" + message + "\" not found", true, false, false);
                }
                ClubChannel.SaveAllChannels(clubChannels, true);
                clubChannels = ClubChannel.LoadAllChannels();
            }
        }
Example #2
0
        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();
                    }
                }
            }
        }
Example #3
0
        public void cmdCCadd(string message)
        {
            if (message == "" || message.IndexOf(" ") == -1)
            {
                sendToUser("Syntax: ccadd <channel name> <owner>", 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");
                }
                else if (target.Length > 1)
                {
                    sendToUser("Multiple matches found: " + target.ToString() + " - Please use more letters", 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 (found)
                    {
                        sendToUser("Channel already exists", true, false, false);
                    }
                    else
                    {
                        ClubChannel chan = new ClubChannel();
                        chan.Name  = split[0];
                        chan.Owner = target[0];
                        clubChannels.Add(chan);
                        ClubChannel.SaveAllChannels(clubChannels, true);
                        sendToUser("Channel \"" + chan.Name + "\" created");
                        logToFile(myPlayer.UserName + " creates a new channel called " + chan.Name + " owned by " + chan.Owner, "channel");
                        if (target[0].ToLower() != myPlayer.UserName.ToLower() && isOnline(target[0]))
                        {
                            Player p = Player.LoadPlayer(target[0], 0);
                            sendToUser("You have been given a new club channel called \"" + chan.Name + "\"", p.UserName, true, p.DoColour, true, false);
                        }
                        clubChannels = ClubChannel.ReindexChannels(clubChannels);
                        clubChannels = ClubChannel.LoadAllChannels();
                    }
                }
            }
        }
Example #4
0
        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();
                    }
                }
            }
        }
Example #5
0
        public static string getChannels(string username)
        {
            List <ClubChannel> clubChannels = ClubChannel.LoadAllChannels();

            string ret = "";

            foreach (ClubChannel c in clubChannels)
            {
                if (c.OnChannel(username))
                {
                    ret += ", " + c.Name;
                }
            }
            return(ret == "" ? "None" : ret.Substring(2));
        }
Example #6
0
        public void cmdCClist(string message)
        {
            clubChannels = ClubChannel.LoadAllChannels();

            string ret = "{bold}{cyan}---[{red}Channels{cyan}]".PadRight(103, '-') + "{reset}\r\n";

            if (clubChannels.Count == 0)
            {
                ret += "No channels exist\r\n";
            }
            else
            {
                foreach (ClubChannel c in clubChannels)
                {
                    ret += "{bold}{blue}[" + c.ID + "]{reset} " + c.Name + " - " + c.Description + "\r\n";
                }
            }

            ret += "{bold}{cyan}".PadRight(92, '-') + "{reset}\r\n";
            sendToUser(ret, true, false, false);
        }
Example #7
0
 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();
             }
         }
     }
 }
Example #8
0
        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();
                    }
                }
            }
        }