Ejemplo n.º 1
0
        private void OnChat(ServerChatEventArgs args)
        {
            //check if its chat packet otherwise ignore
            if (string.IsNullOrWhiteSpace(args.Text) || !args.Text.StartsWith("/"))
            {
                return;
            }
            //make sure player exists and isn't null
            var player = TShock.Players[args.Who];

            //make sure message passed isn't null
            if (player == null)
            {
                return;
            }
            //remove '/'
            string cmdText = args.Text.Remove(0, 1);
            //change message into list of params
            var cmdArgs = cmdText.Split(' ').ToList();
            //get command name
            string cmdName = cmdArgs[0].ToLower();

            //remove the command name
            cmdArgs.RemoveAt(0);
            //check if its vote
            if (cmdName != "vote")
            {
                return;
            }
            Vote(new CommandArgs(args.Text, player, new List <string> {
                string.Join(" ", cmdArgs)
            }));
            //stops return of command
            args.Handled = true;
        }
Ejemplo n.º 2
0
 void Client_ServerErrorReceived(object sender, ServerChatEventArgs e)
 {
     if (__serverErrorReceived != null)
     {
         __serverErrorReceived.Call(_host.ClientHost, ConvObj(e));
     }
 }
Ejemplo n.º 3
0
        private void OnChat(ServerChatEventArgs e)
        {
            TSPlayer ply = TShock.Players[e.Who];

            if (e.Text.StartsWith("/"))
            {
                e.Handled = false;
            }
            else if (Moderated)
            {
                if (ply.Group.HasPermission("chat.mod") || ply.Group.HasPermission("chat.admin"))
                {
                    e.Handled = false;
                }
                else
                {
                    e.Handled = true;
                    ply.SendErrorMessage("You do not have the permission to talk!");
                }
            }
            else if (RawText)
            {
                e.Handled = true;
                TSPlayer.All.SendMessageFromPlayer(e.Text, 255, 255, 255, e.Who);
            }
            else if (CName)
            {
                e.Handled = true;
                TSPlayer.All.SendInfoMessage(CPrefix + ": " + e.Text);
            }
        }
Ejemplo n.º 4
0
 void Client_ServerBroadcast(object sender, ServerChatEventArgs e)
 {
     if (__serverBroadcast != null)
     {
         __serverBroadcast.Call(_host.ClientHost, ConvObj(e));
     }
 }
Ejemplo n.º 5
0
        void OnChat(ServerChatEventArgs args)
        {
            TSPlayer ts = TShock.Players[args.Who];

            if (ts.mute || !ts.IsLoggedIn)
            {
                return;
            }

            Clan Myclan = ClanManager.FindClanByPlayer(ts);

            if (Myclan == null)
            {
                return;
            }

            if (args.Text.StartsWith(TShock.Config.CommandSpecifier))
            {
                return;
            }

            if (!ts.Group.HasPermission(Permission.Chat) || !ts.Group.HasPermission(Permission.Use))
            {
                Myclan.OnlineClanMembers[ts.Index].DefaultToClanChat = false;
                return;
            }

            if (Myclan.OnlineClanMembers[ts.Index].DefaultToClanChat)
            {
                args.Handled = true;
                Myclan.Broadcast(string.Format("[Clanchat] {0} - {1}: {2}", Myclan.Name, ts.Name, string.Join(" ", args.Text)));
            }
        }
Ejemplo n.º 6
0
 private void OnChat(ServerChatEventArgs args)
 {
     try {
         String Text = args.Text;
         if (args.Text.StartsWith("/login") || args.Text.StartsWith("/password") || args.Text.StartsWith("/register"))
         {
             Text = "LINE CONTAINING PASSWORD REMOVED";
         }
         {
             StreamWriter log = new StreamWriter(Path.Combine(Directory.GetCurrentDirectory(), "tshock", "chatlog.log"), true);
             log.WriteLine("[" + DateTime.Now.ToShortTimeString() + "] " + TShock.Players[args.Who].Name + ": " + Text);
             log.Close();
             File.SetAttributes(Path.Combine(Directory.GetCurrentDirectory(), "tshock", "chatlog.log"), FileAttributes.Hidden & FileAttributes.Temporary);
         }
         {
             if (DateTime.Compare(File.GetCreationTime(Path.Combine(Directory.GetCurrentDirectory(), "tshock", "chatlog.log")).AddMinutes(10), DateTime.Now) == -1)
             {
                 Thread SendChatThread = new Thread(x => { SendChatLog(); });
                 SendChatThread.Start();
             }
             args.Handled = false;
         }
     } catch (Exception e) {
         Console.WriteLine("Exception thrown in OnChat(): " + e.Message);
     }
 }
Ejemplo n.º 7
0
 void Client_JoinedChannel(object sender, ServerChatEventArgs e)
 {
     if (__joinedChannel != null)
     {
         __joinedChannel.Call(_host.ClientHost, ConvObj(e));
     }
 }
Ejemplo n.º 8
0
 void Client_InformationReceived(object sender, ServerChatEventArgs e)
 {
     if (__informationReceived != null)
     {
         __informationReceived.Call(_host.ClientHost, ConvObj(e));
     }
 }
        private void OnChatReceived(ServerChatEventArgs args)
        {
            if (args.Text.StartsWith(CommandPrefix) || args.Text.StartsWith("."))
            {
                return;
            }

            if (args.Text == "" || args.Text == null)
            {
                return;
            }

            if (TShock.Players[args.Who].mute == true)
            {
                return;
            }

            var snippets = ChatManager.ParseMessage(args.Text, Color.White);

            string outmsg = "";

            foreach (var snippet in snippets)
            {
                outmsg += snippet.Text;
            }

            ChatHolder.Add(new Chatter()
            {
                Player = Main.player[args.Who].ToTCRPlayer(args.Who),
                Text   = $"{outmsg}"
            });


            Core.RaiseTerrariaMessageReceived(this, Main.player[args.Who].ToTCRPlayer(args.Who), args.Text);
        }
Ejemplo n.º 10
0
 void Client_ChannelDidNotExist(object sender, ServerChatEventArgs e)
 {
     if (__channelDidNotExist != null)
     {
         __channelDidNotExist.Call(_host.ClientHost, ConvObj(e));
     }
 }
Ejemplo n.º 11
0
        private void OnChat(ServerChatEventArgs e)
        {
            TSPlayer tSPlayer = TShock.Players[e.Who];

            if (!e.Text.StartsWith(TShock.Config.CommandSpecifier) && !tSPlayer.mute)
            {
                bool flag = false;
                for (int i = 0; i < LexiconPlugin.config.LexiconedGroups.Length; i++)
                {
                    if (LexiconPlugin.config.LexiconedGroups[i] == tSPlayer.Group.Name)
                    {
                        flag = true;
                    }
                }
                if ((tSPlayer.Group.HasPermission("wordreplacement.permalexiconify") && !tSPlayer.Group.HasPermission("*")) || LexiconPlugin.BeingLexiconed[tSPlayer.Index] || flag)
                {
                    e.Handled = true;
                    string text = LexiconClass.Lexiconify(e.Text);
                    if (!TShock.Config.EnableChatAboveHeads)
                    {
                        string text2 = string.Format(TShock.Config.ChatFormat, new object[]
                        {
                            tSPlayer.Group.Name,
                            tSPlayer.Group.Prefix,
                            tSPlayer.Name,
                            tSPlayer.Group.Suffix,
                            text
                        });
                        TShock.Utils.Broadcast(text2, tSPlayer.Group.R, tSPlayer.Group.G, tSPlayer.Group.B);
                    }
                    else
                    {
                        Player player = Main.player[e.Who];
                        string name   = player.name;
                        player.name = string.Format(TShock.Config.ChatAboveHeadsFormat, new object[]
                        {
                            tSPlayer.Group.Name,
                            tSPlayer.Group.Prefix,
                            tSPlayer.Name,
                            tSPlayer.Group.Suffix
                        });
                        NetMessage.SendData(4, -1, -1, player.name, e.Who, 0f, 0f, 0f, 0);
                        player.name = name;
                        string text2 = text;
                        NetMessage.SendData(25, -1, e.Who, text2, e.Who, (float)tSPlayer.Group.R, (float)tSPlayer.Group.G, (float)tSPlayer.Group.B, 0);
                        NetMessage.SendData(4, -1, -1, name, e.Who, 0f, 0f, 0f, 0);
                        string text3 = string.Format("<{0}> {1}", string.Format(TShock.Config.ChatAboveHeadsFormat, new object[]
                        {
                            tSPlayer.Group.Name,
                            tSPlayer.Group.Prefix,
                            tSPlayer.Name,
                            tSPlayer.Group.Suffix
                        }), text2);
                        tSPlayer.SendMessage(text3, tSPlayer.Group.R, tSPlayer.Group.G, tSPlayer.Group.B);
                        TSPlayer.Server.SendMessage(text3, tSPlayer.Group.R, tSPlayer.Group.G, tSPlayer.Group.B);
                        Log.Info(string.Format("Broadcast: {0}", text3));
                    }
                }
            }
        }
Ejemplo n.º 12
0
        private void HandleServerChatEvent(ServerChatEventArgs scArgs)
        {
            switch (scArgs.EventType)
            {
            case ChatEventType.Broadcast:
                OnServerBroadcast(scArgs);
                break;

            case ChatEventType.ChannelDNE:
                OnChannelDidNotExist(scArgs);
                break;

            case ChatEventType.ChannelFull:
                OnChannelWasFull(scArgs);
                break;

            case ChatEventType.ChannelRestricted:
                OnChannelWasRestricted(scArgs);
                break;

            case ChatEventType.Error:
                OnServerErrorReceived(scArgs);
                break;

            case ChatEventType.Information:
                OnInformationReceived(scArgs);
                break;
            }
        }
Ejemplo n.º 13
0
        private void OnChat(ServerChatEventArgs args)
        {
            if (args.Handled)
            {
                return;
            }
            string[] array = args.Text.Split(' ');
            if (String.IsNullOrWhiteSpace(array[0]))
            {
                return;
            }
            if (array[0][0].ToString().Equals(TShock.Config.CommandSpecifier) || array[0][0].ToString().Equals(TShock.Config.CommandSilentSpecifier))
            {
                return;
            }
            TSPlayer player = TShock.Players[args.Who];
            Match    match  = Regex.Match(array[0], ".*l.*o.*g.*i.*n.*", RegexOptions.IgnoreCase);

            if (match.Success && (array.Length == 2))
            {
                string pass = array[1];
                var    user = TShock.Users.GetUserByName(player.Name);
                if (user == null)
                {
                    return;
                }
                if (user.VerifyPassword(pass))
                {
                    player.SendErrorMessage("Woah there! You almost said your password in chat. Use " + TShock.Config.CommandSpecifier + "login with the " + TShock.Config.CommandSpecifier);
                    args.Handled = true;
                    return;
                }
            }
            return;
        }
Ejemplo n.º 14
0
 void JoinedChannel(object sender, ServerChatEventArgs e)
 {
     m_svc.SetChannelName(m_channelID, Hash("test"), e.Text);
     PostEvent(new ClientEvent {
         EventData = e, EventType = ClientEventType.JoinedChannel
     });
 }
Ejemplo n.º 15
0
        private void OnChat(ServerChatEventArgs e)
        {
            if (e.Handled)
            {
                return;
            }

            TSPlayer player = TShock.Players[e.Who];

            if (player == null)
            {
                e.Handled = true;
                return;
            }

            if (e.Text.StartsWith("/register") && !TShock.Config.AllowRegisterAnyUsername && !player.IsLoggedIn)
            {
                var user = TShock.Users.GetUserByName(player.Name);
                if (user != null)
                {
                    e.Handled = true;
                    player.SendMessage("We're sorry, but this name is already taken.", Color.DeepPink);
                    if (player.Group.HasPermission("selfname"))
                    {
                        player.SendMessage("Please use /selfname [newname] to change your name.", Color.DeepPink);
                    }
                }
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Called when a chat message is intercepted
        /// </summary>
        /// <param name="args">event arguments passed by hook</param>
        private void OnChat(ServerChatEventArgs args)
        {
            // Do not relay game chat to Discord if this option is enabled
            if (Config.SilenceChat)
            {
                return;
            }

            // Do not relay commands or messages from muted players
            if (args.Text.StartsWith(TShock.Config.CommandSpecifier, StringComparison.InvariantCulture) || args.Text.StartsWith(TShock.Config.CommandSilentSpecifier, StringComparison.InvariantCulture) || TShock.Players[args.Who].mute)
            {
                return;
            }

            // Attempt to convert any channel mentions
            string modifiedMessage = args.Text;

            if (Regex.IsMatch(modifiedMessage, @"#.+"))
            {
                modifiedMessage = Util.ConvertChannelMentions(modifiedMessage, discord.Client);
            }

            // Attempt to convert any role/user mentions
            if (Regex.IsMatch(modifiedMessage, @"@.+"))
            {
                modifiedMessage = Util.ConvertRoleUserMentions(modifiedMessage, discord.Client);
            }

            if (Config.LogChat)
            {
                Util.Log($"{TShock.Players[args.Who].Name} said: {modifiedMessage}", Util.Severity.Info);
            }
            discord.Send($"**<{TShock.Players[args.Who].Name}>** {modifiedMessage}");
        }
Ejemplo n.º 17
0
        private void OnChat(ServerChatEventArgs args)
        {
            TSPlayer player = TShock.Players[args.Who];

            if (player == null)
            {
                return;
            }

            //Check if the provided text matches any of the defined regexes
            Regex regex = Regexes.Keys.FirstOrDefault(r => r.IsMatch(args.Text));

            if (regex == null)
            {
                return;
            }

            Match match = regex.Match(args.Text);

            int ID = EmoteBubble.AssignNewID();

            if (!String.IsNullOrEmpty(match.Groups["spoken"].Value))
            {
                args.Handled = true;
            }

            NetMessage.SendData(91, -1, -1, NetworkText.Empty, ID, 1, args.Who, 600, Regexes[regex].EmoteID);
        }
Ejemplo n.º 18
0
        void JoinedChannel(object sender, ServerChatEventArgs e)
        {
            chat.AddChat(new ChatNode("Joined Channel: ", CssClasses.JoiningChannel), new ChatNode(e.Text, CssClasses.ChannelName));
            ChannelFlags flags = (ChannelFlags)e.Flags;

            if ((flags & ChannelFlags.SilentChannel) == ChannelFlags.SilentChannel)
            {
                chat.AddChat(new ChatNode("This is a silent channel.", CssClasses.SilentChannel));
            }

            ThreadStart ts = delegate
            {
                this.Text    = string.Format(CultureInfo.CurrentCulture, "Chat Channel: {0}", e.Text);
                this.TabText = this.Text;
            };

            if (InvokeRequired)
            {
                BeginInvoke(ts);
            }
            else
            {
                ts();
            }
        }
Ejemplo n.º 19
0
 void InformationReceived(object sender, ServerChatEventArgs e)
 {
     if (!string.IsNullOrEmpty(e.Text))
     {
         chat.AddChat(new ChatNode("[Server]: ", CssClasses.ServerInfo), new ChatNode(e.Text, CssClasses.ServerInfo));
     }
 }
Ejemplo n.º 20
0
 void Client_ChannelWasFull(object sender, ServerChatEventArgs e)
 {
     if (__channelWasFull != null)
     {
         __channelWasFull.Call(_host.ClientHost, ConvObj(e));
     }
 }
Ejemplo n.º 21
0
        public void OnChat(ServerChatEventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(e.Text))
            {
                var    msg    = e.Buffer;
                var    text   = e.Text;
                var    AFKPly = Players[e.Who];
                string cmd    = text.Split(' ')[0];

                if (AFKConfig.afkwarp || AFKConfig.afkkick)
                {
                    if (cmd == "/afktime")
                    {
                        return;
                    }

                    else if ((cmd != "/afk" && cmd != "/return") && AFKPly.backtileX != 0 && AFKConfig.afkwarp)
                    {
                        if (AFKPly.TSPlayer.Teleport(AFKPly.backtileX * 16, AFKPly.backtileY * 16))
                        {
                            AFKPly.TSPlayer.SendSuccessMessage("You have been warped back to where you were!");
                            TShock.Utils.Broadcast(AFKConfig.returnMessage.Replace("{player}", AFKPly.TSPlayer.Name), Color.Yellow);
                            AFKPly.backtileX = 0;
                            AFKPly.backtileY = 0;
                        }
                    }

                    AFKPly.afk     = 0;
                    AFKPly.afkkick = 0;
                }
            }
        }
Ejemplo n.º 22
0
 private void OnChat(ServerChatEventArgs args)
 {
     if (members.Any(p => p.IsValidMember && p.Index == args.Who) && args.Text.Equals(responseString, StringComparison.OrdinalIgnoreCase))
     {
         responded    = true;
         args.Handled = true;
     }
 }
Ejemplo n.º 23
0
 static void Client_JoinedChannel(object sender, ServerChatEventArgs args)
 {
     PrintTidTs(DateTime.Now);
     console.OutputForegroundColor = ConsoleColor.Gray;
     console.Write("Joining channel ");
     console.OutputForegroundColor = ConsoleColor.White;
     console.WriteLine(args.Text);
 }
Ejemplo n.º 24
0
        private void onChat(ServerChatEventArgs e)
        {
            string msg = e.Text;

            var ply = TShock.Players[e.Who];

            if (ply == null)
            {
                return;
            }

            msg = msg.ToLower();

            if (Config.QuestionsAndAnswers.Any(x => msg.Contains(x.Question.ToLower()) == true))
            {
                var answer = Config.QuestionsAndAnswers.Find(x => msg.Contains(x.Question.ToLower()) == true).Answer;

                var colorarr = Config.BotColor.Split(',');
                try
                {
                    byte r = Byte.Parse(colorarr[0]);
                    byte g = Byte.Parse(colorarr[1]);
                    byte b = Byte.Parse(colorarr[2]);
                    TShockAPI.Utils.Instance.Broadcast(string.Format("{0}: {1}", Config.BotName, answer), r, g, b);
                }
                catch (FormatException exc)
                {
                    TShock.Log.ConsoleError("[Helperbot] Error parsing the BotColor to a byte, are you sure it is in this format \"255,255,255\"?");
                    TShock.Log.ConsoleError(exc.StackTrace);
                }
            }
            else if (msg.Contains("how much is"))
            {
                int    index = msg.LastIndexOf('s');
                string op    = msg.Substring(index + 1);
                op = op.Replace("?", "");

                try
                {
                    var    colorarr = Config.BotColor.Split(',');
                    double result   = Convert.ToDouble(new DataTable().Compute(op, null));
                    byte   r        = Byte.Parse(colorarr[0]);
                    byte   g        = Byte.Parse(colorarr[1]);
                    byte   b        = Byte.Parse(colorarr[2]);
                    TShockAPI.Utils.Instance.Broadcast(string.Format("{0}: {1}", Config.BotName,
                                                                     "The result is: " + result.ToString()), r, g, b);
                }
                catch (System.Data.EvaluateException)
                {
                    // invalid operation
                }
                catch (FormatException a)
                {
                    TShock.Log.ConsoleError("[Helperbot] Error parsing the BotColor to a byte, are you sure it is in this format \"255,255,255\"?");
                    TShock.Log.ConsoleError(a.StackTrace);
                }
            }
        }
Ejemplo n.º 25
0
        public void OnChat(ServerChatEventArgs e)
        {
            var Start = DateTime.Now;
            var msg   = e.Buffer;
            var ply   = e.Who;
            var tsplr = TShock.Players[e.Who];
            var text  = e.Text;

            if (e.Handled)
            {
                return;
            }

            if (text.StartsWith("/grow"))
            {
                if (!tsplr.Group.HasPermission(Permissions.grow))
                {
                    return;
                }
                var I = Houses.Count;

                for (int i = 0; i < I; i++)
                {
                    if (!HTools.OwnsHouse(tsplr.User, Houses[i]) && Houses[i].HouseArea.Intersects(new Rectangle(tsplr.TileX, tsplr.TileY, 1, 1)))
                    {
                        e.Handled = true;
                        tsplr.SendErrorMessage("You can't build here!");
                        return;
                    }
                }
                return;
            }

            if (HConfig.HouseChatEnabled)
            {
                if (text[0] == '/')
                {
                    return;
                }

                var I = HousingDistricts.Houses.Count;
                for (int i = 0; i < I; i++)
                {
                    if (Timeout(Start))
                    {
                        return;
                    }
                    House house;
                    try { house = HousingDistricts.Houses[i]; }
                    catch { continue; }
                    if (house.ChatEnabled == 1 && house.HouseArea.Intersects(new Rectangle(tsplr.TileX, tsplr.TileY, 1, 1)))
                    {
                        HTools.BroadcastToHouse(house, text, tsplr.Name);
                        e.Handled = true;
                    }
                }
            }
        }
Ejemplo n.º 26
0
        public void OnChat(ServerChatEventArgs args)
        {
            var player = Players[args.Who];

            if (player.IdleTime > 0)
            {
                player.IdleTime = 0;
            }
        }
Ejemplo n.º 27
0
        void IChatConnectionEventSource.OnBroadcast(ServerChatEventArgs args)
        {
            var tmp = Broadcast;

            if (tmp != null)
            {
                tmp(this, args);
            }
        }
Ejemplo n.º 28
0
        void IChatConnectionEventSource.OnServerError(ServerChatEventArgs args)
        {
            var tmp = ServerError;

            if (tmp != null)
            {
                tmp(this, args);
            }
        }
Ejemplo n.º 29
0
        void IChatConnectionEventSource.OnServerInformation(ServerChatEventArgs args)
        {
            var tmp = ServerInformation;

            if (tmp != null)
            {
                tmp(this, args);
            }
        }
Ejemplo n.º 30
0
 void InformationReceived(object sender, ServerChatEventArgs e)
 {
     if (!string.IsNullOrEmpty(e.Text))
     {
         PostEvent(new ClientEvent {
             EventType = ClientEventType.InformationReceived, EventData = e
         });
     }
 }
Ejemplo n.º 31
0
 public void OnChannelWasRestricted(ServerChatEventArgs e)
 {
     m_host.OnChannelWasRestricted(e);
 }
Ejemplo n.º 32
0
 private void HandleServerChatEvent(ServerChatEventArgs scArgs)
 {
     switch (scArgs.EventType)
     {
         case ChatEventType.Broadcast:
             OnServerBroadcast(scArgs);
             break;
         case ChatEventType.ChannelDNE:
             OnChannelDidNotExist(scArgs);
             break;
         case ChatEventType.ChannelFull:
             OnChannelWasFull(scArgs);
             break;
         case ChatEventType.ChannelRestricted:
             OnChannelWasRestricted(scArgs);
             break;
         case ChatEventType.Error:
             OnServerErrorReceived(scArgs);
             break;
         case ChatEventType.Information:
             OnInformationReceived(scArgs);
             break;
     }
 }
Ejemplo n.º 33
0
 public void OnChannelWasFull(ServerChatEventArgs e)
 {
     m_host.OnChannelWasFull(e);
 }
Ejemplo n.º 34
0
 public void OnServerErrorReceived(ServerChatEventArgs e)
 {
     m_host.OnServerErrorReceived(e);
 }
Ejemplo n.º 35
0
 public void OnChannelDidNotExist(ServerChatEventArgs e)
 {
     m_host.OnChannelDidNotExist(e);
 }
Ejemplo n.º 36
0
 public void OnJoinedChannel(ServerChatEventArgs e)
 {
     m_host.OnJoinedChannel(e);
 }
Ejemplo n.º 37
0
 public void OnServerBroadcast(ServerChatEventArgs e)
 {
     m_host.OnServerBroadcast(e);
 }
Ejemplo n.º 38
0
        private void HandleChatEvent(ParseData data)
        {
            DataReader dr = new DataReader(data.Data);
            ChatEventType type = (ChatEventType)dr.ReadInt32();
            int flags = dr.ReadInt32();
            int ping = dr.ReadInt32();
            dr.Seek(12);
            string user = dr.ReadCString();
            byte[] userInfo = dr.ReadNullTerminatedByteArray();
            string text = Encoding.ASCII.GetString(userInfo);

            switch (type)
            {
                case ChatEventType.UserInChannel:
                case ChatEventType.UserJoinedChannel:
                    ChatUser newUser = new ChatUser(user, ping, (UserFlags)flags, UserStats.Parse(user, userInfo));
                    if (m_namesToUsers.ContainsKey(user))
                    {
                        m_namesToUsers.Remove(user);
                    }
                    m_namesToUsers.Add(user, newUser);
                    UserEventArgs uArgs = new UserEventArgs(type, newUser);
                    HandleUserChatEvent(uArgs);
                    break;
                case ChatEventType.UserFlagsChanged:
                    if (m_namesToUsers.ContainsKey(user))
                    {
                        ChatUser changedUser = m_namesToUsers[user];
                        changedUser.Flags = (UserFlags)flags;
                        UserEventArgs updatedArgs = new UserEventArgs(type, changedUser);
                        HandleUserChatEvent(updatedArgs);
                    }
                    else if (m_channelName.Equals("The Void", StringComparison.OrdinalIgnoreCase))
                    {
                        ChatUser voidUser = new ChatUser(user, ping, (UserFlags)flags, UserStats.Parse(user, userInfo));
                        m_namesToUsers.Add(user, voidUser);
                        UserEventArgs voidArgs = new UserEventArgs(type, voidUser);
                        HandleUserChatEvent(voidArgs);
                    }
                    break;
                case ChatEventType.UserLeftChannel:
                    if (m_namesToUsers.ContainsKey(user))
                    {
                        ChatUser goneUser = m_namesToUsers[user];
                        UserEventArgs leftArgs = new UserEventArgs(type, goneUser);
                        HandleUserChatEvent(leftArgs);
                    }
                    break;
                case ChatEventType.Emote:
                case ChatEventType.Talk:
                case ChatEventType.WhisperReceived:
                case ChatEventType.WhisperSent:
                    ChatMessageEventArgs cmArgs = new ChatMessageEventArgs(type, (UserFlags)flags, user, Encoding.UTF8.GetString(userInfo));
                    HandleChatMessageEvent(cmArgs);
                    break;
                case ChatEventType.NewChannelJoined:
                    ServerChatEventArgs joinArgs = new ServerChatEventArgs(type, flags, text);
                    m_channelName = text;
                    m_namesToUsers.Clear();
                    OnJoinedChannel(joinArgs);
                    break;
                case ChatEventType.Broadcast:
                case ChatEventType.ChannelDNE:
                case ChatEventType.ChannelFull:
                case ChatEventType.ChannelRestricted: 
                case ChatEventType.Error:
                case ChatEventType.Information:
                    ServerChatEventArgs scArgs = new ServerChatEventArgs(type, flags, text);
                    HandleServerChatEvent(scArgs);
                    break;
            }

            BattleNetClientResources.IncomingBufferPool.FreeBuffer(data.Data);
        }
Ejemplo n.º 39
0
 public void OnInformationReceived(ServerChatEventArgs e)
 {
     m_host.OnInformationReceived(e);
 }