コード例 #1
0
ファイル: Channel.cs プロジェクト: Pyratron/PyraChat
 public int AddMode(Client client, string channel, char mode, string parameter = "")
 {
     switch (mode)
     {
         case 'v':
         {
             var user = client.UserFromNick(parameter);
             user.AddRank(client, channel, UserRank.Voice);
             return 1;
         }
         case 'h':
         {
             var user = client.UserFromNick(parameter);
             user.AddRank(client, channel, UserRank.HalfOp);
             return 1;
         }
         case 'o':
         {
             var user = client.UserFromNick(parameter);
             user.AddRank(client, channel, UserRank.Op);
             return 1;
         }
         case 'a':
         {
             var user = client.UserFromNick(parameter);
             user.AddRank(client, channel, UserRank.Admin);
             return 1;
         }
         case 'q':
         {
             var user = client.UserFromNick(parameter);
             user.AddRank(client, channel, UserRank.Owner);
             return 1;
         }
         case 'b':
         {
             AddBan(parameter);
                 OnModeAdd(mode);
                 return 1;
         }
         case 'e':
         {
             AddException(parameter);
                 OnModeAdd(mode);
                 return 1;
         }
         case 'I':
         {
             AddInvite(parameter);
                 OnModeAdd(mode);
                 return 1;
         }
         case 'k':
         {
             Key = parameter;
             Modes.Add(mode);
             return 1;
         }
         case 'l':
         {
             int limit;
             if (int.TryParse(parameter, out limit))
             {
                 Userlimit = limit;
                 Modes.Add(mode);
                     OnModeAdd(mode);
                     return 1;
             }
             break;
         }
         default:
         {
             if (!Modes.Contains(mode))
                 Modes.Add(mode);
             break;
         }
     }
     OnModeAdd(mode);
     return 0;
 }
コード例 #2
0
ファイル: Channel.cs プロジェクト: pro-to-tip/PyraChat
        public int RemoveMode(Client client, string channel, char mode, string parameter = "")
        {
            switch (mode)
            {
            case 'v':
            {
                var user = client.UserFromNick(parameter);
                user.RemoveRank(client, channel, UserRank.Voice);
                return(1);
            }

            case 'h':
            {
                var user = client.UserFromNick(parameter);
                user.RemoveRank(client, channel, UserRank.HalfOp);
                return(1);
            }

            case 'o':
            {
                var user = client.UserFromNick(parameter);
                user.RemoveRank(client, channel, UserRank.Op);
                return(1);
            }

            case 'a':
            {
                var user = client.UserFromNick(parameter);
                user.RemoveRank(client, channel, UserRank.Admin);
                return(1);
            }

            case 'q':
            {
                var user = client.UserFromNick(parameter);
                user.RemoveRank(client, channel, UserRank.Owner);
                return(1);
            }

            case 'b':
            {
                RemoveBan(parameter);
                OnModeRemove(mode);
                return(1);
            }

            case 'e':
            {
                RemoveException(parameter);
                OnModeRemove(mode);
                return(1);
            }

            case 'I':
            {
                RemoveInvite(parameter);
                OnModeRemove(mode);
                return(1);
            }

            case 'k':
            {
                if (Key.Equals(parameter))
                {
                    Key = null;
                    if (Modes.Contains(mode))
                    {
                        Modes.Remove(mode);
                    }
                }
                OnModeRemove(mode);
                return(1);
            }

            case 'l':
            {
                Userlimit = -1;
                if (Modes.Contains(mode))
                {
                    Modes.Remove(mode);
                }
                break;
            }

            default:
            {
                if (Modes.Contains(mode))
                {
                    Modes.Remove(mode);
                }
                break;
            }
            }
            OnModeRemove(mode);
            return(0);
        }
コード例 #3
0
ファイル: Channel.cs プロジェクト: Pyratron/PyraChat
 public int RemoveMode(Client client, string channel, char mode, string parameter = "")
 {
     switch (mode)
     {
         case 'v':
         {
             var user = client.UserFromNick(parameter);
             user.RemoveRank(client, channel, UserRank.Voice);
             return 1;
         }
         case 'h':
         {
             var user = client.UserFromNick(parameter);
             user.RemoveRank(client, channel, UserRank.HalfOp);
             return 1;
         }
         case 'o':
         {
             var user = client.UserFromNick(parameter);
             user.RemoveRank(client, channel, UserRank.Op);
             return 1;
         }
         case 'a':
         {
             var user = client.UserFromNick(parameter);
             user.RemoveRank(client, channel, UserRank.Admin);
             return 1;
         }
         case 'q':
         {
             var user = client.UserFromNick(parameter);
             user.RemoveRank(client, channel, UserRank.Owner);
             return 1;
         }
         case 'b':
         {
             RemoveBan(parameter);
             OnModeRemove(mode);
             return 1;
         }
         case 'e':
         {
             RemoveException(parameter);
             OnModeRemove(mode);
             return 1;
         }
         case 'I':
         {
             RemoveInvite(parameter);
             OnModeRemove(mode);
             return 1;
         }
         case 'k':
         {
             if (Key.Equals(parameter))
             {
                 Key = null;
                 if (Modes.Contains(mode))
                     Modes.Remove(mode);
             }
             OnModeRemove(mode);
             return 1;
         }
         case 'l':
         {
             Userlimit = -1;
             if (Modes.Contains(mode))
                 Modes.Remove(mode);
             break;
         }
         default:
         {
             if (Modes.Contains(mode))
                 Modes.Remove(mode);
             break;
         }
     }
     OnModeRemove(mode);
     return 0;
 }
コード例 #4
0
ファイル: Channel.cs プロジェクト: pro-to-tip/PyraChat
        public int AddMode(Client client, string channel, char mode, string parameter = "")
        {
            switch (mode)
            {
            case 'v':
            {
                var user = client.UserFromNick(parameter);
                user.AddRank(client, channel, UserRank.Voice);
                return(1);
            }

            case 'h':
            {
                var user = client.UserFromNick(parameter);
                user.AddRank(client, channel, UserRank.HalfOp);
                return(1);
            }

            case 'o':
            {
                var user = client.UserFromNick(parameter);
                user.AddRank(client, channel, UserRank.Op);
                return(1);
            }

            case 'a':
            {
                var user = client.UserFromNick(parameter);
                user.AddRank(client, channel, UserRank.Admin);
                return(1);
            }

            case 'q':
            {
                var user = client.UserFromNick(parameter);
                user.AddRank(client, channel, UserRank.Owner);
                return(1);
            }

            case 'b':
            {
                AddBan(parameter);
                OnModeAdd(mode);
                return(1);
            }

            case 'e':
            {
                AddException(parameter);
                OnModeAdd(mode);
                return(1);
            }

            case 'I':
            {
                AddInvite(parameter);
                OnModeAdd(mode);
                return(1);
            }

            case 'k':
            {
                Key = parameter;
                Modes.Add(mode);
                return(1);
            }

            case 'l':
            {
                int limit;
                if (int.TryParse(parameter, out limit))
                {
                    Userlimit = limit;
                    Modes.Add(mode);
                    OnModeAdd(mode);
                    return(1);
                }
                break;
            }

            default:
            {
                if (!Modes.Contains(mode))
                {
                    Modes.Add(mode);
                }
                break;
            }
            }
            OnModeAdd(mode);
            return(0);
        }