Ejemplo n.º 1
0
 public MuteListEntry(MuteListEntry src)
 {
     MuteName = src.MuteName;
     MuteID   = src.MuteID;
     Type     = src.Type;
     Flags    = src.Flags;
 }
Ejemplo n.º 2
0
 public MuteEntry(UUID ID, MuteFlags Flags, string Name, MuteType Type)
 {
     this.ID    = ID;
     this.Flags = Flags;
     this.Name  = Name;
     this.Type  = Type;
 }
Ejemplo n.º 3
0
 public static bool AddMute(MuteFlags flags, UUID uuid, string name, MuteType type)
 {
     return(!uuid.Equals(UUID.Zero) && !string.IsNullOrEmpty(name) && AddMute(new MuteEntry
     {
         Flags = flags,
         ID = uuid,
         Name = name,
         Type = type
     }));
 }
Ejemplo n.º 4
0
        public static bool RemoveMute(MuteFlags flags, UUID muteUUID, string name, MuteType type)
        {
            MuteEntry mute;

            lock (MuteCacheLock)
            {
                mute = ObservableMuteCache[new MuteEntry
                                           {
                                               ID = muteUUID,
                                               Flags = flags,
                                               Name = name,
                                               Type = type
                                           }];
            }
            if (mute.Equals(default(MuteEntry)))
            {
                return(false);
            }
            lock (MuteCacheLock)
            {
                return(ObservableMuteCache.Remove(mute));
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Mute an object, resident, etc.
        /// </summary>
        /// <param name="type">Mute type</param>
        /// <param name="id">Mute UUID</param>
        /// <param name="name">Mute name</param>
        /// <param name="flags">Mute flags</param>
        public void UpdateMuteListEntry(MuteType type, UUID id, string name, MuteFlags flags)
        {
            UpdateMuteListEntryPacket p = new UpdateMuteListEntryPacket();
            p.AgentData.AgentID = Client.Self.AgentID;
            p.AgentData.SessionID = Client.Self.SessionID;

            p.MuteData.MuteType = (int)type;
            p.MuteData.MuteID = id;
            p.MuteData.MuteName = Utils.StringToBytes(name);
            p.MuteData.MuteFlags = (uint)flags;

            Client.Network.SendPacket(p);

            MuteEntry me = new MuteEntry();
            me.Type = type;
            me.ID = id;
            me.Name = name;
            me.Flags = flags;
            lock (MuteList.Dictionary)
            {
                MuteList[string.Format("{0}|{1}", me.ID, me.Name)] = me;
            }
            OnMuteListUpdated(EventArgs.Empty);
        }
Ejemplo n.º 6
0
        public override CmdResult ExecuteRequest(CmdRequest pargs)
        {
            string verb = pargs.CmdName;

            string[] args = pargs.tokens;
            var      chat = TheBotClient.Self;
            string   arg1 = "show";

            if (args.Length > 0)
            {
                arg1 = args[0].ToLower();
            }

            var cmld = chat.MuteList.Copy();

            if (arg1 == "show" || arg1 == "list" || arg1 == "request")
            {
                if (arg1 == "request")
                {
                    chat.RequestMuteList();
                }
                int nfound = 0;
                foreach (var mm in cmld)
                {
                    AddSuccess("Mutelist Item: " + mm.Key + " is " + Helpers.StructToString(mm.Value));
                    nfound++;
                }
                return(Success(verb + " found: " + nfound + " object/agent(s)"));
            }

            lock (cmld)
            {
                cmld.Clear();
            }
            bool unmute = verb.ToLower().StartsWith("u");

            if (arg1 == "all")
            {
                if (unmute)
                {
                    int nfound = 0;

                    foreach (var mm in cmld)
                    {
                        MuteEntry me = mm.Value;
                        chat.UpdateMuteListEntry(me.Type, me.ID, me.Name, MuteFlags.All);
                        chat.RemoveMuteListEntry(me.ID, me.Name);
                        AddSuccess("Unmuted " + Helpers.StructToString(me) + ".");
                        nfound++;
                    }
                    chat.RequestMuteList();
                    return(Success(verb + " found: " + nfound + " object/agent(s)"));
                }
                if (args.Length == 1)
                {
                    args = new[] { "dist", "30" }
                }
                ;
            }

            object    value;
            MuteFlags mf = MuteFlags.All;
            int       argsUsed;

            if (TryEnumParse(typeof(MuteFlags), args, 0, out argsUsed, out value))
            {
                mf = (MuteFlags)value;
            }
            if (!unmute)
            {
                // invert the flags
                mf = (MuteFlags)((int)MuteFlags.All - (int)mf);
            }
            // if flags found
            if (argsUsed > 0)
            {
                args = Parser.SplitOff(args, argsUsed);
            }
            string           muteName = ((MuteFlags)((int)MuteFlags.All - (int)mf)).ToString();
            List <SimObject> PS       = WorldSystem.GetPrimitives(args, out argsUsed);

            if (!IsEmpty(PS))
            {
                int nfound = 0;
                foreach (var prim in PS)
                {
                    UUID     id = prim.ID;
                    MuteType mt = MuteType.Object;
                    if (prim is SimAvatar)
                    {
                        mt = MuteType.Resident;
                    }
                    if (mf == MuteFlags.All)
                    {
                        chat.RemoveMuteListEntry(id, null);
                    }
                    else
                    {
                        chat.UpdateMuteListEntry(mt, id, null, mf);
                    }

                    nfound++;
                    AddSuccess(verb + " " + muteName + " " + prim + " " + id + ".");
                }
                if (nfound > 0)
                {
                    chat.RequestMuteList();
                    return(Success(verb + " " + muteName + ": " + nfound + " object/agent(s)"));
                }
            }
            return(Failure("I don't know who " + pargs.str + " is."));
        }
    }