예제 #1
0
파일: McpeText.cs 프로젝트: oas/MiNET
        public string message;        // = null;

        partial void AfterEncode()
        {
            Write(false);
            ChatTypes chatType = (ChatTypes)type;

            switch (chatType)
            {
            case ChatTypes.Chat:
            case ChatTypes.Whisper:
            case ChatTypes.Announcement:
                Write(source);
                Write("");                         //TODO: third party name
                WriteSignedVarInt(0);              //TODO: platform
                goto case ChatTypes.Raw;

            case ChatTypes.Raw:
            case ChatTypes.Tip:
            case ChatTypes.System:
                Write(message);
                break;

            case ChatTypes.Popup:
            case ChatTypes.Translation:
            case ChatTypes.Jukeboxpopup:
                Write(message);
                WriteUnsignedVarInt(0);                         //TODO: translation parameters (list of strings)
                break;
            }

            Write("");             //TODO: XUID
            Write("");             //TODO: platform chat ID
        }
예제 #2
0
 public void UnsetUnique(IEnumerable <XivChatType> types)
 {
     foreach (var xivChatType in types)
     {
         ChatTypes.Remove(xivChatType);
     }
 }
예제 #3
0
        partial void AfterEncode()
        {
            //Write(islocalized);
            ChatTypes chatType = (ChatTypes)type;

            switch (chatType)
            {
            case ChatTypes.Chat:
            case ChatTypes.Whisper:
            case ChatTypes.Announcement:
                Write(source);
                Write(message);
                break;

            case ChatTypes.Raw:
            case ChatTypes.Tip:
            case ChatTypes.System:
                Write(message);
                break;

            case ChatTypes.Popup:
            case ChatTypes.Translation:
            case ChatTypes.JukeboxPopup:
                Write(message);
                WriteVarInt(parameters.Length);
                foreach (var p in parameters)
                {
                    Write(p);
                }
                break;
            }
            Write(xuid);
        }
예제 #4
0
        public static ChatlineColor GetColor(ChatTypes chatType)
        {
            switch (chatType)
            {
            case ChatTypes.Shout:
                return(ChatlineColor.Green);

            case ChatTypes.Alert:
                return(ChatlineColor.OrangeRed);

            case ChatTypes.Error:
                return(ChatlineColor.Red);

            case ChatTypes.Radio:
                return(ChatlineColor.Pink);

            case ChatTypes.Notification:
                return(ChatlineColor.Magenta);



            case ChatTypes.None:
                return(ChatlineColor.White);

            default:
            {
                ConsoleManager.WriteLine("Warning: GetColor not implemented for " + chatType.ToString());
                return(ChatlineColor.White);
            }
            }
        }
예제 #5
0
        partial void AfterDecode()
        {
            ReadBool();             // localization

            ChatTypes chatType = (ChatTypes)type;

            switch (chatType)
            {
            case ChatTypes.Chat:
            case ChatTypes.Whisper:
            case ChatTypes.Announcement:
                source  = ReadString();
                message = ReadString();
                break;

            case ChatTypes.Raw:
            case ChatTypes.Tip:
            case ChatTypes.System:
                message = ReadString();
                break;

            case ChatTypes.Popup:
            case ChatTypes.Translation:
            case ChatTypes.Jukeboxpopup:
                message = ReadString();
                // More stuff
                break;
            }
        }
예제 #6
0
        public string message;        // = null;

        partial void AfterEncode()
        {
            Write(false);
            ChatTypes chatType = (ChatTypes)type;

            switch (chatType)
            {
            case ChatTypes.Chat:
            case ChatTypes.Whisper:
            case ChatTypes.Announcement:
                Write(source);
                Write(message);
                break;

            case ChatTypes.Raw:
            case ChatTypes.Tip:
            case ChatTypes.System:
                Write(message);
                break;

            case ChatTypes.Popup:
            case ChatTypes.Translation:
            case ChatTypes.Jukeboxpopup:
                Write(message);
                // More stuff
                break;
            }
        }
예제 #7
0
파일: McpeText.cs 프로젝트: yesdog/MiNET
        partial void AfterDecode()
        {
            needsTranslation = ReadBool();

            ChatTypes chatType = (ChatTypes)type;

            switch (chatType)
            {
            case ChatTypes.Chat:
            case ChatTypes.Whisper:
            case ChatTypes.Announcement:
                source = ReadString();
                goto case ChatTypes.Raw;

            case ChatTypes.Raw:
            case ChatTypes.Tip:
            case ChatTypes.System:
                message = ReadString();
                break;

            case ChatTypes.Popup:
            case ChatTypes.Translation:
            case ChatTypes.Jukeboxpopup:
                message    = ReadString();
                parameters = new string[ReadUnsignedVarInt()];
                for (var i = 0; i < parameters.Length; ++i)
                {
                    parameters[i] = ReadString();
                }
                break;
            }

            xuid           = ReadString();
            platformChatId = ReadString();
        }
예제 #8
0
        // Sends chat message packet to server
        public void SendChatMessage(string text, ChatTypes chatType, params string[] customParams)
        {
            if (chatType == ChatTypes.AutoSelect)
            {
                chatType = Chat.ActiveChat;
            }

            Chat.SendChatMessage(text, chatType, customParams);
        }
예제 #9
0
 // Sets active chat
 public void SetActiveChat(ChatTypes chatType)
 {
     ActiveChat = chatType;
     clientGame.Invoke(() =>
     {
         clientGame.MainWindow.ChatActiveLabel.Content    = chatType;
         clientGame.MainWindow.ChatActiveLabel.Foreground = GetChatColor(chatType);
     });
 }
예제 #10
0
 public void SetUnique(IEnumerable <XivChatType> types)
 {
     foreach (var xivChatType in types)
     {
         if (!ChatTypes.Contains(xivChatType))
         {
             ChatTypes.Add(xivChatType);
         }
     }
 }
예제 #11
0
        public GameMessageIn(GameServerPacket packet)
        {
            BinaryReader br = new BinaryReader(new MemoryStream(packet.Data));

            ChatType      = (ChatTypes)br.ReadByte();
            UnknownA      = br.ReadByte();
            EntityType    = br.ReadByte();
            EntityID      = br.ReadUInt32();
            UnknownB      = br.ReadByte();
            UnknownC      = br.ReadByte();
            CharacterName = Util.ReadSpecialString(br);
            Message       = Util.ReadSpecialString(br);;
        }
예제 #12
0
        public static ChatPayloadPrefix CreateChatPayload(ChatTypes chatTypes)
        {
            Type classType;

            if (ChatPayloadFromType.TryGetValue(chatTypes, out classType))
            {
                ChatPayloadPrefix result = (ChatPayloadPrefix)Activator.CreateInstance(classType);
                result.Magic = ChatPayloadPrefix.PayloadMagic;
                result.Type  = 0;
                return(result);
            }

            return(null);
        }
예제 #13
0
        /// <summary>
        /// Returns if message can be split
        /// </summary>
        /// <param name="chatType">ChatType to check</param>
        /// <returns>If Splitable</returns>
        private bool IsSplitable(ChatTypes chatType)
        {
            // If a player wrote the message, our line-split character should be included in the message
            switch (chatType)
            {
            case ChatTypes.Radio:
            case ChatTypes.Shout:
            case ChatTypes.tell:
            case ChatTypes.hug:
            case ChatTypes.admins:
                return(false);

            default:
                return(true);
            }
        }
예제 #14
0
        public IBotServerConfiguration GetServerConfig(ulong id, ChatTypes chatType, string name = "")
        {
            var result = GuildConfigs.FirstOrDefault(x => x.Id == id && (x.ChatType ?? ChatTypes.Discord) == chatType);

            if (result == null)
            {
                result = new ServerConfiguration()
                {
                    Id       = id,
                    ChatType = chatType,
                    Name     = name
                };
                GuildConfigs.Add(result);
            }
            result.ChatType = chatType;
            return(result);
        }
예제 #15
0
        // Sends chat message to server
        public void SendChatMessage(string text, ChatTypes chatType, params string[] customParams)
        {
            if (string.IsNullOrWhiteSpace(text))
            {
                return;
            }

            var packet = new Packet(CMSGPackets.CMSG_CHAT_MESSAGE);

            packet.Write((byte)chatType);
            packet.Write(text.Trim());
            foreach (var p in customParams)
            {
                packet.Write(p);
            }

            clientGame.SendPacket(packet);
        }
예제 #16
0
        public string[] parameters;   // = null

        partial void AfterEncode()
        {
            Write(needsTranslation);
            ChatTypes chatType = (ChatTypes)type;

            switch (chatType)
            {
            case ChatTypes.Chat:
            case ChatTypes.Whisper:
            case ChatTypes.Announcement:
                Write(source);
                goto case ChatTypes.Raw;

            case ChatTypes.Raw:
            case ChatTypes.Tip:
            case ChatTypes.System:
            case ChatTypes.Json:
                Write(message);
                break;

            case ChatTypes.Popup:
            case ChatTypes.Translation:
            case ChatTypes.Jukeboxpopup:
                Write(message);
                if (parameters == null)
                {
                    WriteUnsignedVarInt(0);
                }
                else
                {
                    WriteUnsignedVarInt((uint)parameters.Length);
                    foreach (var parameter in parameters)
                    {
                        Write(parameter);
                    }
                }
                break;
            }

            Write(xuid);
            Write(platformChatId);
        }
예제 #17
0
        /// <summary>
        /// Returns a color for the prefix, based on the chat type.
        /// </summary>
        /// <param name="chatType">Chat Type Enum</param>
        /// <returns>Color to Draw</returns>
        private Color GetPrefixColor(ChatTypes chatType)
        {
            //Console.WriteLine("Value " + chatType);
            switch (chatType)
            {
            case ChatTypes.Radio:
                return(Color.MediumPurple);

            case ChatTypes.tell:
                return(Color.LightBlue);

            case ChatTypes.hug:
                return(Color.MediumSpringGreen);

            case ChatTypes.Shout:
                return(Color.LimeGreen);

            case ChatTypes.admin:
                return(Color.HotPink);

            case ChatTypes.admins:
                return(Color.HotPink);

            case ChatTypes.help:
                return(Color.Yellow);

            case ChatTypes.warp:
                return(Color.Turquoise);

            case ChatTypes.whosonline:
                return(Color.SteelBlue);

            case ChatTypes.login:
                return(Color.MediumTurquoise);

            case ChatTypes.Alert:
                return(Color.OrangeRed);

            default:
                return(Color.White);
            }
        }
예제 #18
0
        // Returns chat color
        private Brush GetChatColor(ChatTypes chatType)
        {
            switch (chatType)
            {
            case ChatTypes.Game:
                return(Brushes.Blue);

            case ChatTypes.Global:
                return(Brushes.Green);

            case ChatTypes.Whisper:
            case ChatTypes.WhisperResponse:
                return(Brushes.Purple);

            case ChatTypes.Info:
                return(Brushes.Orange);

            default:
                return(Brushes.Black);
            }
        }
예제 #19
0
파일: McpeText.cs 프로젝트: oas/MiNET
        partial void AfterDecode()
        {
            ReadBool();             // localization

            ChatTypes chatType = (ChatTypes)type;

            switch (chatType)
            {
            case ChatTypes.Chat:
            case ChatTypes.Whisper:
            case ChatTypes.Announcement:
                source = ReadString();
                ReadString();                         //TODO: third party name
                ReadSignedVarInt();                   //TODO: platform
                goto case ChatTypes.Raw;

            case ChatTypes.Raw:
            case ChatTypes.Tip:
            case ChatTypes.System:
                message = ReadString();
                break;

            case ChatTypes.Popup:
            case ChatTypes.Translation:
            case ChatTypes.Jukeboxpopup:
                message = ReadString();
                uint parameterCount = ReadUnsignedVarInt();
                for (uint i = 0; i < parameterCount; ++i)
                {
                    ReadString();                             //TODO: translation parameters
                }
                // More stuff
                break;
            }

            ReadString();             //TODO: XUID
            ReadString();             //TODO: platform chat ID
        }
예제 #20
0
        partial void AfterDecode()
        {
            //ReadBool(); // localization

            ChatTypes chatType = (ChatTypes)type;

            switch (chatType)
            {
            case ChatTypes.Chat:
            case ChatTypes.Whisper:
            case ChatTypes.Announcement:
                source  = ReadString();
                message = ReadString();
                break;

            case ChatTypes.Raw:
            case ChatTypes.Tip:
            case ChatTypes.System:
                message = ReadString();
                break;

            case ChatTypes.Popup:
            case ChatTypes.Translation:
            case ChatTypes.JukeboxPopup:
                message = ReadString();
                int count = ReadVarInt();
                parameters = new string[count];
                for (int i = 0; i < parameters.Length; i++)
                {
                    parameters[i] = ReadString();
                }
                // More stuff
                break;
            }

            xuid = ReadString();
        }
예제 #21
0
 // Writes message as channel message into chat
 public void WriteChannelMessage(ChatTypes chatType, string message, string sender)
 {
     Write($"[{chatType.GetDescription()}] {sender}> {message}", chatType);
 }
예제 #22
0
 // Writes message into chat
 public void Write(string message, ChatTypes chatType)
 {
     InvokeToChat(message, clientGame.MainWindow.GeneralChatTab, GetChatColor(chatType));
 }
예제 #23
0
 public ChatHandler(ClientGame game)
 {
     clientGame = game;
     ActiveChat = ChatTypes.Global;
 }
 public IBotServerConfiguration GetServerConfig(ulong id, ChatTypes chatType, string name = "")
 {
     throw new NotImplementedException();
 }
예제 #25
0
        //public NetOutgoingMessage SerializeChatMessage(string chatJson)
        //{
        //    return SerializeChatMessage(chatJson, null);
        //}

        //public NetOutgoingMessage SerializeChatMessage(string chatJson, string metaJson)
        //{
        //    var data = CreateChatMessageContainer(chatJson, metaJson);

        //    var msg = _connectionManager.Server.CreateMessage();

        //    data.WriteToLidgrenMessage_ToClient(MessageTypes.ChatMessage, msg);

        //    return msg;
        //}

        /// <summary>
        /// Builds and a simple chat text and colors the prefix according to chatType
        /// </summary>
        /// <param name="prefix"></param>
        /// <param name="text"></param>
        /// <param name="chatType"></param>
        public void SendSimpleChat(Player p, string prefix, string text, ChatTypes chatType, ChatlineColor textColor = ChatlineColor.White)
        {
            var chat = new OutboundChatMessage(p, BuildChatLine(prefix, text, ChatHelpers.GetColor(chatType), textColor));

            SendChatToPlayer(chat);
        }
예제 #26
0
        /// <summary>
        /// Sends a simple chat message to all online players in the area except for the player with the corresponding playerIdToIgnore
        /// </summary>
        /// <param name="area"></param>
        /// <param name="prefix"></param>
        /// <param name="text"></param>
        /// <param name="chatType"></param>
        /// <param name="playerIdToIgnore"></param>
        public void BroadcastSimpleChat(IArea area, string prefix, string text, ChatTypes chatType, int?playerIdToIgnore = null)
        {
            var outboundList = area.BuildReplyAllChatList(playerIdToIgnore, BuildChatLine(prefix, text, ChatHelpers.GetColor(ChatTypes.Alert)));

            SendChatList(outboundList);
        }
예제 #27
0
        /// <summary>
        /// Сканировать входящий Telegram.Update
        /// </summary>
        public void UpdateNew()
        {
            if (IncUpdate is null)
            {
                return;
            }
            ScanSpamMatches  = new List <SpamMatch>();
            ChatAdmins       = new List <ChatMemberClass>();
            CompositionTypes = new List <TelegramDataTypes>();

            #region Определение типа чата
            ChatType = ChatTypes.Error;
            foreach (ChatTypes c in Enum.GetValues(typeof(ChatTypes)))
            {
                if (c.ToString("g").ToLower() == IncUpdate.message.chat.type.ToLower())
                {
                    ChatType = c;
                    break;
                }
            }
            #endregion

            ////////////////////////////////////////////////////////
            #region Если сообщение из группы или супергруппы, то определяем администраторов чата
            if ((ChatType == ChatTypes.Group || ChatType == ChatTypes.Supergroup) && ChatAdmins.Count == 0)
            {
                ChatMemberClass[] chat_admins = telegram_client.getChatAdministrators(IncUpdate.message.chat.id.ToString());
                if (!(chat_admins is null))
                {
                    ChatAdmins.AddRange(chat_admins.Where(x => !x.user.is_bot));
                }
            }
            #endregion

            #region Определение состава данных сообщения
            if (!(IncUpdate.message is null))
            {
                if (!string.IsNullOrEmpty(IncUpdate.message.text))
                {
                    CompositionTypes.Add(TelegramDataTypes.Text);
                    if (Regex.IsMatch(IncUpdate.message.text, @"^\s*\d{1,2}\.\d{1,6}\s*,\s*d{1,2}\.\d{1,6}\s*$"))
                    {
                        CompositionTypes.Add(TelegramDataTypes.LocationText);
                    }
                }
                if (!string.IsNullOrEmpty(IncUpdate.message.caption))
                {
                    CompositionTypes.Add(TelegramDataTypes.Caption);
                }

                if (!(IncUpdate.message.new_chat_members is null))
                {
                    CompositionTypes.Add(TelegramDataTypes.NewChatMembers);
                }

                if (!(IncUpdate.message.location is null))
                {
                    CompositionTypes.Add(TelegramDataTypes.Location);
                }

                if (!(IncUpdate.message.photo is null))
                {
                    CompositionTypes.Add(TelegramDataTypes.Photo);
                }

                if (!(IncUpdate.message.document is null))
                {
                    CompositionTypes.Add(TelegramDataTypes.Document);
                }

                if (!(IncUpdate.message.video is null))
                {
                    CompositionTypes.Add(TelegramDataTypes.Video);
                }
            }

            #endregion

            if (ChatType == ChatTypes.Private && !string.IsNullOrEmpty(IncUpdate.message.text))
            {
                TelegramCommand = new TelegramCommandClass(IncUpdate.message.text);
            }
            else
            if (ChatType == ChatTypes.Group || ChatType == ChatTypes.Supergroup)
            {
                #region Если это группа/чат
                Log.WriteLine("Сканирование сообщения на спам");

                SpamScanner scanMessage = new SpamScanner(this);
                ScanSpamMatches = scanMessage.scan_matches;
                #endregion
            }
        }
예제 #28
0
        public byte UnknownC; //(0x05 chat, 0x01 recv-wisp)

        #endregion Fields

        #region Constructors

        public GameMessageIn(GameServerPacket packet)
        {
            BinaryReader br = new BinaryReader(new MemoryStream(packet.Data));
            ChatType = (ChatTypes)br.ReadByte();
            UnknownA = br.ReadByte();
            EntityType = br.ReadByte();
            EntityID = br.ReadUInt32();
            UnknownB = br.ReadByte();
            UnknownC = br.ReadByte();
            CharacterName = Util.ReadSpecialString(br);
            Message = Util.ReadSpecialString(br); ;
        }