Beispiel #1
0
        void client_ChannelModeSet(object sender, ModeSetEventArgs e)
        {
            tempBool = userIsSquelched(e.To); //Remember if user was squelched
            tempInt  = getUserByName(e.To);   //Gets the index where the target user is found in the user list.
            Console.WriteLine("MODE SET OUTPUT: "
                              + "\nCHANNEL: " + e.Channel
                              + "\nFROM: " + e.From
                              + "\nMODE: " + e.Mode
                              + "\nTO: " + e.To);

            /*
             * ADDING MODES
             */
            if (e.Mode.StartsWith("+"))
            {
                /*
                 * OP and Halfop
                 */
                if (e.Mode.Contains("o") || e.Mode.Contains("h"))
                {
                    if (tempInt >= 0)
                    {
                        tempString = "op";      //Save picture
                        cw.removeUser(tempInt); //Remove user
                        users.RemoveAt(tempInt);
                        tempInt = 0;
                        users.Insert(tempInt, new User(tempString, e.To, tempBool));
                        cw.AddToChatWindow(3, e.To, " is now a channel operator.");
                        if (tempBool)
                        {
                            cw.insertUser(tempInt, "squelch", e.To);    //Re-add user at old index
                        }
                        else
                        {
                            cw.insertUser(tempInt, tempString, e.To);    //Re-add user at old index
                        }
                        //Cleanup if need be
                        tempList = getUsersByName(tempString);
                        if (tempList.Count > 1)
                        {
                            cw.removeUser(tempList.ElementAt(tempList.Count - 1));
                        }
                    }
                }

                /*
                 * VOICE mode
                 */
                else if (e.Mode.Contains("v"))
                {
                    if (tempInt >= 0)
                    {
                        tempString = "spkr";    //Save picture
                        cw.removeUser(tempInt); //Remove user
                        users.RemoveAt(tempInt);
                        cw.AddToChatWindow(3, e.To, " is now a speaker.");
                        try
                        {
                            users.Insert(tempInt, new User(tempString, e.To, tempBool));
                            if (tempBool)
                            {
                                cw.insertUser(tempInt, "squelch", e.To);    //Re-add user at old index with new name
                            }
                            else
                            {
                                cw.insertUser(tempInt, tempString, e.To);    //Re-add user at old index with new name
                            }
                        }
                        catch (ArgumentOutOfRangeException ex)
                        {
                            users.Add(new User(tempString, e.To, tempBool));
                            if (tempBool)
                            {
                                cw.addUser("squelch", e.To);    //Re-add user at old index with new name
                            }
                            else
                            {
                                cw.addUser(tempString, e.To);    //Re-add user at old index with new name
                            }
                        }
                    }
                }
                else if (e.Mode.Contains("b"))
                {
                    cw.AddToChatWindow(3, e.To, " was banned by " + e.From + ".");
                }
            }

            /*
             * REMOVING MODES
             */
            if (e.Mode.StartsWith("-"))
            {
                /*
                 * OP and Halfop
                 */
                if (e.Mode.Contains("o") || e.Mode.Contains("h"))
                {
                    if (tempInt >= 0)
                    {
                        cw.removeUser(tempInt);   //Remove user
                        users.RemoveAt(tempInt);
                        tempString = cw.getUserProfile(e.To).PictureID;
                        users.Add(new User(tempString, e.To, tempBool));
                        cw.AddToChatWindow(3, e.To, " is no longer a channel operator.");
                        if (tempBool)
                        {
                            cw.addUser("squelch", e.To);    //Re-add user at old index with new name
                        }
                        else
                        {
                            cw.addUser(tempString, e.To);    //Re-add user at old index with new name
                        }
                    }
                }

                /*
                 * VOICE mode
                 */
                else if (e.Mode.Contains("v"))
                {
                    if (tempInt >= 0)
                    {
                        tempString = cw.getUserProfile(e.To).PictureID; //Save picture
                        cw.removeUser(tempInt);                         //Remove user
                        users.RemoveAt(tempInt);
                        cw.AddToChatWindow(3, e.To, " is no longer a speaker.");
                        try
                        {
                            users.Insert(tempInt, new User(tempString, e.To, tempBool));   //Remember if user was squelched
                            if (tempBool)
                            {
                                cw.insertUser(tempInt, "squelch", e.To);    //Re-add user at old index with new name
                            }
                            else
                            {
                                cw.insertUser(tempInt, tempString, e.To);    //Re-add user at old index with new name
                            }
                        }
                        catch (ArgumentOutOfRangeException ex)
                        {
                            users.Add(new User(tempString, e.To, tempBool));
                            if (tempBool)
                            {
                                cw.addUser("squelch", e.To);    //Re-add user at old index with new name
                            }
                            else
                            {
                                cw.addUser(tempString, e.To);    //Re-add user at old index with new name
                            }
                        }
                    }
                }
                else if (e.Mode.Contains("b"))
                {
                    cw.AddToChatWindow(3, e.To, " was unbanned by " + e.From + ".");
                }
            }
        }
Beispiel #2
0
 private void Fire_ChannelModeSet(ModeSetEventArgs o)
 {
     op.Post(x => OnChannelModeSet(this, (ModeSetEventArgs)x), o);
 }