Ejemplo n.º 1
0
        void MyPlugin_PreReceiveMessageHandler(object sender, MythBox.Model.Plugin.SDK.Events.MessagePreArgs e)
        {
            if (e.Message.identifier != 0x2EE2)
            {
                return;
            }

            try
            {
                using (JumpStreamReader sr = new JumpStreamReader(e.Message.readerData))
                {
                    byte unknownA    = sr.ReadByte();
                    byte messageType = sr.ReadByte();

                    if (messageType != 0x12)
                    {
                        return;
                    }

                    sr.ReadBytes(11);   //ignore unknown

                    string playerName = sr.ReadString();

                    byte unknownB = sr.ReadByte();
                    byte unknownC = sr.ReadByte();

                    string chatText = sr.ReadString();

                    lock (logWriter)
                    {
                        try
                        {
                            logWriter.WriteLine(DateTime.Now.ToString() + ":      " + chatText);
                            logWriter.Flush();
                        }
                        catch
                        {
                        }
                    }

                    foreach (string match in matchList)
                    {
                        if (IsMatch(chatText, match) == true)
                        {
                            e.Cancel  = true;
                            e.Blocked = true;
                            return;
                        }
                    }
                }
            }
            catch
            {
            }
        }
Ejemplo n.º 2
0
        void MyPlugin_PreSendMessageHandler(object sender, MythBox.Model.Plugin.SDK.Events.MessagePreArgs e)
        {
            if (e.Message.identifier == 0x2EE2)
            {
                try
                {
                    using (JumpStreamReader sr = new JumpStreamReader(e.Message.readerData))
                    {
                        byte unknownA    = sr.ReadByte();
                        byte messageType = sr.ReadByte();

                        byte[] fillByteA    = sr.ReadBytes(8); //ignore unknown
                        string targetPlayer = sr.ReadString();
                        string playerName   = sr.ReadString();

                        byte unknownB = sr.ReadByte();
                        byte unknownC = sr.ReadByte();

                        string chatText = sr.ReadString();
                        byte[] endBytes = sr.ReadBytes(12);

                        using (JumpStreamWriter sw = new JumpStreamWriter(e.Message.magic, e.Message.identifier))
                        {
                            sw.Write(unknownA);
                            sw.Write(messageType);
                            sw.Write(fillByteA);
                            sw.Write(targetPlayer);
                            sw.Write(playerName);

                            sw.Write(unknownB);
                            sw.Write(unknownC);

                            sw.Write(@"[color=" + chatColor + @"]" + chatText);
                            sw.Write(endBytes);

                            byte[] sb = sw.GetBuffer();
                            e.result = sb;
                        }
                    }
                }
                catch
                {
                }
            }
        }