예제 #1
0
		private void Decoder_ChatReceived(object sender, ChatEventArgs e)
		{
			if (e.Channel == this)
			{
				ChatReceived?.Invoke(this, e);
			}
		}
예제 #2
0
파일: Train.cs 프로젝트: ArcticEcho/Hatman
        public bool HandleEvent(object sender, ChatEventArgs e)
        {
            if (e.Type == EventType.MessagePosted)
                ProcessMessage(e);

            return false;
        }
예제 #3
0
 // Implements ICommLayer
 public void NotifyCommHandler(object sender, ChatEventArgs e)
 {
     if (CommHandler != null)
     {
         CommHandler(this, e);
     }
 }
예제 #4
0
        public void Add(string s)
        {
            ChatEventArgs args = new ChatEventArgs()
            {
                SenderName   = SenderName,
                ReceivedDate = DateTime.Today
            };

            OnMessageReceived(args);
        }
예제 #5
0
        public bool HandleEvent(object sender, ChatEventArgs e)
        {
            if (ptn.IsMatch(e.Message.Content))
            {
                e.Room.PostMessageLight("No more.");
                return(true);
            }

            return(false);
        }
예제 #6
0
        public bool HandleEvent(object sender, ChatEventArgs e)
        {
            if (ptn.IsMatch(e.Message.Content))
            {
                e.Room.PostMessageLight("No more.");
                return true;
            }

            return false;
        }
예제 #7
0
    public void OnMesage(object source, ChatEventArgs args)
    {
        // since we could have sent the message
        if (source == this)
        {
            return;
        }

        myListBox.Items.Add(args.Message);
    }
예제 #8
0
        /// <summary>
        /// Handle somebody speaking near us.
        /// </summary>
        /// <param name="message"></param>
        /// <param name="audible"></param>
        /// <param name="type"></param>
        /// <param name="sourceType"></param>
        /// <param name="fromName"></param>
        /// <param name="id"></param>
        /// <param name="ownerid"></param>
        /// <param name="position"></param>
        void OnChat(
            object sender,
            ChatEventArgs e)
        {
/*             string message,
 *          ChatAudibleLevel audible,
 *          ChatType type,
 *          ChatSourceType sourceType,
 *          string fromName,
 *          UUID id, UUID ownerid, Vector3 position)
 */
            // Ignore some chat types.
            switch (e.Type)
            {
            case ChatType.Debug:
            case ChatType.StartTyping:
            case ChatType.StopTyping:
                return;

            default:
                break;
            }

            string message = e.Message;

            // Ignore empty messages.
            if (message == "")
            {
                return;
            }

            // Speak it according to what kind of thing said it.
            switch (e.SourceType)
            {
            case ChatSourceType.System:
                Talker.Say(message);
                break;

            case ChatSourceType.Object:
                if (muteObjects)
                {
                    return;
                }
                Talker.SayObject(e.FromName, message, e.Position);
                break;

            case ChatSourceType.Agent:
                Talker.SayPerson(
                    FriendlyName(e.FromName, e.SourceID),
                    message,
                    e.Position,
                    Talker.voices.VoiceFor(e.SourceID));
                break;
            }
        }
예제 #9
0
        private void GamelogManager_MessageRecevied(object sender, ChatEventArgs e)
        {
            switch (e.ChatLogEntry.MessageType)
            {
            case MessageType.RetainerSaleReports:
                Logger.Info("Market Board sale made.");

                var match = _mbRegex.Match(e.ChatLogEntry.Contents);
                if (match.Success)
                {
                    _saleCount++;
                    Sale sale   = new Sale();
                    var  groups = match.Groups;

                    sale.SalesDateTime = e.ChatLogEntry.TimeStamp.ToLocalTime();
                    sale.AmountSold    = groups[1].ToString() != "" ? int.Parse(groups[1].ToString()) : 1;



                    Item item = GetItemFromBytes(e.ChatLogEntry.Bytes);
                    if (item != null)
                    {
                        sale.ItemSold     = item.CurrentLocaleName;
                        sale.ItemId       = item.Id;
                        sale.SoldPrice    = int.Parse(groups[2].ToString().Replace(",", ""));
                        _gil             += sale.SoldPrice;
                        sale.ByteHashCode = ComputeHash(e.ChatLogEntry.Bytes);

                        if (SalesSettings.Instance.Sales.Contains(sale))
                        {
                            Logger.Info($"Sale already in list for {sale.ItemSold}");
                            return;
                        }

                        Logger.Info($"{sale.AmountSold} x {sale.ItemSold} (Item ID: {sale.ItemId}) sold for {sale.SoldPrice:n0}\n");
                        Logger.Info($"You have made {_saleCount} sales, and {_gil:n0} since starting the bot.");

                        SalesSettings.Instance.Sales.Add(sale);
                        SalesSettings.Instance.Save();
                        _form?.UpdateSalesDgv();
                    }
                    else
                    {
                        var chatbytes = string.Join(" ", e.ChatLogEntry.Bytes.Select(i => $"{i:X2}"));
                        Logger.Verbose($"Chat Log Bytes: {chatbytes}");
                    }
                }
                break;

            case MessageType.Tell_Receive:
                Logger.Info($"Tell received from {e.ChatLogEntry.SenderDisplayName}.");
                Logger.Info($"Tell text: {e.ChatLogEntry.Contents}");
                break;
            }
        }
예제 #10
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;
        }
예제 #11
0
 void OnChat(Player pl, ChatEventArgs args)
 {
     if (pList.ContainsKey(pl)) {
         var p = Player.Find(pList[pl]);
         args.Username = pList[p];
         //Player.UniversalChat(p.voicestring + p.color + p.prefix + p.Username + ": &f" + args.message);
     }
     else {
         pl.OnPlayerChat.Normal -= new ChatEvent.EventHandler(OnChat);
     }
 }
예제 #12
0
        // "Name<uid><wonid><team>" say_team "message" [63.2]
        /// <summary>
        /// Raises the <see cref="TeamSay"/> event.
        /// </summary>
        /// <param name="timestamp">Time at which <see cref="TeamSay"/> event was fired.</param>
        /// <param name="info">Information about <see cref="TeamSay"/> event.</param>
        protected virtual void OnTeamSay(DateTime timestamp, string[] info)
        {
            ChatEventArgs eventArgs = new ChatEventArgs()
            {
                Timestamp = timestamp,
                Player    = GetPlayerInfo(info[0]),
                Message   = info.Length == 3 ? info[2] : string.Empty
            };

            TeamSay.Fire(ServerEndPoint, eventArgs);
        }
예제 #13
0
 public static void HandleNotification(ChatEventArgs e)
 {
     if (RaiseCustomEvent != null)
     {
         RaiseCustomEvent(null, e);
     }
     else
     {
         SendDeviceNotification(e);
     }
 }
예제 #14
0
 private void ServerConnection_MessageArrived(object sender, ChatEventArgs e)
 {
     switch (e.Message.MessageInfo.MsgId)
     {
     case MessageId.ConnectedToMilestoneToServer:
         Chatting.WhisperGui(new Info {
             MsgId = MessageId.ConnectedToMilestoneServer, Bool = IsConnectedToMilestoneServer
         });
         break;
     }
 }
예제 #15
0
 private void Self_ChatFromSimulator(object sender, ChatEventArgs e)
 {
     if (CanSyncInvoke)
     {
         NetcomSync.BeginInvoke(new OnChatRaise(OnChatReceived), new object[] { e });
     }
     else
     {
         OnChatReceived(e);
     }
 }
예제 #16
0
 private async void OnRoomJoined(object sender, ChatEventArgs e)
 {
     if (!e.ChatRoomId.Equals(Guid.Empty))
     {
         _logger.LogInformation($"Trying to connect to chat room {e.ChatRoomId}: {e.ReceivedDate}");
         await JoinChatRoom(new ChatRoomJoin()
         {
             User = e.Sender, ChatRoomId = e.ChatRoomId.ToString()
         }, e.MessageStream);
     }
 }
예제 #17
0
        public void Say(Message msg)
        {
            ChatEventArgs e = new ChatEventArgs
            {
                CallbackType = CallBackType.Receive,
                User         = user,
                Message      = msg
            };

            BroadcastMessage(e);
        }
예제 #18
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);
     }
 }
예제 #19
0
        private void Client_ChatStarted(object sender, ChatEventArgs e)
        {
            RaisePropertyChanged(nameof(IsCurrentlyChatting));

            // var location = (Location)int.Parse(e.ChatInfo.Key.Split(":")[0]);

            Application.Current.Dispatcher.Invoke(() =>
            {
                //  (stranger is probably looking for people in {location})
                ChatItems.Add(new Notification("chat started"));
            });
            Messenger.Default.Send((new ChatStatusMessage("connected to stranger")));
        }
예제 #20
0
        /// <summary>
        /// Raised when a scripted object or agent within range sends a public message
        /// </summary>
        /// <see cref="http://lib.openmetaverse.org/docs/trunk/html/E_OpenMetaverse_AgentManager_ChatFromSimulator.htm"/>
        /// <param name="sender">Source of this event.</param>
        /// <param name="e"></param>
        void Self_ChatFromSimulator(object sender, ChatEventArgs e)
        {
            lock (greedyBotLock)
            {
                if (e.Message.Trim().ToLower() == "shazbot!")
                {
                    ClearGame();
                    ToggleSeat();
                }
                if (e.SourceID != gameComponents.tableId)
                {
                    return;
                }

                if (e.Message == "It is not your turn. Please wait your turn before attempting to change the playing pieces.")
                {
                    Utils.OutputLine("Chat: Not our turn - StopThreadWork", Utils.OutputLevel.Game);
                    ThreadPool.Instance.StopThreadWork();
                    game         = null;
                    currentState = State.WaitingForOurTurn;
                }
                else if (e.Message == "You must accumulate at least 1000 points before you can begin scoring. Keep on truckin'.")
                {
                    // TODO: This is a hack... but it semes to be an OKAY hack! If we get this message then we actually have 0 points
                    //  and because we don't have a very reliable way to detect the end of the game yet to reset to 0 points we're just
                    //  going to use this to do it for us!
                    Utils.OutputLine("Chat: must get 1k points - scheduling roll", Utils.OutputLevel.Game);
                    myGameScore = 0;
                    ClickRoll();
                }
                else if (e.Message == "This is the final round, you must keep rolling until you beat the current top score or bust. Good luck, citizen.")
                {
                    // TODO: Detect that this is the last round so we can use the correct algorithm in the game logic to pick our dice
                    //   for now we just keep trying to roll until we either exceed the opponets score or bust.
                    Utils.OutputLine("MSG 3: End of game must keep rolling till we win or bust - scheduling roll", Utils.OutputLevel.Game);
                    ClickRoll();
                }
                else if (e.Message.EndsWith(" has left the game."))
                {
                    // TODO: Check to see if we're the last player?
                }
                else if (e.Message.EndsWith(" has joined the game."))
                {
                    // TODO: Check to see if we're the only player?
                }
                else if (e.Message.StartsWith("Welcome to the game,"))
                {
                    // TODO: do anything?
                }
            }
        }
예제 #21
0
        public User[] Join(User name)
        {
            bool userAdded = false;

            //create a new ChatEventHandler delegate, pointing to the MyEventHandler() method
            eventHandler = new EventHandler <ChatEventArgs>(ChatEventHandler);

            //carry out a critical section that checks to see if the new chatter
            //name is already in use, if its not allow the new chatter to be
            //added to the list of chatters, using the user as the key, and the
            //ChatEventHandler delegate as the value, for later invocation
            lock (syncObj)
            {
                if (name != null && !CheckIfPersonExists(name.Name))
                {
                    user = name;
                    chatters.Add(name, ChatEventHandler);
                    userAdded = true;
                }
            }

            //if the new chatter could be successfully added, get a callback instance
            //create a new message, and broadcast it to all other chatters, and then
            //return the list of al chatters such that connected clients may show a
            //list of all the chatters
            if (userAdded)
            {
                callback = OperationContext.Current.GetCallbackChannel <IChatCallback>();
                ChatEventArgs e = new ChatEventArgs()
                {
                    CallbackType = CallBackType.UserEnter,
                    User         = user
                };

                BroadcastMessage(e);
                //add this newly joined chatters ChatEventHandler delegate, to the global
                //multicast delegate for invocation
                ChatEvent += eventHandler;
                User[] list = new User[chatters.Count];
                //carry out a critical section that copy all chatters to a new list
                lock (syncObj)
                    chatters.Keys.CopyTo(list, 0);

                return(list);
            }
            else
            {
                return(null);
            }
        }
예제 #22
0
        private string OnChat(string message)
        {
            ChatEventArgs e = new ChatEventArgs
            {
                Cancelled = false,
                Message   = message
            };

            if (ChatMessage != null)
            {
                ChatMessage.Invoke(this, e);
            }
            return(e.Cancelled ? null : e.Message);
        }
예제 #23
0
        public override async Task JoinAndWriteMessage(IAsyncStreamReader <Message> requestStream, IServerStreamWriter <Message> responseStream, ServerCallContext context)
        {
            if (!await requestStream.MoveNext())
            {
                return;
            }
            do
            {
                var eventArgs = new ChatEventArgs(requestStream.Current.User, requestStream.Current, responseStream);
                chatHandler.Invoke(null, eventArgs);
            } while (await requestStream.MoveNext());

            _chatRoomService.Remove(Guid.Parse(requestStream.Current.ChatRoomId), context.Peer);
        }
예제 #24
0
        public bool HandleEvent(object sender, ChatEventArgs e)
        {
            if (e.Message.Content.ToLowerInvariant().Contains("starry night"))
            {
                starryNight = true;
            }

            if (starryNight && !outOfStars)
            {
                outOfStars = !e.Room.ToggleStar(e.Message);
            }

            return(true);
        }
예제 #25
0
        private async void GameMaster(object sender, ChatEventArgs e)
        {
            if (Settings.Current.GM.Enabled)
            {
                SndPlayer.play("gm.wav");
                Log.Bot.Print("ATTENTION! A Game Master is contacting you.");
                Log.Chat.PrintMsg(Log.Chat.Channels.Gm, e.ChatLogEntry.Contents, e.ChatLogEntry.SenderDisplayName);

                if (Settings.Current.GM.PushBulletEnabled && Settings.Current.pushBullet.Enabled)
                {
                    await new PushBullet.Note("AlertMe", String.Format("From: {0}\r\n{1} {2}", e.ChatLogEntry.SenderDisplayName, '[' + Log.Chat.Channels.Gm.ToString() + ']', e.ChatLogEntry.Contents)).Push();
                }
            }
        }
예제 #26
0
        public bool HandleEvent(object sender, ChatEventArgs e)
        {
            if (e.Message.Content.ToLowerInvariant().Contains("starry night"))
            {
                starryNight = true;
            }

            if (starryNight && !outOfStars)
            {
                outOfStars = !e.Room.ToggleStar(e.Message);
            }

            return true;
        }
예제 #27
0
        public void OnSubmit(ChatEventArgs chatEvent)
        {
            if (!string.IsNullOrEmpty(chatEvent.Text))
            {
                try
                {
                    if (!BoltNetwork.isRunning)
                    {
                        return;
                    }

                    // Check if player is detached
                    var isAttached = LocalPlayer.Entity?.isAttached ?? false;

                    // Validate player
                    ValidatePlayer();

                    // Check if we need to randomize
                    if (CurrentChatAs == ChatAs.Random || (CurrentChatAs == ChatAs.Self && !isAttached && CurrentChatAsInvisible == ChatAsInvisible.Random))
                    {
                        RandomizePlayer();

                        // Validate
                        if (LastChattedAs == null)
                        {
                            Logger.Warning("Player still null even after refresh (all invisible?)");
                            return;
                        }
                        if (!LastChattedAs.Entity.isAttached)
                        {
                            Logger.Warning("Random player is not attached (disconnecting?)");
                            return;
                        }
                    }

                    // Apply values
                    if (!isAttached)
                    {
                        chatEvent.Target = GlobalTargets.Everyone;
                    }
                    chatEvent.CustomHandler = true;
                    chatEvent.SenderId      = CurrentChatAs == ChatAs.Self && isAttached ? LocalPlayer.Entity.networkId : LastChattedAs.NetworkId;
                    chatEvent.Text          = ((isAttached && UsePrefixWhenVisible) || (!isAttached && UsePrefixWhenInvisible) ? GriefClientPro.ChatManager.Prefix : string.Empty) + chatEvent.Text;
                }
                catch (Exception e)
                {
                    Logger.Exception("Exception while processing chat message to send!", e);
                }
            }
        }
        /// <summary>
        /// Adds a ChatSelection tile the the Chat seletion stack
        /// </summary>
        /// <param name="source"></param>
        /// <param name="args"></param>
        private void Chat_Added(object source, ChatEventArgs args)
        {
            ChatPage          chatPage          = new ChatPage(args.Chat);
            ChatSelectionTile chatSelectionTile = new ChatSelectionTile(chatPage);


            Device.BeginInvokeOnMainThread(() =>
            {
                chatSelectionStack.Children.Add(chatSelectionTile);
                chatSelctScroll.ScrollToAsync(chatSelectionStack, ScrollToPosition.Start, false);
            });

            OrderMostRecentChat(chatSelectionTile);
        }
예제 #29
0
        private void Self_ChatFromSimulator(object sender, ChatEventArgs e)
        {
            //process the chat info (it is contained in "e") and the sender info is in sender

            if (e.Message == "How are you?")
            {
                Client.Self.Chat("You " + e.FromName + " is talking to me and I will answer ", 0, ChatType.Normal);
                Client.Self.Chat("I am fine Dude!", 0, ChatType.Normal);
                Client.Self.Chat("Your UUID is: " + e.SourceID, 0, ChatType.Normal);
            }
            else if (e.Message == "Bye")
            {
                Client.Self.Chat("Bye " + e.FromName + " !", 0, ChatType.Normal);
            }
        }
예제 #30
0
        private void ServerConnection_UserEnter(object sender, ChatEventArgs e)
        {
            if (e != null && e.User != null && !string.IsNullOrEmpty(e.User.Name))
            {
                if (e.User.Name != User.AutoExporterServiceName)
                {
                    string msg = $"New Client: {e.User.Name}";
                    Console.WriteLine(msg);
                    Program.Log.Info(msg);
                }

                //Info info = new Info { MsgId = MessageId.Init, Message1 = CodecList };
                //Chatting.Whisper(e.User.Name, info);
            }
        }
예제 #31
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);
        }
예제 #32
0
        private void SocketClientOnUserCreatedChannel(object source, EventArgs args)
        {
            Application.Current.Dispatcher.Invoke(() =>
            {
                ChatEventArgs e = (ChatEventArgs)args;
                var newChannel  = new Channel(e.ChannelName, e.ChannelId, e.IsGame);
                Channels.Add(newChannel);
                if (e.UserID == SessionInformations.User.ID)
                {
                    JoinChannel(newChannel);
                }

                UpdateChannels();
            });
        }
예제 #33
0
        public static void SendDeviceNotification(ChatEventArgs e)
        {
            var data = new NotificationData
            {
                Message   = e.Message,
                ContactId = e.ContactId,
                UserName  = e.UserName,
                GroupId   = e.GroupId,
                ChatId    = e.ChatId,
                IsFile    = e.IsFile
            };

            DependencyService.Get <ILocalNotificationService>()
            .Show(data);
        }
예제 #34
0
 void Self_ChatFromSimulator(object sender, ChatEventArgs e)
 {
     if (e.AudibleLevel == ChatAudibleLevel.Fully && e.Type != ChatType.StartTyping && e.Type != ChatType.StopTyping)
     {
         Color color;
         if (e.SourceType == ChatSourceType.Agent)
         {
             color = Color.FromKnownColor(KnownColor.ControlText);
         }
         else
         {
             color = Color.FromKnownColor(KnownColor.GrayText);
         }
         LogChat(e.FromName, e.Type, e.Message, color);
     }
 }
예제 #35
0
 private void GamelogManagerOnMessageRecevied(object sender, ChatEventArgs e)
 {
     if (e.ChatLogEntry.MessageType == (MessageType)2105)
     {
         foreach (var name in pomanderLocalizedNames)
         {
             if (e.ChatLogEntry.FullLine.IndexOf(name, StringComparison.OrdinalIgnoreCase) >= 0)
             {
                 Logger.Info("Got a message that looks like we are capped on" + name);
                 GamelogManager.MessageRecevied -= GamelogManagerOnMessageRecevied;
                 pomanderCapped = true;
                 break;
             }
         }
     }
 }
예제 #36
0
        protected void ReceiveMessage(object sender, ChatEventArgs e)
        {
#if RB_CN
            if (e.ChatLogEntry.MessageType == (MessageType)2115 && e.ChatLogEntry.Contents.Contains("获得了") ||
                e.ChatLogEntry.MessageType == (MessageType)67 && e.ChatLogEntry.Contents.Contains("鱼逃走了"))
            {
                MatchSpearResult(e.ChatLogEntry.Contents);
            }
#else
            if (e.ChatLogEntry.MessageType == (MessageType)2115 && e.ChatLogEntry.Contents.StartsWith("You spear") ||
                e.ChatLogEntry.MessageType == (MessageType)67 && e.ChatLogEntry.Contents.StartsWith("The fish"))
            {
                MatchSpearResult(e.ChatLogEntry.Contents);
            }
#endif
        }
예제 #37
0
        public bool HandleEvent(object sender, ChatEventArgs e)
        {
            if (e.Type == EventType.UserEntered)
            {
                if (e.User.GetChatFriendlyUsername().ToLowerInvariant() == "kyll")
                {
                    e.Room.PostMessageFast("@Kyll Plop!");
                }
                else
                {
                    e.Room.PostMessageFast(String.Format("@{0} {1}",
                        e.User.GetChatFriendlyUsername(),
                        Extensions.PickRandom<string>(hiPhrases)));
                }
                e.Handled = true;
                return true;
            }

            return false;
        }
예제 #38
0
        public bool HandleEvent(object sender, ChatEventArgs e)
        {
            if (ptn.IsMatch(e.Message.Content))
            {
                var n = new byte[4];
                Extensions.RNG.GetBytes(n);

                if (BitConverter.ToUInt32(n, 0) % 10 == 0)
                {
                    e.Room.PostMessageLight("https://media.giphy.com/media/12mgpZe6brh2nu/giphy.gif");
                }
                else
                {
                    e.Room.PostMessageLight("Baby don't hurt me.");
                }

                return true;
            }

            return false;
        }
예제 #39
0
파일: Train.cs 프로젝트: thebecwar/Hatman
        public bool ProcessMessage(ChatEventArgs e)
        {
            var curMsg = e.Message.Content.ToLowerInvariant();

            if (curMsg.StartsWith("https"))
            {
                curMsg = curMsg.Remove(4, 1);
            }

            if (curMsg == lastMsg && curMsg != lastPostedMessage)
            {
                var n = new byte[4];
                rng.GetBytes(n);

                if (BitConverter.ToUInt32(n, 0) % 10 == 0)
                {
                    rng.GetBytes(n);

                    if (BitConverter.ToUInt32(n, 0) % 10 > 4)
                    {
                        e.Room.PostMessageFast("C-C-C-COMBO BREAKER");
                    }
                    else
                    {
                        e.Room.PostMessageFast("https://s3.amazonaws.com/img.ultrasignup.com/events/raw/6a76f4a3-4ad2-4ae2-8a3b-c092e85586af.jpg");
                    }
                }
                else
                {
                    e.Room.PostMessageFast(e.Message.Content);
                }

                e.Handled = true;

                lastPostedMessage = lastMsg;
            }

            lastMsg = curMsg;
            return false;
        }
예제 #40
0
        private void plist(Player sender, ChatEventArgs eventargs) {
            sender.OnPlayerChat.Normal -= new ChatEvent.EventHandler(plist);
            if (eventargs.Message.ToLower() != "yes" || sender.ExtraData.GetIfExist<object, object>("LastCmd") != "mapinfo" && sender.ExtraData.GetIfExist("LastCmd") != "mi")
                return;

            eventargs.Cancel();
            Level l = (Level)sender.GetDatapass("mapinfoLevel");
            List<Player> templist = Server.Players.FindAll((p) => { return p.Level == l; });

            if (templist.Count == 0) {
                sender.SendMessage("No one is on " + l.Name + ".");
                return;
            }
            if (templist.Count == 1 && sender.Level == l) {
                sender.SendMessage("No one besides you is on " + l.Name + ".");
                return;
            }

            templist.ForEach((p) => {
                sender.SendMessage(String.Concat(p.Color, p.Username));
            });
        }
예제 #41
0
파일: HiBye.cs 프로젝트: ArcticEcho/Hatman
        public bool HandleEvent(object sender, ChatEventArgs e)
        {
            if (e.Type == EventType.UserEntered && !e.User.IsMod)
            {
                var b = new byte[4];
                Extensions.RNG.GetBytes(b);

                if (BitConverter.ToUInt32(b, 0) % 2 == 0 && e.User.ID == 4174897)
                {
                    e.Room.PostMessageLight("@Kyll Plop!");
                }
                else
                {
                    e.Room.PostMessageLight(string.Format("@{0} {1}",
                        e.User.Name.Replace(" ", ""),
                        Extensions.PickRandom<string>(hiPhrases)));
                }

                e.Handled = true;
                return true;
            }

            return false;
        }
예제 #42
0
        public bool HandleEvent(object sender, ChatEventArgs e)
        {
            if (activeUser == null)
            {
                if (startReorderCmdPattern.IsMatch(e.Message.Content))
                {
                    activeUser = e.Message.Author;
                    PrintCommandListReply(e.Message, e.Room);
                    e.Handled = true;
                    return true; // stay as the active trigger
                }
            }
            else if (e.Message.Author.Name.Equals(activeUser.Name))
            {
                List<int> args = ParseCommandArgs(e.Message.Content);
                if (switchCmdPattern.IsMatch(e.Message.Content))
                {
                    // need 2 args
                    if (args.Count < 2)
                    {
                        e.Room.PostReplyLight(e.Message, "Not enough parameters. Try again, dummy.");
                        e.Handled = true;
                        return true;
                    }
                    // sanity check
                    if (args[0] > router.Commands.Count || args[1] > router.Commands.Count)
                    {
                        e.Room.PostReplyLight(e.Message, "Message failed sanity check. You're crazy.");
                        e.Handled = true;
                        return true;
                    }

                    //swap
                    ICommand first = router.Commands[args[0] - 1];
                    router.Commands[args[0] - 1] = router.Commands[args[1] - 1];
                    router.Commands[args[1] - 1] = first;

                    PrintCommandListReply(e.Message, e.Room);

                    e.Handled = true;
                    return true;

                }
                else if (toggleCmdPattern.IsMatch(e.Message.Content))
                {
                    if (args.Count <1)
                    {
                        e.Room.PostReplyLight(e.Message, "Not enough parameters. Try again, dummy.");
                        e.Handled = true;
                        return true;
                    }
                    if (args[0] > router.Commands.Count)
                    {
                        e.Room.PostReplyLight(e.Message, "Message failed sanity check. You're crazy.");
                        e.Handled = true;
                        return true;
                    }

                    // toggle the state.
                    router.CommandStates[router.Commands[args[0] - 1]] = !router.CommandStates[router.Commands[args[0] - 1]];
                    PrintCommandListReply(e.Message, e.Room);
                    e.Handled = true;
                    return true;
                }
                else if (doneReorderCmd.IsMatch(e.Message.Content))
                {
                    activeUser = null;
                    e.Room.PostReplyLight(e.Message, "Done.");
                    e.Handled = true;
                }
                else
                {
                    e.Room.PostReplyLight(e.Message, "Try not mumbling so much.");
                }
            }

            return false;
        }
예제 #43
0
        void ChatReceived( object sender, ChatEventArgs e )
        {
            CpeMessage type = e.Type;
            if( type == CpeMessage.Normal ) {
                chatIndex++;
                List<ChatLine> chat = game.Chat.Log;
                normalChat.PushUpAndReplaceLast( chat[chatIndex + chatLines - 1].Text );

                int[] metadata = (int[])Metadata;
                for( int i = 0; i < chatLines - 1; i++ )
                    metadata[i] = metadata[i + 1];
                metadata[chatLines - 1] = chatIndex + chatLines - 1;
            } else if( type >= CpeMessage.Status1 && type <= CpeMessage.Status3 ) {
                status.SetText( (int)( type - CpeMessage.Status1 ), e.Text );
            } else if( type >= CpeMessage.BottomRight1 && type <= CpeMessage.BottomRight3 ) {
                bottomRight.SetText( 2 - (int)( type - CpeMessage.BottomRight1 ), e.Text );
            } else if( type == CpeMessage.Announcement ) {
                UpdateAnnouncement( e.Text );
            }
        }
예제 #44
0
 void Self_ChatFromSimulator(object sender, ChatEventArgs e)
 {
     if (e.AudibleLevel == ChatAudibleLevel.Fully && e.Type != ChatType.StartTyping && e.Type != ChatType.StopTyping)
     {
         Color color;
         if (e.SourceType == ChatSourceType.Agent) color = Color.FromKnownColor(KnownColor.ControlText);
         else color = Color.FromKnownColor(KnownColor.GrayText);
         LogChat(e.FromName, e.Type, e.Message, color);
     }
 }
예제 #45
0
파일: World.cs 프로젝트: JohnMcCaffery/XMRM
        private void HandleChatPacket(OSChatMessage chat)
        {
            if (string.IsNullOrEmpty(chat.Message))
                return;

            // Object?
            if (chat.Sender == null && chat.SenderObject != null)
            {
                ChatEventArgs e = new ChatEventArgs();
                e.Sender = new EntityWrapper(Objects[((SceneObjectPart) chat.SenderObject).LocalId]);
                e.Text = chat.Message;
                e.Channel = chat.Channel;

                _OnChat(this, e);
                return;
            }
            // Avatar?
            if (chat.Sender != null && chat.SenderObject == null)
            {
                ChatEventArgs e = new ChatEventArgs();
                e.Sender = new EntityWrapper(new SPAvatar(m_internalScene, chat.Sender.AgentId, m_security, m_rawObjs));
                e.Text = chat.Message;
                e.Channel = chat.Channel;

                _OnChat(this, e);
                return;
            }
            // Skip if other
        }
예제 #46
0
        void OnAllPlayersChat_Normal(Player p, ChatEventArgs args) {
            #region Spam Check
            if (hasPlayerInfo(p)) {
                PlayerInfo pi = getPlayerInfo(p);
                if (pi.LastMessage.ToLower() == args.Message.ToLower())
                    pi.offense++;
                else {
                    pi.LastMessage = args.Message;
                    pi.offense--;
                }
            }
            #endregion

            #region Caps Check
            int rage = 0;
            bool skip = false;
        goagain: //EWW LABELS
            string newmessage = "";
            string message = args.Message;
            for (int i = 0; i < message.Length; i++) {
                char c = message[i];
                if (caps.IndexOf(c) != -1)
                    rage++;
                else
                    rage--;
                if (rage >= 5 && caps.IndexOf(c) != -1)
                    c = nocaps[caps.IndexOf(c)];
                newmessage += c;
            }
            if (rage == message.Length) {
                skip = true;
                p.SendMessage("Lay off the caps :/");
                goto goagain;
            }
            else if (rage >= 7 && !skip) {
                p.SendMessage("Lay off the caps :/");
                if (!hasPlayerInfo(p)) {
                    PlayerInfo pi = new PlayerInfo(p);
                    pi.LastMessageSent = DateTime.Now;
                    pi.LastMessage = message;
                    players.Add(pi);
                }
                else {
                    PlayerInfo pi = getPlayerInfo(p);
                    pi.offense++;
                }
            }
            args.Message = newmessage;
            #endregion

            if (hasPlayerInfo(p) && getPlayerInfo(p).kicked)
                args.Cancel();
        }
예제 #47
0
 void ChatReceived( object sender, ChatEventArgs e )
 {
     CpeMessage type = e.Type;
     if( type == CpeMessage.Normal ) {
         chatIndex++;
         List<string> chat = game.Chat.Log;
         normalChat.PushUpAndReplaceLast( chat[chatIndex + chatLines - 1] );
     } else if( type >= CpeMessage.Status1 && type <= CpeMessage.Status3 ) {
         status.SetText( (int)( type - CpeMessage.Status1 ), e.Text );
     } else if( type >= CpeMessage.BottomRight1 && type <= CpeMessage.BottomRight3 ) {
         bottomRight.SetText( 2 - (int)( type - CpeMessage.BottomRight1 ), e.Text );
     } else if( type == CpeMessage.Announcement ) {
         UpdateAnnouncement( e.Text );
     }
 }
예제 #48
0
 public void OnChat(Player Player, ChatEventArgs args)
 {
     ExtraPlayerData P = FindPlayer(Player);
     if (Voting && IsNotImportant(args.Message))
     {
         int l = args.Message.Length;
         if (l > 3)
             l = 3;
         else if (l <= 0)
             l = 1;
         Player.ExtraData.CreateIfNotExist("Voted", false);
         var didVote = (bool)Player.ExtraData.GetIfExist("Voted");
         if (args.Message.ToLower().Equals(LevelChoices[0].Substring(0, l).ToString().ToLower()) && !didVote)
         {
             Player.SendMessage("[Zombie Survival]: " + Colors.red + "Thank you for voting for " + LevelChoices[0]);
             LevelVotes.x += 1;
             Player.ExtraData["Voted"] = true;
             args.Cancel();
         }
         else if (args.Message.ToLower().Equals(LevelChoices[1].Substring(0, l).ToString().ToLower()))
         {
             Player.SendMessage("[Zombie Survival]: " + Colors.red + "Thank you for voting for " + LevelChoices[1]);
             LevelVotes.y += 1;
             Player.ExtraData["Voted"] = true;
             args.Cancel();
         }
         else if (args.Message.ToLower().Equals("random".Substring(0, l).ToString().ToLower()))
         {
             Player.SendMessage("[Zombie Survival]: " + Colors.red + "Thank you for voting for random");
             LevelVotes.z += 1;
             Player.ExtraData["Voted"] = true;
             args.Cancel();
         }
         else if (!(bool)Player.ExtraData.GetIfExist("Voiced") && !P.Referee)
         {
             Player.SendMessage("[Zombie Survival]: " + Colors.red + "You may not speak while voting, sorry :(");
             args.Cancel();
         }
         else
         {
             args.Message = ZombieHelper.CleanString(Player, args.Message);
             if (args.Message == "")
             {
                 args.Cancel();
                 return;
             }
             return;
         }
     }
     else if (IsNotImportant(args.Message))
     {
         var voiceString = (string)Player.ExtraData.GetIfExist("VoiceString") ?? "";
         var mColor = Player.Group.Color;
         var mPrefix = (string)Player.ExtraData.GetIfExist("Title") ?? "";
         string msg = voiceString + mPrefix + mColor + Player.Username + ": &f" + args.Message;
         if (P.Referee)
         {
             msg = Colors.gold + "[Referee] " + msg;
         }
         else if (P.Infected)
         {
             msg = Colors.red + "[Infected] " + msg;
         }
         else
         {
             msg = Colors.green + "[Survivor] " + msg;
         }
         string l = ZombieHelper.CleanString(Player, msg);
         if (l == "")
         {
             args.Cancel();
             return;
         }
         Player.UniversalChat(l);
         Server.IRC.SendMessage(l);
         args.Cancel();
         return;
     }
     else
     {
         args.Message = ZombieHelper.CleanString(Player, args.Message);
         if (args.Message == "")
         {
             args.Cancel();
             return;
         }
         return;
     }
 }
예제 #49
0
파일: World.cs 프로젝트: ChrisD/opensim
        private void HandleChatPacket(OSChatMessage chat)
        {
            if (string.IsNullOrEmpty(chat.Message))
                return;

            // Object?
            if (chat.Sender == null && chat.SenderObject != null)
            {
                ChatEventArgs e = new ChatEventArgs();
                e.Sender = new SOPObject(m_internalScene, ((SceneObjectPart) chat.SenderObject).LocalId);
                e.Text = chat.Message;

                _OnChat(this, e);
                return;
            }
            // Avatar?
            if (chat.Sender != null && chat.SenderObject == null)
            {
                ChatEventArgs e = new ChatEventArgs();
                e.Sender = new SPAvatar(m_internalScene, chat.SenderUUID);
                e.Text = chat.Message;

                _OnChat(this, e);
                return;
            }
            // Skip if other
        }
예제 #50
0
 public void OnChat6(Player p, ChatEventArgs e) {
     OnChat(p, e.Message);
 }
예제 #51
0
        private void HandleChatPacket(OSChatMessage chat)
        {
            if (string.IsNullOrEmpty(chat.Message))
                return;

            // Object?
            if (chat.Sender == null && chat.SenderObject != null)
            {
                ChatEventArgs e = new ChatEventArgs
                                      {
                                          Sender = new SOPObject(m_internalScene, chat.SenderObject.LocalId, m_security),
                                          Text = chat.Message,
                                          Channel = chat.Channel
                                      };

                _OnChat(this, e);
                return;
            }
            // Avatar?
            if (chat.Sender != null && chat.SenderObject == null)
            {
                ChatEventArgs e = new ChatEventArgs
                                      {
                                          Sender = new SPAvatar(m_internalScene, chat.SenderUUID, m_security),
                                          Text = chat.Message,
                                          Channel = chat.Channel
                                      };

                _OnChat(this, e);
                return;
            }
            // Skip if other
        }
예제 #52
0
 private string OnChat(string message)
 {
     ChatEventArgs e = new ChatEventArgs
     {
         Cancelled = false,
         Message = message
     };
     if (ChatMessage != null)
         ChatMessage.Invoke(this, e);
     return e.Cancelled ? null : e.Message;
 }
        private void HandleChat(byte[] message)
        {
            if (!IsLoggedIn) return;

            string incomingText = enc.GetString(message, 1, 64).Trim();

            byte incomingID = message[0];
            if (incomingID != 0xFF && incomingID != ID && incomingID != 0)
            {
                Player.UniversalChatOps("Player " + Username + ", sent a malformed packet!");
                Kick("Hacked Client!");
                return;
            }

            incomingText = Regex.Replace(incomingText, @"\s\s+", " ");

            if (incomingText.StartsWith("/womid"))
            {
                //UsingWom = true;
                //WOM.SendDetail(this); //Will make this editable later ?
                return;
            }

            if (StringUtils.ContainsBadChar(incomingText))
            {
                Kick("Illegal character in chat message!");
                return;
            }

            if (incomingText.Length == 0)
                return;

            if (incomingText[0] == '/' && incomingText.Length == 1)
            {
                if (ExtraData.ContainsKey("LastCmd"))
                {
                    incomingText = "/" + ExtraData["LastCmd"];
                }
                else
                {
                    SendMessage("You need to specify a command!");
                    return;
                }
            }

            //Get rid of whitespace
            var gex = new Regex(@"[ ]{2,}", RegexOptions.None);
            incomingText = gex.Replace(incomingText, @" ");


            //Meep is used above for //Command

            foreach (string word in Server.BadWordsList)
            {

                if (incomingText.Contains(word))
                    incomingText = Regex.Replace(incomingText, word, Server.ReplacementWordsList[playerRandom.Next(0, Server.ReplacementWordsList.Count)]);

            }

            ExtraData.CreateIfNotExist("Muted", false);
            var isMuted = (bool)ExtraData.GetIfExist("Muted");
            if (isMuted)
            {
                SendMessage("You are muted!");
                return;
            }

            ExtraData.CreateIfNotExist("Voiced", false);
            var isVoiced = (bool)ExtraData.GetIfExist("Voiced");
            if (Server.Moderation && !isVoiced && !Server.Devs.Contains<string>(Username))
            {
                SendMessage("You can't talk during chat moderation!");
                return;
            }

            ExtraData.CreateIfNotExist("Jokered", false);
            var isJokered = (bool)ExtraData.GetIfExist("Jokered");
            if (isJokered)
            {
                int a = playerRandom.Next(0, Server.JokerMessages.Count);
                incomingText = Server.JokerMessages[a];
            }

            //Message appending stuff.
            if (ServerSettings.GetSettingBoolean("messageappending"))
            {
                if (!String.IsNullOrWhiteSpace(_storedMessage))
                {
                    if (!incomingText.EndsWith(">") && !incomingText.EndsWith("<"))
                    {
                        incomingText = _storedMessage.Replace("|>|", " ").Replace("|<|", " ") + incomingText;
                        _storedMessage = String.Empty;
                    }
                }
                if (incomingText.EndsWith(">"))
                {
                    _storedMessage += incomingText.Replace(">", "|>|");
                    SendMessage("Message appended!");
                    return;
                }
                else if (incomingText.EndsWith("<"))
                {
                    _storedMessage += incomingText.Replace("<", "|<|");
                    SendMessage("Message appended!");
                    return;
                }
            }

            //This allows people to use //Command and have it appear as /Command in the chat.
            if (incomingText.StartsWith("//"))
            {
                incomingText = incomingText.Remove(0, 1);
            }
            else if (incomingText[0] == '/')
            {
                incomingText = incomingText.Remove(0, 1);

                string[] args = incomingText.Split(' ');
                HandleCommand(args);
                return;
            }

            ChatEventArgs eargs = new ChatEventArgs(incomingText, Username);
            bool canceled = OnPlayerChat.Call(this, eargs, OnAllPlayersChat).Canceled;
            if (canceled || eargs.Message == null || eargs.Message.Length == 0)
                return;
            incomingText = eargs.Message;

            //TODO: add this to a different plugin, its a mess right here, and i hate it
            if (Server.Voting)
            {
                if (Server.KickVote && Server.Kicker == this)
                {
                    SendMessage("You're not allowed to vote!");
                    return;
                }

                ExtraData.CreateIfNotExist("Voted", false);
                var didVote = (bool)ExtraData.GetIfExist("Voted");
                if (didVote)
                {
                    SendMessage("You have already voted...");
                    return;
                }
                string vote = incomingText.ToLower();
                if (vote == "yes" || vote == "y")
                {
                    Server.YesVotes++;
                    ExtraData["Voted"] = true;
                    SendMessage("Thanks for voting!");
                    return;
                }
                else if (vote == "no" || vote == "n")
                {
                    Server.NoVotes++;
                    ExtraData["Voted"] = true;
                    SendMessage("Thanks for voting!");
                    return;
                }
                else
                {
                    SendMessage("Use either %aYes " + Server.DefaultColor + "or %cNo " + Server.DefaultColor + " to vote!");
                }

            }

            ExtraData.CreateIfNotExist("OpChat", false);
            if (incomingText[0] == '#' || (bool)ExtraData.GetIfExist("OpChat")) //Opchat ouo
            {
                incomingText = incomingText.Trim().TrimStart('#');
                UniversalChatOps("&a<&fTo Ops&a> " + Group.Color + Username + ": &f" + incomingText);
                if (Group.Permission < ServerSettings.GetSettingInt("OpChatPermission"))
                {
                    SendMessage("&a<&fTo Ops&a> " + Group.Color + Username + ": &f" + incomingText);
                } //So players who aren't op see their messages
                Logger.Log("<OpChat> <" + Username + "> " + incomingText);
                try
                {
                    if (Server.IRC.opChannel != "#" || Server.IRC.opChannel != "")
                        Server.IRC.SendUserMessage("<OpChat> <" + Username + "> " + incomingText, Server.IRC.opChannel);
                }
                catch { }
                return;
            }
            if (incomingText[0] == '*') //Rank chat
            {
                string groupname = Group.Name;
                incomingText = incomingText.Remove(0, 1);
                if (incomingText == "")
                {
                    return;
                }
                if (!groupname.EndsWith("ed") && !groupname.EndsWith("s"))
                {
                    groupname += "s";
                } //Plural
                RankChat(this, "&a<&fTo " + groupname + "&a> " + Group.Color + DisplayName + ": &f" + incomingText);
                Logger.Log("<" + groupname + " Chat> <" + Username + " as " + DisplayName + "> " + incomingText);
                return;
            }
            if (incomingText[0] == '!') //Level chat
            {
                incomingText = incomingText.Remove(0, 1);
                if (incomingText == "")
                {
                    return;
                }
                LevelChat(this, "&a<&f" + Level.Name + "&a> " + DisplayName + ":&f " + incomingText);
                Logger.Log("<" + Level.Name + " Chat> " + Username + " as " + DisplayName + ": " + incomingText);
                return;
            }

            ExtraData.CreateIfNotExist("AdminChat", false);
            if (incomingText[0] == '+' || (bool)ExtraData.GetIfExist("AdminChat")) //Admin chat
            {
                incomingText = incomingText.Remove(0, 1);
                if (incomingText == "")
                {
                    return;
                }
                UniversalChatAdmins("&a<&fTo Admins&a> " + Group.Color + Username + ": &f" + incomingText);
                if (Group.Permission < ServerSettings.GetSettingInt("AdminChatPermission"))
                {
                    SendMessage("&a<&fTo Admins&a> " + Group.Color + Username + ": &f" + incomingText);
                }
                Logger.Log("<AdminChat> <" + Username + "> " + incomingText);
                return;
            }

            ExtraData.CreateIfNotExist("Whispering", false);
            if ((bool)ExtraData.GetIfExist("Whispering")) // /whisper command
            {
                ExtraData.CreateIfNotExist("WhisperTo", null);
                Player to = (Player)ExtraData.GetIfExist("WhisperTo");
                if (to == null)
                {
                    SendMessage("Player not found!");
                    return;
                }
                if (to == this)
                {
                    SendMessage("Trying to talk to yourself huh?");
                    return;
                }

                //no whispering nicknames
                SendMessage("[>] <" + to.Username + ">&f " + incomingText);
                to.SendMessage("[<] " + Username + ":&f " + incomingText);
                return;
            }
            if (incomingText[0] == '@') //Whisper whisper woosh woosh
            {
                incomingText = incomingText.Trim();
                if (incomingText[1] == ' ')
                {
                    incomingText = incomingText.Remove(1, 1);
                }

                incomingText = incomingText.Remove(0, 1);
                Player to = Player.Find(incomingText.Split(' ')[0]);
                if (to == null)
                {
                    SendMessage("Player not found!");
                    return;
                }

                incomingText = incomingText.Remove(0, to.Username.Length);
                //no whispering nicknames
                SendMessage("[>] <" + to.Username + ">&f " + incomingText.Trim());
                to.SendMessage("[<] " + Username + ":&f " + incomingText.Trim());
                return;
            }
            //TODO: remove to place better
            Logger.Log(Username != DisplayName ? "<" + Username + " as " + DisplayName + "> " + incomingText : "<" + Username + "> " + incomingText);
            var voiceString = (string)ExtraData.GetIfExist("VoiceString") ?? "";
            var mColor = Color ?? Group.Color;
            var mPrefix = (string)ExtraData.GetIfExist("Title") ?? "";
            string msg = voiceString +
                          mPrefix +
                          mColor +
                          DisplayName +
                          ": &f" +
                          incomingText;
            try
            {
                Server.IRC.SendMessage(voiceString + Username + ": " + incomingText);
            }
            catch { }
            UniversalChat(msg);
        }
예제 #54
0
        void ChatReceived( object sender, ChatEventArgs e )
        {
            MessageType type = e.Type;
            if( type == MessageType.Normal ) {
                chatIndex++;
                if( game.ChatLines == 0 ) return;
                List<ChatLine> chat = game.Chat.Log;
                normalChat.PushUpAndReplaceLast( chat[chatIndex + chatLines - 1].Text );

                int[] metadata = (int[])Metadata;
                for( int i = 0; i < chatLines - 1; i++ )
                    metadata[i] = metadata[i + 1];
                metadata[chatLines - 1] = chatIndex + chatLines - 1;
            } else if( type >= MessageType.Status1 && type <= MessageType.Status3 ) {
                status.SetText( 2 + (int)(type - MessageType.Status1), e.Text );
            } else if( type >= MessageType.BottomRight1 && type <= MessageType.BottomRight3 ) {
                bottomRight.SetText( 2 - (int)(type - MessageType.BottomRight1), e.Text );
            } else if( type == MessageType.Announcement ) {
                announcement.SetText( e.Text );
            } else if( type >= MessageType.ClientStatus1 && type <= MessageType.ClientStatus6 ) {
                clientStatus.SetText( (int)(type - MessageType.ClientStatus1), e.Text );
                UpdateChatYOffset( true );
            } else if( type == MessageType.ClientClock && game.ShowClock ) {
                status.SetText( 0, e.Text );
            }
        }
예제 #55
0
 private void HandleChat(object sender, ChatEventArgs e)
 {
     DispatchChatWindowMessage(e.sender.Nickname + ": " + e.text);
 }
예제 #56
0
        void Client_OnChat(object sender, ChatEventArgs e)
        {
            if (e.RawText.Contains("§"))
            {
                string result = ""; foreach (string s in e.RawText.Split('§')) { if (!string.IsNullOrEmpty(s)) { result += s.Substring(1); } } e.RawText = result;
            }
            if (e.RawText.Contains(">") && e.RawText.Contains("<"))
            {
                if (e.RawText.Split('>')[1].Trim().StartsWith("!"))
                {
                    try
                    {
                        string username = e.RawText.Split('<')[1].Split('>')[0];
                        string command = "";
                        if (!e.RawText.Split('>')[1].Trim().Contains(" "))
                        {
                            command = e.RawText.Split('>')[1].Trim().Remove(0, 1);
                        }
                        else
                        {
                            string cemd = e.RawText.Split('>')[1];
                            if (cemd.StartsWith(" ")) { cemd = cemd.Remove(0, 1); }
                            if (cemd.StartsWith("!")) { cemd = cemd.Remove(0, 1); }
                            if (cemd.Contains(" ")) { cemd = cemd.Split(' ')[0]; }
                            command = cemd;
                        }
                        string args = e.RawText.Remove(0, username.Length + 4 + command.Length);
                        Player who = Player.Find(username);
                        Command cmd = Command.Find(command);
                        if (command.ToLower() != "c" && command.ToLower() != "control")
                        {
                            List<string> cnames = new List<string>();
                            foreach (Player playa in controllers) { cnames.Add(playa.Playername.ToLower()); }
                            if (!cnames.Contains(username.ToLower())) { Addline(e.RawText.ToString()); return; }
                        }
                        if (cmd == null) { who.SendMessage("Command '" + command + "' not found!"); }
                        else
                        {
                            if (args.StartsWith(" ") || args != "") { args = args.Remove(0, 1); }
                            if (!cmd.Execute(who, args))
                            {
                                who.SendMessage("You are not allowed to use that command!");
                            }
                        }

                    }
                    catch(Exception err)
                    {
                        // laat mensen opsturen als er errors zijn
                        MessageBox.Show(err.ToString());
                    }
                }
            }
            Addline(e.RawText.ToString());
        }
예제 #57
0
		protected void ReceiveMessage(object sender, ChatEventArgs e)
		{
			if (e.ChatLogEntry.MessageType == (MessageType)2115 && e.ChatLogEntry.Contents.StartsWith("You land"))
			{
				SetFishResult(e.ChatLogEntry.Contents);
			}

			if (e.ChatLogEntry.MessageType == (MessageType)2115
				&& e.ChatLogEntry.Contents.Equals("You do not sense any fish here.", StringComparison.InvariantCultureIgnoreCase))
			{
				Logger.Info("You do not sense any fish here, trying next location.");

				if (CanDoAbility(Abilities.Quit))
				{
					DoAbility(Abilities.Quit);
				}

				ChangeFishSpot();
			}

			if (e.ChatLogEntry.MessageType == (MessageType)2115
				&& e.ChatLogEntry.Contents == "The fish sense something amiss. Perhaps it is time to try another location.")
			{
				Logger.Info("The fish sense something amiss!");
				amissfish++;

				if (CanDoAbility(Abilities.Quit))
				{
					DoAbility(Abilities.Quit);
				}

				ChangeFishSpot();
			}
		}
예제 #58
0
파일: Events.cs 프로젝트: Jascen/UOSmart
 public static void InvokeChat(ChatEventArgs args)
 {
     if (Chat != null)
         Chat(args);
 }
예제 #59
0
        private void netcom_ChatReceived(object sender, ChatEventArgs e)
        {
            if (string.IsNullOrEmpty(e.Message)) return;

            // Avoid form flash if RLV command
            if (e.SourceType == ChatSourceType.Object)
            {
                if (e.Message.StartsWith("@", StringComparison.CurrentCultureIgnoreCase)) return;
            }

            tabs["chat"].Highlight();
        }
예제 #60
0
 /// <summary>
 /// Handler for chat events 
 /// </summary>
 /// <param name="world">The world object which is the key to the in world scenegraph</param>
 /// <param name="args">Any arguments related to the chat event</param>
 public void chatListener(IWorld world, ChatEventArgs args)
 {
     try {
         this.world = world;
         if (proxy != null)
             proxy.updateWorld(world);
         if (listening.Contains(args.Sender.GlobalID) || !(args.Sender is IAvatar))
             return;
     } catch (Exception e) {
         DB.Exception(e, "Problem updating proxy with world", Levels.SCRIPTS);
     }
     try {
         if (world.Objects[hostID] == null || !world.Objects[hostID].Exists) {
             DB.Print("Controller object removed, closing down script completely", Levels.ALWAYS);
             shutdown();
             return;
         }
     } catch (Exception e) {
         DB.Exception(e, "Unable to perform checks on host object", Levels.SCRIPTS);
         DB.Print("Controller object removed, closing down script completely", Levels.ALWAYS);
         shutdown();
         return;
     }
     if (!isRestart(args.Text) &&
         !isStart(args.Text) &&
         !isShutdown(world, args.Text, args.Sender.Name) &&
         !isClear(args.Text, args.Sender)) {
         if (chatQ != null && chatQ.IsRunning) {
             chatQ.qItem(new Pair<IEntity, string>(args.Sender, args.Text));
             DB.Print("Entry Point passed down chat event: " + args.Text, Levels.SCRIPTS);
         }
     }
 }