Esempio n. 1
0
 protected virtual void OnChatReceived(OpenMetaverse.ChatEventArgs e)
 {
     if (ChatReceived != null)
     {
         ChatReceived(this, e);
     }
 }
Esempio n. 2
0
 static void Self_ChatFromSimulator(object sender, ChatEventArgs e)
 {
     if (e.FromName != _Client.Self.Name && e.Type == ChatType.Normal && e.AudibleLevel == ChatAudibleLevel.Fully)
     {
         string str = "<" + e.FromName + "> " + e.Message;
         _IRC.SendMessage(_AutoJoinChannel, str);
         Console.WriteLine("[SL->IRC] " + str);
     }
 }
        // there is chat coming our way
        void Self_ChatFromSimulator(object sender, OpenMetaverse.ChatEventArgs e)
        {
            m_log.Log(LogLevel.DCOMMDETAIL, "Self_ChatFromSimulator: {0} says '{1}'", e.FromName, e.Message);
            if (e.Message.Length == 0)
            {
                // zero length messages are typing start and end
                return;
            }
            ChatEntry ce = new ChatEntry();

            ce.fromName   = e.FromName;
            ce.message    = e.Message;
            ce.position   = e.Position;
            ce.sourceType = e.SourceType;
            ce.chatType   = e.Type;
            switch (e.Type)
            {
            case OMV.ChatType.Normal:      ce.chatTypeString = "Normal";      break;

            case OMV.ChatType.Shout:       ce.chatTypeString = "Shout";       break;

            case OMV.ChatType.Whisper:     ce.chatTypeString = "Whisper";     break;

            case OMV.ChatType.OwnerSay:    ce.chatTypeString = "OwnerSay";    break;

            case OMV.ChatType.RegionSay:   ce.chatTypeString = "RegionSay";   break;

            case OMV.ChatType.Debug:       ce.chatTypeString = "Debug";       break;

            case OMV.ChatType.StartTyping: ce.chatTypeString = "StartTyping"; break;

            case OMV.ChatType.StopTyping:  ce.chatTypeString = "StopTyping";  break;

            default:                       ce.chatTypeString = "Normal";      break;
            }
            ce.ownerID       = e.OwnerID;
            ce.chatEntryType = ChatEntryType.Normal;
            if (e.SourceType == OMV.ChatSourceType.Agent && e.FromName.EndsWith("Linden"))
            {
                ce.chatEntryType = ChatEntryType.LindenChat;
            }
            if (e.SourceType == OMV.ChatSourceType.Object)
            {
                if (e.Type == OMV.ChatType.OwnerSay)
                {
                    ce.chatEntryType = ChatEntryType.OwnerSay;
                }
                else
                {
                    ce.chatEntryType = ChatEntryType.ObjectChat;
                }
            }
            lock (m_chats) m_chats.Enqueue(ce);
        }
Esempio n. 4
0
        public void OnChatFromSimulator(object sender, ChatEventArgs e)
        {
            if (e.Message != "\n" && e.Message != " " && e.Message != "")
            {
                string msg = e.Message;
                string name = m_Client.Self.FirstName;
                string target = "mind" + name.ElementAt(name.Length - 1) + "@jlnetbook/smack";

                Console.WriteLine("Incoming Message : " + msg);

                JsonReading jr = new JsonReading();
                string evt = null;

                if (e.FromName.StartsWith(Constant.CONDUCTOR))
                {
                    // Case 1
                    if (msg.Equals("all aboard") == true)
                    {
                        SetDestination(e.Position); evt = "ready";
                    }
                    else
                    {
                        evt = msg;
                    }
                }
                else if (e.FromName.StartsWith(Constant.DISABLED))
                {
                    // Perceive as if it recognises disabled people
                    if (msg.Contains("space") == true)
                    {
                        evt = "detect(disabled)";
                    }
                }

                if (evt != null)
                {
                    jr.AddValue("EVENT", evt);
                    m_Sensor.Publish(jr);
                }
                else
                {
                    // no-op
                    Debug.WriteLine("No data published in Chat Message Handler!");
                }
            }
        }
Esempio n. 5
0
 private void Self_OnChat(object sender, OpenMetaverse.ChatEventArgs ea)
 {
     try
     {
         if (netcomSync != null)
         {
             netcomSync.BeginInvoke(new OnChatRaise(OnChatReceived), new object[] { ea });
         }
         else
         {
             OnChatReceived(ea);
         }
     }
     catch
     {
         ;
     }
 }
Esempio n. 6
0
 public RLVRule(ChatEventArgs e)
 {
     if (e.SourceID != null)
     {
         Match reg = rlv_regex.Match(e.Message);
         if (reg.Success)
         {
             Behaviour = reg.Groups["behaviour"].ToString().ToLower();
             Option = reg.Groups["option"].ToString().ToLower();
             Param = reg.Groups["param"].ToString().ToLower();
             if (Param == "rem") Param = "y";
             if (Param == "add") Param = "n";
             Source = e.SourceID;
             SourceName = e.FromName;
         }
         else throw new ArgumentException("Invalid rlv rule : " + e.Message);
     }
     else throw new ArgumentException("source uuid may not be null.");
 }
Esempio n. 7
0
        void Self_ChatFromSimulator(object sender, ChatEventArgs e)
        {
            // Boilerplate, make sure to be on the GUI thread
            if (InvokeRequired)
            {
                BeginInvoke(new MethodInvoker(() => Self_ChatFromSimulator(sender, e)));
                return;
            }

            //txtChat.Text = e.Message;
        }
Esempio n. 8
0
        public bool TryProcessCMD(ChatEventArgs e)
        {
            if (!Enabled || !e.Message.StartsWith("@")) return false;

            foreach (string cmd in e.Message.Substring(1).Split(','))
            {
                RLVRule rule = new RLVRule(e);

                switch (rule.Behaviour)
                {
                    case "version":
                        int chan = 0;
                        if (int.TryParse(rule.Param, out chan) && chan > 0)
                        {
                            Respond(chan, "RestrainedLife viewer v1.23 (SteelCity Automaton - Alpha)");
                        }
                        break;

                    case "versionnew":
                        chan = 0;
                        if (int.TryParse(rule.Param, out chan) && chan > 0)
                        {
                            Respond(chan, "RestrainedLove viewer v1.23 (SteelCity Automaton - Alpha)");
                        }
                        break;

                    case "versionnum":
                        if (int.TryParse(rule.Param, out chan) && chan > 0)
                        {
                            Respond(chan, "1230100");
                        }
                        break;

                    case "getgroup":
                        if (int.TryParse(rule.Param, out chan) && chan > 0)
                        {
                            UUID gid = Client.Self.ActiveGroup;
                            if (Am.Groups().ContainsKey(gid))
                            {
                                Respond(chan, Am.Groups()[gid].Name);
                            }
                        }
                        break;

                    case "setgroup":
                        {
                            if (rule.Param == "force")
                            {
                                Am.set_group(rule.Option);
                            }
                        }
                        break;

                    //TODO MORE

                    case "getinv":
                        if (int.TryParse(rule.Param, out chan) && chan > 0)
                        {
                            string res = string.Empty;
                            InventoryNode folder = FindFolder(rule.Option);
                            if (folder != null)
                            {
                                foreach (var f in folder.Nodes.Values)
                                {
                                    if (f.Data is InventoryFolder && !f.Data.Name.StartsWith("."))
                                    {
                                        res += f.Data.Name + ",";
                                    }
                                }
                            }

                            Respond(chan, res.TrimEnd(','));
                        }
                        break;

                    default:
                        Console.WriteLine("Invalid rlv behaviour:");
                        Console.WriteLine(rule.ToString());
                        break;
                }
            }
            return true;
        }
Esempio n. 9
0
        void Self_ChatFromSimulator(object sender, ChatEventArgs e)
        {
            if (currentSource == null || currentSource.SourceType != RelaySourceType.Chat)
                return;

            if (e.SourceID == client.Self.AgentID)
            {
                if (e.Message.StartsWith("(irc:"))
                    return;
            }

            if (e.Type == ChatType.Normal || e.Type == ChatType.Shout || e.Type == ChatType.Whisper)
                ProcessMessage(e.Message, e.FromName);
        }
Esempio n. 10
0
        public bool TryProcessCMD(ChatEventArgs e)
        {
            if (!Enabled || !e.Message.StartsWith("@")) return false;

            if (e.Message == "@clear")
            {
                Clear(e.SourceID);
                return true;
            }

            foreach (var cmd in e.Message.Substring(1).Split(','))
            {
                var m = rlv_regex.Match(cmd);
                if (!m.Success) continue;

                var rule = new RLVRule();
                rule.Behaviour = m.Groups["behaviour"].ToString().ToLower(); ;
                rule.Option = m.Groups["option"].ToString().ToLower();
                rule.Param = m.Groups["param"].ToString().ToLower();
                rule.Sender = e.SourceID;
                rule.SenderName = e.FromName;

                Logger.DebugLog(rule.ToString());

                if (rule.Param == "rem") rule.Param = "y";
                if (rule.Param == "add") rule.Param = "n";

                if (rule.Param == "n")
                {
                    lock (rules) rules.Add(rule);
                    OnRLVRuleChanged(new RLVEventArgs(rule));
                    continue;
                }

                if (rule.Param == "y")
                {
                    lock (rules)
                    {
                        if (rule.Option == "")
                        {
                            rules.RemoveAll((RLVRule r) =>
                                {
                                    return r.Behaviour == rule.Behaviour && r.Sender == rule.Sender;
                                });
                        }
                        else
                        {
                            rules.RemoveAll((RLVRule r) =>
                            {
                                return r.Behaviour == rule.Behaviour && r.Sender == rule.Sender && r.Option == rule.Option;
                            });
                        }
                    }

                    OnRLVRuleChanged(new RLVEventArgs(rule));
                    continue;
                }

                switch (rule.Behaviour)
                {
                    case "version":
                        int chan = 0;
                        if (int.TryParse(rule.Param, out chan) && chan > 0)
                        {
                            instance.Client.Self.Chat("RestrainedLife viewer v1.20c (" + Properties.Resources.RadegastTitle + "." + RadegastBuild.CurrentRev + ")", chan, ChatType.Normal);
                        }
                        break;

                    case "versionnum":
                        if (int.TryParse(rule.Param, out chan) && chan > 0)
                        {
                            instance.Client.Self.Chat("1210100", chan, ChatType.Normal);
                        }
                        break;

                    case "sit":
                        UUID sitTarget = UUID.Zero;

                        if (rule.Param == "force" && UUID.TryParse(rule.Option, out sitTarget) && sitTarget != UUID.Zero)
                        {
                            instance.State.SetSitting(true, sitTarget);
                        }
                        break;

                    case "unsit":
                        if (rule.Param == "force")
                        {
                            instance.State.SetSitting(false, UUID.Zero);
                        }
                        break;

                    case "setrot":
                        double rot = 0.0;

                        if (rule.Param == "force" && double.TryParse(rule.Option, System.Globalization.NumberStyles.Float, Utils.EnUsCulture, out rot))
                        {
                            instance.Client.Self.Movement.UpdateFromHeading(Math.PI / 2d - rot, true);
                        }
                        break;

                    case "tpto":
                        var coord = rule.Option.Split('/');

                        try
                        {
                            float gx = float.Parse(coord[0], Utils.EnUsCulture);
                            float gy = float.Parse(coord[1], Utils.EnUsCulture);
                            float z = float.Parse(coord[2], Utils.EnUsCulture);
                            float x = 0, y = 0;

                            instance.TabConsole.DisplayNotificationInChat("Starting teleport...");
                            ulong h = Helpers.GlobalPosToRegionHandle(gx, gy, out x, out y);
                            instance.Client.Self.RequestTeleport(h, new Vector3(x, y, z));
                        }
                        catch (Exception) { }

                        break;

                }
            }

            return true;
        }
Esempio n. 11
0
        void Self_OnChat(object sender, ChatEventArgs e)
        {
            InstantMessageDialog Dialog = InstantMessageDialog.MessageFromAgent;
            switch (e.SourceType)
            {
                case ChatSourceType.System:
                    break;
                case ChatSourceType.Agent:
                    break;
                case ChatSourceType.Object:
                    Dialog = InstantMessageDialog.MessageFromObject;
                    break;
            }
            UUID regionID = UUID.Zero;
            if (e.Simulator != null)
            {
                regionID = e.Simulator.RegionID;
            }
            Self_OnMessage(e.FromName, e.SourceID, e.OwnerID,
                           e.Message, UUID.Zero, false,
                           regionID, e.Position,
                           Dialog, e.Type, e);
            ;

        }
Esempio n. 12
0
 protected virtual void OnChatReceived(ChatEventArgs e)
 {
     if (ChatReceived != null) ChatReceived(this, e);
 }
Esempio n. 13
0
 void netcom_ChatReceived(object sender, ChatEventArgs e)
 {
     //somehow it can be too early (when Radegast is loaded from running bot)
     if (instance.GlobalSettings==null) return;
     if (!instance.GlobalSettings["disable_look_at"]
         && e.SourceID != client.Self.AgentID
         && (e.SourceType == ChatSourceType.Agent || e.Type == ChatType.StartTyping))
     {
         // change focus max every 4 seconds
         if (Environment.TickCount - lastLookAtEffect > 4000)
         {
             lastLookAtEffect = Environment.TickCount;
             client.Self.LookAtEffect(client.Self.AgentID, e.SourceID, Vector3d.Zero, LookAtType.Respond, lookAtEffect);
             // keep looking at the speaker for 10 seconds
             if (lookAtTimer != null)
             {
                 lookAtTimer.Change(10000, Timeout.Infinite);
             }
         }
     }
 }
Esempio n. 14
0
 void netcom_ChatReceived(object sender, ChatEventArgs e)
 {
     if (e.SourceID != client.Self.AgentID && (e.SourceType == ChatSourceType.Agent || e.Type == ChatType.StartTyping))
     {
         // change focus max every 4 seconds
         if (Environment.TickCount - lastLookAtEffect > 4000)
         {
             lastLookAtEffect = Environment.TickCount;
             client.Self.LookAtEffect(client.Self.AgentID, e.SourceID, Vector3d.Zero, LookAtType.Respond, lookAtEffect);
             // keep looking at the speaker for 10 seconds
             if (lookAtTimer != null)
             {
                 lookAtTimer.Change(10000, Timeout.Infinite);
             }
         }
     }
 }
Esempio n. 15
0
 void Self_ChatFromSimulator(object sender, ChatEventArgs e)
 {
     string head;
     ConsoleColor col;
     switch(e.Type)
     {
         case ChatType.OwnerSay:
                 head = "OWNER";
                 if (e.Message[0] == '@')
                 {
                     //if(RLV(e))return;
                 }
                 else if(e.Message[0] == '#')
                 {
                     if(e.Message.Length > 1)
                     {
                         string msg = e.Message.Substring(1);
                         JObject json;
                         try
                         {
                             json = JObject.Parse(msg);
                         }
                         catch (Exception er)
                         {
     #if DEBUG
                             Console.WriteLine("[JSON]:{0}:{1}", er.Message, er.StackTrace);
     #endif
                             return;
                         }
                         string resp = processCommands(json);
                         int chan = 0;
                         if (!int.TryParse((string)json["channel"], out chan)) chan = 175971596;
                         Client.Self.Chat(resp, chan, ChatType.Normal);
                         return;
                     }
                 }
                 col = ConsoleColor.Yellow;
             break;
         case ChatType.Normal:
                 head = " CHAT";
                 col = ConsoleColor.Green;
             break;
         case ChatType.Whisper:
                 head = "QUIET";
                 col = ConsoleColor.Yellow;
             break;
         case ChatType.Shout:
                 head = "SHOUT";
                 col = ConsoleColor.Yellow;
             break;
         case ChatType.StartTyping:
         case ChatType.StopTyping:
             return;
         default:
                 head = "DEF";
                 col = ConsoleColor.Gray;
             break;
     }
     /*
     #if DEBUG
     string txt = String.Format("[{0}]{1}:{2}", head, e.FromName, e.Message);
     Console.ForegroundColor = ConsoleColor.White;
     Console.Write("[");
     Console.ForegroundColor = col;
     Console.Write(head);
     Console.ForegroundColor = ConsoleColor.White;
     Console.Write("]");
     Console.ForegroundColor = ConsoleColor.Gray;
     Console.Write(e.FromName);
     Console.ForegroundColor = ConsoleColor.White;
     Console.Write(":");
     Console.ForegroundColor = ConsoleColor.Gray;
     Console.Write(e.Message);
     Console.ResetColor();
     Console.WriteLine("");
     #endif
     */
     ++total_chat;
     ChatLog.Add(new Chat(e, ChatLog.Count));
     httpCallback(CallBackEvent.chat, e.SourceID.ToString(), ChatLog.Last());
 }
Esempio n. 16
0
 public Chat(ChatEventArgs e,int _id)
 {
     id = _id;
     source = e.SourceType.ToString();
     message = e.Message;
     from_id = e.SourceID.ToString();
     from_name = e.FromName;
     timestamp = Helper.unixTimeStamp();
 }
Esempio n. 17
0
 void Self_ChatFromSimulator(object sender, ChatEventArgs e)
 {
     if (e.Message.Length > 0 && (Client.MasterKey == e.SourceID || (Client.MasterName == e.FromName && !Client.AllowObjectMaster)))
         Client.Self.Chat(e.Message, 0, ChatType.Normal);
 }		
Esempio n. 18
0
 public void Self_ChatFromSimulator(object sender, ChatEventArgs e)
 {
     Hashtable item = new Hashtable();
     item.Add("MessageType", "SpatialChat");
     item.Add("Message", e.Message);
     item.Add("Audible", e.AudibleLevel);
     item.Add("Type", e.Type);
     item.Add("SourceType", e.SourceType);
     item.Add("FromName", e.FromName);
     item.Add("ID", e.SourceID);
     item.Add("OwnerID", e.OwnerID);
     item.Add("Position", e.Position);
     enqueue(item);
 }
 public void OnLocalChat(object o, OpenMetaverse.ChatEventArgs e)
 {
     throw new NotImplementedException();
 }
Esempio n. 20
0
 // CALLBACKS
 // These are all assigned to LibSL callbacks in Connect.cs. This determines their argument order.
 // The if(!active) check is to ensure they don't get called after we've logged off. This is a
 // LibSL bug.
 // These almost all perform the same task:
 // 1) Create a hashtable
 // 2) Place various passed-in arguments in the hashtable
 // 3) Optionally, loop through one of the arguments if necessary, and add this to the hashtable
 //    as a bunch more hashtables.
 // 4) Enqueue the hashtable in the message queue. This is periodically emptied by the client.
 // ***********************************************************************************************
 public void Self_ChatFromSimulator(object sender, ChatEventArgs e)
 {
     if (e.Message.Length <= 0) return;
     Hashtable item = new Hashtable();
     item.Add("MT", "chat");
     item.Add("msg", e.Message);
     //item.Add("Audible", e.AudibleLevel);
     //item.Add("type", e.Type);
     item.Add("tipo", e.SourceType);
     item.Add("from", e.FromName);
     //item.Add("id", e.SourceID);
     //item.Add("owner", e.OwnerID);
     //item.Add("Position", e.Position);
     enqueue(item);
 }
Esempio n. 21
0
 private void Self_ChatFromSimulator(object sender, ChatEventArgs e)
 {
     if (CanSyncInvoke)
         netcomSync.BeginInvoke(new OnChatRaise(OnChatReceived), new object[] { e });
     else
         OnChatReceived(e);
 }
Esempio n. 22
0
 void Self_ChatFromSimulator(object sender, ChatEventArgs e)
 {
     if (e.Type == ChatType.StartTyping)
     {
         new BufferSound(
             UUID.Random(),
             UISounds.Typing,
             false,
             true,
             e.Position,
             ObjectVolume / 2f);
     }
 }
Esempio n. 23
0
        void HandleClientSelfChatFromSimulator(object sender, ChatEventArgs e)
        {

        }
Esempio n. 24
0
 private void Self_ChatFromSimulator(object sender, ChatEventArgs e)
 {
     if (e.Message.Length > 0 && (Client.GetSecurityLevel(e.SourceID, e.FromName) & BotPermissions.IsMaster) != 0)
         Client.Self.Chat(e.Message, 0, ChatType.Normal);
 }
Esempio n. 25
0
 private void netcom_ChatReceived(object sender, ChatEventArgs e)
 {
     ProcessIncomingChat(e);
 }
Esempio n. 26
0
 public ControlDialogo(ChatEventArgs _e, int _distancia)
 {
     e = _e;
     distancia = _distancia;
 }
Esempio n. 27
0
 /// <summary>
 /// Handles a chat message received from the server
 /// </summary>
 /// <param name="sender">Client that received the chat</param>
 /// <param name="e">Parameters of the chat message</param>
 private void Self_ChatFromSimulator(object sender, ChatEventArgs e)
 {
     if (e.SourceType == ChatSourceType.Agent && e.Type == ChatType.Normal && e.SourceID != Client.Self.AgentID)
     {
         //Iterate through each action and call its handler in case the received message tries to invoke that action
         //The Message that is sent with the event is the original message without the verb
         foreach (string action in Handlers.Keys)
         {
             if (e.Message.ToLower().StartsWith(action))
             {
                 ChatActionEventArgs args = new ChatActionEventArgs();
                 args.Message = e.Message.Replace(action + " ", "");
                 args.FromName = e.FromName;
                 Handlers[action].Invoke(this, args);
             }
         }
     }
 }
Esempio n. 28
0
        void Self_ChatFromSimulator(object sender, ChatEventArgs e)
        {
            // We ignore everything except normal chat from other avatars
            if (e.SourceType != ChatSourceType.Agent || e.FromName == Client.Self.Name || e.Message.Trim().Length == 0) return;

            bool parseForResponse = Alice.isAcceptingUserInput && Enabled;
            if (parseForResponse && respondRange >= 0)
            {
                parseForResponse = Vector3.Distance(Client.Self.SimPosition, e.Position) <= respondRange;
            }
            if (parseForResponse)
            {
                parseForResponse = respondWithoutName || e.Message.ToLower().Contains(FirstName(Client.Self.Name).ToLower());
            }

            if (parseForResponse)
            {
                ThreadPool.QueueUserWorkItem(sync =>
                {
                    lock (syncChat)
                    {
                        Alice.GlobalSettings.updateSetting("location", "region " + Client.Network.CurrentSim.Name);
                        string msg = e.Message.ToLower();
                        msg = msg.Replace(FirstName(Client.Self.Name).ToLower(), "");
                        AIMLbot.User user;
                        if (AliceUsers.ContainsKey(e.FromName))
                        {
                            user = (AIMLbot.User)AliceUsers[e.FromName];
                        }
                        else
                        {
                            user = new User(e.FromName, Alice);
                            user.Predicates.removeSetting("name");
                            user.Predicates.addSetting("name", FirstName(e.FromName));
                            AliceUsers[e.FromName] = user;
                        }

                        Client.Self.Movement.TurnToward(e.Position);
                        if (EnableRandomDelay) System.Threading.Thread.Sleep(1000 + 1000 * rand.Next(2));
                        if (!Instance.State.IsTyping)
                        {
                            Instance.State.SetTyping(true);
                        }
                        if (EnableRandomDelay)
                        {
                            System.Threading.Thread.Sleep(2000 + 1000 * rand.Next(5));
                        }
                        else
                        {
                            System.Threading.Thread.Sleep(1000);
                        }
                        Instance.State.SetTyping(false);
                        AIMLbot.Request req = new Request(msg, user, Alice);
                        AIMLbot.Result res = Alice.Chat(req);
                        string outp = res.Output;
                        if (outp.Length > 1000)
                        {
                            outp = outp.Substring(0, 1000);
                        }

                        ChatType useChatType = ChatType.Normal;
                        if (shout2shout && e.Type == ChatType.Shout)
                        {
                            useChatType = ChatType.Shout;
                        }
                        else if (whisper2whisper && e.Type == ChatType.Whisper)
                        {
                            useChatType = ChatType.Whisper;
                        }
                        Client.Self.Chat(outp, 0, useChatType);
                    }
                });
            }
        }
Esempio n. 29
0
        public void OnLocalChat(object sender, OpenMetaverse.ChatEventArgs e)
        {
            if (e.Type == ChatType.StartTyping || e.Type == ChatType.StopTyping || e.Type == ChatType.Debug)
            {
                return;
            }

            if (e.SourceID == client.Self.AgentID)
            {
                return;
            }


            System.Diagnostics.Debug.WriteLine("Local chat: <{1}> {0}", e.Message, e.FromName);

            var msg = new IntermediateMessage();

            msg.Payload = e.Message;

            if (e.SourceType == OpenMetaverse.ChatSourceType.Object)
            {
                msg.Sender = mapper.MapObject(e.SourceID, e.FromName);
            }
            else if (e.SourceType == OpenMetaverse.ChatSourceType.Agent)
            {
                msg.Sender = mapper.MapUser(e.SourceID, e.FromName);
            }
            else
            {
                msg.Sender = mapper.Grid;
            }

            msg.Timestamp = DateTime.UtcNow;



            if (e.SourceType == ChatSourceType.System)
            {
                msg.Type   = MessageType.System;
                msg.Sender = mapper.Grid;
            }

            if (e.Type == OpenMetaverse.ChatType.Shout)
            {
                msg.Type = MessageType.Shout;
            }
            else if (e.Type == ChatType.Whisper)
            {
                msg.Type = MessageType.Whisper;
            }
            else if (e.Type == ChatType.RegionSay)
            {
                msg.Type = MessageType.RegionSay;
            }
            else if (e.Type == ChatType.OwnerSay)
            {
                msg.Type = MessageType.OwnerSay;
                if (Rlv(msg.Payload))
                {
                    return;
                }
            }

            SendMessageDownstream(msg);
        }
Esempio n. 30
0
        void Self_ChatFromSimulator(object sender, ChatEventArgs e)
        {
            // We ignore everything except normal chat from other avatars

            if (e.Type != ChatType.Normal || e.SourceType != ChatSourceType.Agent)
            {
                return;
            }

            // See if somone said the magic words
            if (e.Message.ToLower() == "demo plugin version")
            {
                // Turn towards the person who spoke
                Client.Self.Movement.TurnToward(e.Position);

                // Play typing animation for 1 second
                Instance.State.SetTyping(true);
                Thread.Sleep(1000);
                Instance.State.SetTyping(false);

                // Finally send the answer back
                Client.Self.Chat("Hello " + e.FromName + ", glad you asked. My version is " + version + ".", 0, ChatType.Normal);
            }
        }
Esempio n. 31
0
 public virtual void Self_OnChat(object sender, ChatEventArgs e) {OnEvent("On-Chat", paramNamesOnChat, paramTypesOnChat, e);}
Esempio n. 32
0
        private void ProcessIncomingChat(ChatEventArgs e)
        {
            if (string.IsNullOrEmpty(e.Message)) return;

            // Check if the sender agent is muted
            if (e.SourceType == ChatSourceType.Agent &&
                null != client.Self.MuteList.Find(me => me.Type == MuteType.Resident && me.ID == e.SourceID)
                ) return;

            // Check if sender object is muted
            if (e.SourceType == ChatSourceType.Object &&
                null != client.Self.MuteList.Find(me =>
                    (me.Type == MuteType.Resident && me.ID == e.OwnerID) // Owner muted
                    || (me.Type == MuteType.Object && me.ID == e.SourceID) // Object muted by ID
                    || (me.Type == MuteType.ByName && me.Name == e.FromName) // Object muted by name
                )) return;

            if (instance.RLV.Enabled && e.Message.StartsWith("@"))
            {
                instance.RLV.TryProcessCMD(e);
            #if !DEBUG
                return;
            #endif
            }

            ChatBufferItem item = new ChatBufferItem();
            item.ID = e.SourceID;
            item.RawMessage = e;
            StringBuilder sb = new StringBuilder();

            if (e.SourceType == ChatSourceType.Agent)
            {
                item.From = instance.Names.Get(e.SourceID, e.FromName);
            }
            else
            {
                item.From = e.FromName;
            }

            bool isEmote = e.Message.ToLower().StartsWith("/me ");

            if (!isEmote)
            {
                switch (e.Type)
                {

                    case ChatType.Whisper:
                        sb.Append(" whispers");
                        break;

                    case ChatType.Shout:
                        sb.Append(" shouts");
                        break;
                }
            }

            if (isEmote)
            {
                if (e.SourceType == ChatSourceType.Agent && instance.RLV.RestictionActive("recvemote", e.SourceID.ToString()))
                    sb.Append(" ...");
                else
                    sb.Append(e.Message.Substring(3));
            }
            else
            {
                sb.Append(": ");
                if (e.SourceType == ChatSourceType.Agent && !e.Message.StartsWith("/") && instance.RLV.RestictionActive("recvchat", e.SourceID.ToString()))
                    sb.Append("...");
                else
                    sb.Append(e.Message);
            }

            item.Timestamp = DateTime.Now;
            item.Text = sb.ToString();

            switch (e.SourceType)
            {
                case ChatSourceType.Agent:
                    item.Style =
                        (e.FromName.EndsWith("Linden") ?
                        ChatBufferTextStyle.LindenChat : ChatBufferTextStyle.Normal);
                    break;

                case ChatSourceType.Object:
                    if (e.Type == ChatType.OwnerSay)
                    {
                        item.Style = ChatBufferTextStyle.OwnerSay;
                    }
                    else
                    {
                        item.Style = ChatBufferTextStyle.ObjectChat;
                    }
                    break;
            }

            ProcessBufferItem(item, true);
            instance.TabConsole.Tabs["chat"].Highlight();

            sb = null;
        }
Esempio n. 33
0
        public bool TryProcessCMD(ChatEventArgs e)
        {
            if (!Enabled || !e.Message.StartsWith("@")) return false;

            if (e.Message == "@clear")
            {
                Clear(e.SourceID);
                return true;
            }

            foreach (var cmd in e.Message.Substring(1).Split(','))
            {
                var m = rlv_regex.Match(cmd);
                if (!m.Success) continue;

                var rule = new RLVRule();
                rule.Behaviour = m.Groups["behaviour"].ToString().ToLower(); ;
                rule.Option = m.Groups["option"].ToString().ToLower();
                rule.Param = m.Groups["param"].ToString().ToLower();
                rule.Sender = e.SourceID;
                rule.SenderName = e.FromName;

                Logger.DebugLog(rule.ToString());

                if (rule.Param == "rem") rule.Param = "y";
                if (rule.Param == "add") rule.Param = "n";

                if (rule.Param == "n")
                {
                    lock (rules)
                    {
                        var existing = rules.Find(r =>
                            r.Behaviour == rule.Behaviour &&
                            r.Sender == rule.Sender &&
                            r.Option == rule.Option);

                        if (existing != null)
                        {
                            rules.Remove(existing);
                        }
                        rules.Add(rule);
                        OnRLVRuleChanged(new RLVEventArgs(rule));
                    }
                    continue;
                }

                if (rule.Param == "y")
                {
                    lock (rules)
                    {
                        if (rule.Option == "")
                        {
                            rules.RemoveAll((RLVRule r) =>
                                {
                                    return r.Behaviour == rule.Behaviour && r.Sender == rule.Sender;
                                });
                        }
                        else
                        {
                            rules.RemoveAll((RLVRule r) =>
                            {
                                return r.Behaviour == rule.Behaviour && r.Sender == rule.Sender && r.Option == rule.Option;
                            });
                        }
                    }

                    OnRLVRuleChanged(new RLVEventArgs(rule));
                    continue;
                }

                switch (rule.Behaviour)
                {
                    case "version":
                        int chan = 0;
                        if (int.TryParse(rule.Param, out chan) && chan > 0)
                        {
                            Respond(chan, "RestrainedLife viewer v1.23 (" + Properties.Resources.RadegastTitle + "." + RadegastBuild.CurrentRev + ")");
                        }
                        break;

                    case "versionnew":
                        chan = 0;
                        if (int.TryParse(rule.Param, out chan) && chan > 0)
                        {
                            Respond(chan, "RestrainedLove viewer v1.23 (" + Properties.Resources.RadegastTitle + "." + RadegastBuild.CurrentRev + ")");
                        }
                        break;

                    case "versionnum":
                        if (int.TryParse(rule.Param, out chan) && chan > 0)
                        {
                            Respond(chan, "1230100");
                        }
                        break;

                    case "getgroup":
                        if (int.TryParse(rule.Param, out chan) && chan > 0)
                        {
                            UUID gid = client.Self.ActiveGroup;
                            if (instance.Groups.ContainsKey(gid))
                            {
                                Respond(chan, instance.Groups[gid].Name);
                            }
                        }
                        break;

                    case "setgroup":
                        {
                            if (rule.Param == "force")
                            {
                                foreach (var g in instance.Groups.Values)
                                {
                                    if (g.Name.ToLower() == rule.Option)
                                    {
                                        client.Groups.ActivateGroup(g.ID);
                                    }
                                }
                            }
                        }
                        break;

                    case "getsitid":
                        if (int.TryParse(rule.Param, out chan) && chan > 0)
                        {
                            Avatar me;
                            if (client.Network.CurrentSim.ObjectsAvatars.TryGetValue(client.Self.LocalID, out me))
                            {
                                if (me.ParentID != 0)
                                {
                                    Primitive seat;
                                    if (client.Network.CurrentSim.ObjectsPrimitives.TryGetValue(me.ParentID, out seat))
                                    {
                                        Respond(chan, seat.ID.ToString());
                                        break;
                                    }
                                }
                            }
                            Respond(chan, UUID.Zero.ToString());
                        }
                        break;

                    case "getstatusall":
                    case "getstatus":
                        if (int.TryParse(rule.Param, out chan) && chan > 0)
                        {
                            string sep = "/";
                            string filter = "";

                            if (!string.IsNullOrEmpty(rule.Option))
                            {
                                var parts = rule.Option.Split(';');
                                if (parts.Length > 1 && parts[1].Length > 0)
                                {
                                    sep = parts[1].Substring(0, 1);
                                }
                                if (parts.Length > 0 && parts[0].Length > 0)
                                {
                                    filter = parts[0].ToLower();
                                }
                            }

                            lock (rules)
                            {
                                string res = "";
                                rules
                                    .FindAll(r => (rule.Behaviour == "getstatusall" || r.Sender == rule.Sender) && r.Behaviour.Contains(filter))
                                    .ForEach(objRule =>
                                {
                                    res += sep + objRule.Behaviour;
                                    if (!string.IsNullOrEmpty(objRule.Option))
                                    {
                                        res += ":" + objRule.Option;
                                    }
                                });
                                Respond(chan, res);
                            }
                        }
                        break;

                    case "sit":
                        UUID sitTarget = UUID.Zero;

                        if (rule.Param == "force" && UUID.TryParse(rule.Option, out sitTarget) && sitTarget != UUID.Zero)
                        {
                            instance.State.SetSitting(true, sitTarget);
                        }
                        break;

                    case "unsit":
                        if (rule.Param == "force")
                        {
                            instance.State.SetSitting(false, UUID.Zero);
                        }
                        break;

                    case "setrot":
                        double rot = 0.0;

                        if (rule.Param == "force" && double.TryParse(rule.Option, System.Globalization.NumberStyles.Float, Utils.EnUsCulture, out rot))
                        {
                            client.Self.Movement.UpdateFromHeading(Math.PI / 2d - rot, true);
                        }
                        break;

                    case "tpto":
                        var coord = rule.Option.Split('/');

                        try
                        {
                            float gx = float.Parse(coord[0], Utils.EnUsCulture);
                            float gy = float.Parse(coord[1], Utils.EnUsCulture);
                            float z = float.Parse(coord[2], Utils.EnUsCulture);
                            float x = 0, y = 0;

                            instance.TabConsole.DisplayNotificationInChat("Starting teleport...");
                            ulong h = Helpers.GlobalPosToRegionHandle(gx, gy, out x, out y);
                            client.Self.RequestTeleport(h, new Vector3(x, y, z));
                        }
                        catch (Exception) { }

                        break;

                    #region #RLV folder and outfit manipulation
                    case "getoutfit":
                        if (int.TryParse(rule.Param, out chan) && chan > 0)
                        {
                            var wearables = client.Appearance.GetWearables();
                            string res = "";

                            // Do we have a specific wearable to check, ie @getoutfit:socks=99
                            if (!string.IsNullOrEmpty(rule.Option))
                            {
                                if (wearables.ContainsKey(WearableFromString(rule.Option)))
                                {
                                    res = "1";
                                }
                                else
                                {
                                    res = "0";
                                }
                            }
                            else
                            {
                                for (int i = 0; i < RLVWearables.Count; i++)
                                {
                                    if (wearables.ContainsKey(RLVWearables[i].Type))
                                    {
                                        res += "1";
                                    }
                                    else
                                    {
                                        res += "0";
                                    }

                                }
                            }
                            Respond(chan, res);
                        }
                        break;

                    case "getattach":
                        if (int.TryParse(rule.Param, out chan) && chan > 0)
                        {
                            string res = "";
                            var attachments = client.Network.CurrentSim.ObjectsPrimitives.FindAll(p => p.ParentID == client.Self.LocalID);
                            if (attachments.Count > 0)
                            {
                                var myPoints = new List<AttachmentPoint>(attachments.Count);
                                for (int i = 0; i < attachments.Count; i++)
                                {
                                    if (!myPoints.Contains(attachments[i].PrimData.AttachmentPoint))
                                    {
                                        myPoints.Add(attachments[i].PrimData.AttachmentPoint);
                                    }
                                }

                                // Do we want to check one single attachment
                                if (!string.IsNullOrEmpty(rule.Option))
                                {
                                    if (myPoints.Contains(AttachmentPointFromString(rule.Option)))
                                    {
                                        res = "1";
                                    }
                                    else
                                    {
                                        res = "0";
                                    }
                                }
                                else
                                {
                                    for (int i = 0; i < RLVAttachments.Count; i++)
                                    {
                                        if (myPoints.Contains(RLVAttachments[i].Point))
                                        {
                                            res += "1";
                                        }
                                        else
                                        {
                                            res += "0";
                                        }
                                    }
                                }

                            }
                            Respond(chan, res);
                        }
                        break;

                    case "remattach":
                    case "detach":
                        if (rule.Param == "force")
                        {
                            if (!string.IsNullOrEmpty(rule.Option))
                            {
                                var point = RLVAttachments.Find(a => a.Name == rule.Option);
                                if (point.Name == rule.Option)
                                {
                                    var attachment = client.Network.CurrentSim.ObjectsPrimitives.Find(p => p.ParentID == client.Self.LocalID && p.PrimData.AttachmentPoint == point.Point);
                                    if (attachment != null && client.Inventory.Store.Items.ContainsKey(CurrentOutfitFolder.GetAttachmentItem(attachment)))
                                    {
                                        instance.COF.Detach((InventoryItem)client.Inventory.Store.Items[CurrentOutfitFolder.GetAttachmentItem(attachment)].Data);
                                    }
                                }
                                else
                                {
                                    InventoryNode folder = FindFolder(rule.Option);
                                    if (folder != null)
                                    {
                                        var outfit = new List<InventoryItem>();
                                        foreach (var item in folder.Nodes.Values)
                                        {
                                            if (CurrentOutfitFolder.CanBeWorn(item.Data))
                                            {
                                                outfit.Add((InventoryItem)(item.Data));
                                            }
                                        }
                                        instance.COF.RemoveFromOutfit(outfit);
                                    }
                                }
                            }
                            else
                            {
                                client.Network.CurrentSim.ObjectsPrimitives.FindAll(p => p.ParentID == client.Self.LocalID).ForEach(attachment =>
                                {
                                    if (client.Inventory.Store.Items.ContainsKey(CurrentOutfitFolder.GetAttachmentItem(attachment)))
                                    {
                                        instance.COF.Detach((InventoryItem)client.Inventory.Store.Items[CurrentOutfitFolder.GetAttachmentItem(attachment)].Data);
                                    }
                                });
                            }
                        }
                        break;

                    case "remoutfit":
                        if (rule.Param == "force")
                        {
                            if (!string.IsNullOrEmpty(rule.Option))
                            {
                                var w = RLVWearables.Find(a => a.Name == rule.Option);
                                if (w.Name == rule.Option)
                                {
                                    var items = instance.COF.GetWornAt(w.Type);
                                    instance.COF.RemoveFromOutfit(items);
                                }
                            }
                        }
                        break;

                    case "attach":
                    case "attachoverorreplace":
                    case "attachover":
                        if (rule.Param == "force")
                        {
                            if (!string.IsNullOrEmpty(rule.Option))
                            {
                                InventoryNode folder = FindFolder(rule.Option);
                                if (folder != null)
                                {
                                    List<InventoryItem> outfit = new List<InventoryItem>();
                                    foreach (var item in folder.Nodes.Values)
                                    {
                                        if (CurrentOutfitFolder.CanBeWorn(item.Data))
                                        {
                                            outfit.Add((InventoryItem)item.Data);
                                        }
                                    }
                                    if (rule.Behaviour == "attachover")
                                    {
                                        instance.COF.AddToOutfit(outfit, false);
                                    }
                                    else
                                    {
                                        instance.COF.AddToOutfit(outfit, true);
                                    }
                                }
                            }
                        }
                        break;

                    case "getinv":
                        if (int.TryParse(rule.Param, out chan) && chan > 0)
                        {
                            string res = string.Empty;
                            InventoryNode folder = FindFolder(rule.Option);
                            if (folder != null)
                            {
                                foreach (var f in folder.Nodes.Values)
                                {
                                    if (f.Data is InventoryFolder && !f.Data.Name.StartsWith("."))
                                    {
                                        res += f.Data.Name + ",";
                                    }
                                }
                            }

                            Respond(chan, res.TrimEnd(','));
                        }
                        break;

                    case "getinvworn":
                        if (int.TryParse(rule.Param, out chan) && chan > 0)
                        {
                            string res = string.Empty;
                            InventoryNode root = FindFolder(rule.Option);
                            if (root != null)
                            {
                                res += "|" + GetWornIndicator(root) + ",";
                                foreach (var n in root.Nodes.Values)
                                {
                                    if (n.Data is InventoryFolder && !n.Data.Name.StartsWith("."))
                                    {
                                        res += n.Data.Name + "|" + GetWornIndicator(n) + ",";
                                    }
                                }
                            }

                            Respond(chan, res.TrimEnd(','));
                        }
                        break;

                    #endregion #RLV folder and outfit manipulation

                }
            }

            return true;
        }
Esempio n. 34
0
 /// <summary>Raises the ChatFromSimulator event</summary>
 /// <param name="e">A ChatEventArgs object containing the
 /// data returned from the data server</param>
 protected virtual void OnChat(ChatEventArgs e)
 {
     EventHandler<ChatEventArgs> handler = m_Chat;
     if (handler != null)
         handler(this, e);
 }
 //listen to chat for commands
 void Self_ChatFromSimulator(object sender, ChatEventArgs e)
 {
     //ensure from self  //if (e.Type != ChatType.Normal || e.SourceType != ChatSourceType.Agent) return;
     if(e.SourceID != Client.Self.AgentID || e.SourceType != ChatSourceType.Agent) return;
     else //pass message to the handler method
     handleMessage(e.Message.ToLower());
 }