Пример #1
0
 void _chat_SystemMessageEvent(Vha.Net.Chat chat, SystemMessageEventArgs e)
 {
     // Descramble message
     MDB.Message message = null;
     try { message = MDB.Parser.Decode((int)e.CategoryID, (int)e.MessageID, e.Arguments, null); }
     catch (Exception ex)
     {
         this.Write(MessageClass.Error, "Error while decoding message: " + ex.Message);
     }
     // Apply ignore filter to "received offline message from" messages
     if (e.MessageID == (uint)SystemMessageType.IncommingOfflineMessage)
     {
         string character = message.Arguments[(int)IncomingOfflineMessageArgs.Name].ToString();
         // Check ignored characters list
         if (this.Ignores.Contains(character))
         {
             return;
         }
     }
     // Failed to get the entry
     if (message == null || string.IsNullOrEmpty(message.Value))
     {
         this.Write(MessageClass.Error, "Unknown system message " + e.CategoryID + ":" + e.MessageID);
         return;
     }
     // Dispatch message
     this.Write(MessageClass.SystemMessage, message.Value);
 }
Пример #2
0
        void _chat_ChannelMessageEvent(Vha.Net.Chat chat, ChannelMessageEventArgs e)
        {
            Channel channel = this.GetChannel(e.Channel);

            // Check if channel is muted
            if (channel != null && (channel.Flags & ChannelFlags.Muted) != 0)
            {
                return;
            }
            // Check for ignores
            if (this.Ignores.Contains(e.Character))
            {
                return;
            }
            // Descramble
            string message = e.Message;

            if (e.Message.StartsWith("~"))
            {
                MDB.Message parsedMessage = null;
                try { parsedMessage = MDB.Parser.Decode(e.Message); }
                catch (Exception) { } // Errors are fine here, if it's not a valid message, we'll display the original
                if (parsedMessage != null && !string.IsNullOrEmpty(parsedMessage.Value))
                {
                    message = parsedMessage.Value;
                }
            }
            // Dispatch message
            MessageSource source = new MessageSource(MessageType.Channel, e.Channel, e.Character, e.Character == this.Character);

            this.Write(source, this.GetChannelClass(e.Channel), message);
        }