Пример #1
0
        /// <summary>
        /// Check if user is approved to do operation requested
        /// </summary>
        /// <param name="User">Username</param>
        /// <param name="Host">Hostname</param>
        /// <param name="command">Approved for specified object / request</param>
        /// <returns></returns>
        public bool IsApproved(string User, string Host, string command)
        {
            core.SystemUser current = getUser(User + "!@" + Host);
            if (current.level == "null")
            {
                return(false);
            }
            switch (command)
            {
            case "alias_key":
            case "delete_key":
            case "trust":
            case "info":
            case "trustadd":
            case "trustdel":
            case "recentchanges":
                return(matchLevel(1, current.level));

            case "admin":
            case "infobot-manage":
            case "recentchanges-manage":
            case "shutdown":
                return(matchLevel(2, current.level));

            case "flushcache":
                return(matchLevel(200, current.level));

            case "reconnect":
                return(matchLevel(800, current.level));

            case "root":
                return(matchLevel(65535, current.level));
            }
            return(false);
        }
Пример #2
0
 /// <summary>
 /// Delete user
 /// </summary>
 /// <param name="origin"></param>
 /// <param name="user">Regex</param>
 /// <returns></returns>
 public bool delUser(core.SystemUser origin, string user)
 {
     config.channel channel = core.getChannel(ChannelName);
     if (channel == null)
     {
         core.irc._SlowQueue.DeliverMessage("Error: unable to get pointer of current channel", ChannelName);
         return(false);
     }
     foreach (core.SystemUser u in Users)
     {
         if (u.name == user)
         {
             if (getLevel(u.level) > getLevel(origin.level))
             {
                 core.irc._SlowQueue.DeliverMessage(messages.get("Trust1", channel.Language), ChannelName);
                 return(true);
             }
             if (u.name == origin.name)
             {
                 core.irc._SlowQueue.DeliverMessage(messages.get("Trust2", channel.Language), ChannelName);
                 return(true);
             }
             Users.Remove(u);
             Save();
             core.irc._SlowQueue.DeliverMessage(messages.get("Trust3", channel.Language), ChannelName);
             return(true);
         }
     }
     core.irc._SlowQueue.DeliverMessage(messages.get("Trust4", channel.Language), ChannelName);
     return(true);
 }
Пример #3
0
 /// <summary>
 /// Load all global users of bot
 /// </summary>
 private static void GlobalLoad()
 {
     string[] dba = System.IO.File.ReadAllLines(variables.config + System.IO.Path.DirectorySeparatorChar + "admins");
     lock (GlobalUsers)
     {
         GlobalUsers.Clear();
         foreach (string x in dba)
         {
             if (x.Contains(config.Separator))
             {
                 string[]        info  = x.Split(Char.Parse(config.Separator));
                 string          level = info[1];
                 string          name  = core.decode2(info[0]);
                 core.SystemUser user  = new core.SystemUser(level, name);
                 if (info.Length > 3)
                 {
                     user.UserName = info[3];
                     user.Password = info[2];
                 }
                 GlobalUsers.Add(user);
                 core.DebugLog("Registered global user (" + level + "): " + name, 2);
             }
         }
     }
 }
Пример #4
0
        /// <summary>
        /// Return user object from a name
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public core.SystemUser getUser(string user)
        {
            core.SystemUser lv      = new core.SystemUser("null", "");
            int             current = 0;

            lock (GlobalUsers)
            {
                foreach (core.SystemUser b in GlobalUsers)
                {
                    core.RegexCheck id = new core.RegexCheck(b.name, user);
                    if (id.IsMatch() == 1)
                    {
                        if (getLevel(b.level) > current)
                        {
                            current = getLevel(b.level);
                            lv      = b;
                        }
                    }
                }
            }
            lock (Users)
            {
                foreach (core.SystemUser b in Users)
                {
                    core.RegexCheck id = new core.RegexCheck(b.name, user);
                    if (id.IsMatch() == 1)
                    {
                        if (getLevel(b.level) > current)
                        {
                            current = getLevel(b.level);
                            lv      = b;
                        }
                    }
                }
            }
            return(lv);
        }
Пример #5
0
 private static void GlobalLoad()
 {
     string[] dba = System.IO.File.ReadAllLines(variables.config + System.IO.Path.DirectorySeparatorChar + "admins");
     lock (GlobalUsers)
     {
         GlobalUsers.Clear();
         foreach (string x in dba)
         {
             if (x.Contains(config.separator))
             {
                 string[] info = x.Split(Char.Parse(config.separator));
                 string level = info[1];
                 string name = core.decode2(info[0]);
                 core.SystemUser user = new core.SystemUser(level, name);
                 if (info.Length > 3)
                 {
                     user.UserName = info[3];
                     user.Password = info[2];
                 }
                 GlobalUsers.Add(user);
                 core.DebugLog("Registered global user (" + level + "): " + name, 2);
             }
         }
     }
 }
Пример #6
0
 /// <summary>
 /// Return user object from a name
 /// </summary>
 /// <param name="user"></param>
 /// <returns></returns>
 public core.SystemUser getUser(string user)
 {
     core.SystemUser lv = new core.SystemUser("null", "");
     int current = 0;
     lock (GlobalUsers)
     {
         foreach (core.SystemUser b in GlobalUsers)
         {
             core.RegexCheck id = new core.RegexCheck(b.name, user);
             if (id.IsMatch() == 1)
             {
                 if (getLevel(b.level) > current)
                 {
                     current = getLevel(b.level);
                     lv = b;
                 }
             }
         }
     }
     lock (Users)
     {
         foreach (core.SystemUser b in Users)
         {
             core.RegexCheck id = new core.RegexCheck(b.name, user);
             if (id.IsMatch() == 1)
             {
                 if (getLevel(b.level) > current)
                 {
                     current = getLevel(b.level);
                     lv = b;
                 }
             }
         }
     }
     return lv;
 }