Exemplo n.º 1
0
        public void SendPrivateTo(string name)
        {
            string content = account.FloodContent;

            if (account.IsRandomingSmileyBox.Checked == true)
            {
                content = AddRandomSmiley(content);
            }
            if (account.IsRandomingNumberBox.Checked == true)
            {
                content = AddRandomNumber(content);
            }
            using (BigEndianWriter writer = new BigEndianWriter())
            {
                ChatClientPrivateMessage msg = new ChatClientPrivateMessage(content, name);
                msg.Serialize(writer);
                writer.Content = account.HumanCheck.hash_function(writer.Content);
                MessagePackaging pack = new MessagePackaging(writer);
                pack.Pack((int)msg.ProtocolID);
                account.SocketManager.Send(pack.Writer.Content);
                account.Log(new PrivateTextInformation("à " + name + " : " + content), 1);
                if (account.DebugMode.Checked)
                {
                    account.Log(new BotTextInformation("[SND] 851 (ChatClientPrivateMessage)"), 0);
                }
            }
        }
Exemplo n.º 2
0
        public static void HandleChatClientPrivateMessage(Client client, ChatClientPrivateMessage message)
        {
            Client targetClient = Server.Clients.FirstOrDefault(target => target.Character.Name == message.receiver);

            if (targetClient != null && targetClient != client)
            {
                targetClient.Send(new ChatServerMessage(9, message.content, Functions.ReturnUnixTimeStamp(DateTime.Now), "", client.Character.Id, client.Character.Name));
            }
        }
        public void SendPrivateMessage(string receiver, string content)
        {
            var message = new ChatClientPrivateMessage(); //on créer une instance du packet à envoyer

            message.Receiver = receiver;
            message.Content  = content;
            _dofusAccount.DofusBotManager.Send(message, FriendlyBot.API.Enums.SocketTarget.Server); //on l'envois au serveur
            //PS : Si vous utilisez SimpleAPI, envoyé le packet via MessageAPI.SendMessage();
            //Cette fonction va vérifié que vous être dans les bonnes conditions avant d'envoyé le packet (par exemple, il faut être en combat avant de lancé un sort, ...)
        }
Exemplo n.º 4
0
 public BotChatMessageClient(ChatClientPrivateMessage message)
 {
     if (message == null)
     {
         throw new ArgumentNullException("message");
     }
     Content      = message.content;
     ReceiverName = message.receiver;
     Channel      = ChatActivableChannelsEnum.PSEUDO_CHANNEL_PRIVATE;
 }
Exemplo n.º 5
0
        public static void HandleChatClientPrivateMessage(GameClient client, ChatClientPrivateMessage message)
        {
            GameClient targetClient = GameServer.Clients.FirstOrDefault(target => target.Character.Name == message.receiver);

            if (targetClient != null && targetClient != client)
            {
                client.Send(new ChatServerCopyMessage(9, message.content, Functions.ReturnUnixTimeStamp(DateTime.Now), "", targetClient.Character.Id, targetClient.Character.Name));
                SendChatServerMessage(targetClient, 9, message.content, client.Character.Id, client.Character.Name);
            }
            else
            {
                BasicHandler.SendTextInformationMessage(client, TextInformationTypeEnum.TEXT_INFORMATION_ERROR, 211, new string[0]);
            }
        }
Exemplo n.º 6
0
        public static void ChatClientPrivate(ChatClientPrivateMessage message, WorldClient client)
        {
            if (message.receiver == client.Character.Name)
            {
                client.Character.OnChatError(ChatErrorEnum.CHAT_ERROR_INTERIOR_MONOLOGUE);
                return;
            }

            WorldClient target = WorldServer.Instance.GetOnlineClient(message.receiver);

            if (target != null)
            {
                target.Send(ChatChannels.GetChatServerMessage(ChatActivableChannelsEnum.PSEUDO_CHANNEL_PRIVATE, message.content, client));
                client.Send(ChatChannels.GetChatServerCopyMessage(ChatActivableChannelsEnum.PSEUDO_CHANNEL_PRIVATE, message.content, client, target));
            }
            else
            {
                client.Character.OnChatError(ChatErrorEnum.CHAT_ERROR_RECEIVER_NOT_FOUND);
            }
        }
Exemplo n.º 7
0
 public void SendPrivateTo(string name, string content)
 {
     if (mods.Contains(name))
     {
         account.Log(new ErrorTextInformation("[Flood] Annulation de l'envoi d'un message privé à " + name + " (Modo)"), 0);
         return;
     }
     using (BigEndianWriter writer = new BigEndianWriter())
     {
         ChatClientPrivateMessage msg = new ChatClientPrivateMessage(content, name);
         msg.Serialize(writer);
         writer.Content = account.HumanCheck.hash_function(writer.Content);
         MessagePackaging pack = new MessagePackaging(writer);
         pack.Pack((int)msg.MessageID);
         account.SocketManager.Send(pack.Writer.Content);
         account.Log(new PrivateTextInformation("à " + name + " : " + content), 1);
         if (account.DebugMode.Checked)
         {
             account.Log(new DebugTextInformation("[SND] 851 (ChatClientPrivateMessage)"), 0);
         }
     }
 }
Exemplo n.º 8
0
        public static void ChatClientPrivate(ChatClientPrivateMessage message, WorldClient client)
        {
            if (message.receiver == client.Character.Record.Name)
            {
                return;
            }
            var target = WorldServer.Instance.GetOnlineClient(message.receiver);

            if (target != null)
            {
                if (target.Character.PlayerStatus.statusId == (sbyte)PlayerStatusEnum.PLAYER_STATUS_PRIVATE)
                {
                    client.Character.ReplyImportant(target.Character.Record.Name + " est actuellement en mode privé");
                    return;
                }
                else if (target.Character.PlayerStatus.statusId == (sbyte)PlayerStatusEnum.PLAYER_STATUS_SOLO)
                {
                    client.Character.ReplyImportant(target.Character.Record.Name + " est actuellement en mode solo");
                    return;
                }
                target.Send(new ChatServerMessage((sbyte)ChatActivableChannelsEnum.PSEUDO_CHANNEL_PRIVATE, message.content, 1, client.Character.Record.Name, client.Character.Id, client.Character.Record.Name, client.Account.Id));
                client.Send(new ChatServerCopyMessage((sbyte)ChatActivableChannelsEnum.PSEUDO_CHANNEL_PRIVATE, message.content, 1, client.Character.Record.Name, (uint)target.Character.Record.Id, target.Character.Record.Name));
                if (target.Character.PlayerStatus.statusId == (sbyte)PlayerStatusEnum.PLAYER_STATUS_AFK)
                {
                    client.Character.ReplyImportant(target.Character.Record.Name + " est asbent");

                    /*if(target.Character.AFKMessage != null)
                     * {
                     *  client.Send(new ChatServerCopyMessage((sbyte)ChatActivableChannelsEnum.PSEUDO_CHANNEL_PRIVATE, target.Character.AFKMessage, 1, client.Character.Record.Name, (uint)target.Character.Record.Id, target.Character.Record.Name));
                     * }*/
                }
            }
            else
            {
                client.Character.Reply("Le personnage n'éxiste pas ou n'est pas connecté");
            }
        }
Exemplo n.º 9
0
        private void HandleSendChatMessage()
        {
            if (_account.Character.Status == CharacterStatus.Disconnected)
            {
                return;
            }
            if (string.IsNullOrWhiteSpace(ChatTextBox.Text))
            {
                Logger.Default.Log("Vous ne pouvez pas envoyer un texte vide.", LogMessageType.Public);
            }
            else
            {
                _chatHistory.Add(ChatTextBox.Text);
                Logger.Default.Log(ChatTextBox.Text, LogMessageType.Command);
                if (ChatTextBox.Text.Length > 2 && ChatTextBox.Text[0] == '.')
                {
                    var txt = ChatTextBox.Text.Substring(1);
                    try
                    {
                        CommandManager.ParseAndCall(_account, txt);
                    }
                    catch (Exception e)
                    {
                        Logger.Default.Log(e.Message);
                        Logger.Default.Log("Commande Incorrecte ou qui a échouée.", LogMessageType.Public);
                    }

                    ChatTextBox.BeginInvoke(new Action(() => ChatTextBox.Text = ""));
                    return;
                }


                if (ChatTextBox.Text.Length < 2)
                {
                    var ccmm = new ChatClientMultiMessage
                    {
                        Channel = (sbyte)ChatChannelsMultiEnum.CHANNEL_GLOBAL,
                        Content = ChatTextBox.Text
                    };

                    _account.Network.SendToServer(ccmm);
                }
                else
                {
                    var txt     = ChatTextBox.Text.Substring(0, 2);
                    var chattxt = ChatTextBox.Text.Replace(txt, "");
                    if (txt == "/w")
                    {
                        string[] receiver      = chattxt.Split(new char[] { ' ' }, 2, StringSplitOptions.RemoveEmptyEntries);
                        var      messagePacket = new ChatClientPrivateMessage(receiver[0])
                        {
                            Content = receiver[1]
                        };
                        _account.Network.SendToServer(messagePacket);
                    }
                    else
                    {
                        var ccmm = new ChatClientMultiMessage
                        {
                            Channel = (sbyte)ChatChannelsMultiEnum.CHANNEL_GLOBAL,
                            Content = chattxt
                        };

                        switch (txt)
                        {
                        case "/g":
                            if (string.IsNullOrWhiteSpace(chattxt))
                            {
                                ccmm.Channel = (sbyte)ChatChannelsMultiEnum.CHANNEL_GUILD;
                            }
                            break;

                        case "/s":
                            if (string.IsNullOrWhiteSpace(chattxt))
                            {
                                ccmm.Channel = (sbyte)ChatChannelsMultiEnum.CHANNEL_GLOBAL;
                            }
                            break;

                        case "/t":
                            if (string.IsNullOrWhiteSpace(chattxt))
                            {
                                ccmm.Channel = (sbyte)ChatChannelsMultiEnum.CHANNEL_TEAM;
                            }
                            break;

                        case "/a":
                            if (string.IsNullOrWhiteSpace(chattxt))
                            {
                                ccmm.Channel = (sbyte)ChatChannelsMultiEnum.CHANNEL_ALLIANCE;
                            }
                            break;

                        case "/p":
                            if (string.IsNullOrWhiteSpace(chattxt))
                            {
                                ccmm.Channel = (sbyte)ChatChannelsMultiEnum.CHANNEL_PARTY;
                            }
                            break;

                        case "/k":
                            if (string.IsNullOrWhiteSpace(chattxt))
                            {
                                ccmm.Channel = (sbyte)ChatChannelsMultiEnum.CHANNEL_ARENA;
                            }
                            break;

                        case "/b":
                            if (string.IsNullOrWhiteSpace(chattxt))
                            {
                                ccmm.Channel = (sbyte)ChatChannelsMultiEnum.CHANNEL_SALES;
                            }
                            break;

                        case "/r":
                            if (string.IsNullOrWhiteSpace(chattxt))
                            {
                                ccmm.Channel = (sbyte)ChatChannelsMultiEnum.CHANNEL_SEEK;
                            }
                            break;

                        default:
                            ccmm.Channel = (sbyte)ChatChannelsMultiEnum.CHANNEL_GLOBAL;
                            ccmm.Content = txt + chattxt;
                            break;
                        }
                        _account.Network.SendToServer(ccmm);
                        ChatTextBox.BeginInvoke(new Action(() => ChatTextBox.Text = ""));
                    }
                }
            }
        }
Exemplo n.º 10
0
 public static void HandleChatClientPrivateMessage(Bot bot, ChatClientPrivateMessage message)
 {
     bot.SendLocal(new BotChatMessageClient(message));
 }
Exemplo n.º 11
0
        public void SendPrivateMessage(string message, string target)
        {
            ChatClientPrivateMessage ccpm = new ChatClientPrivateMessage(message, target);

            bot.Network.Send(ccpm);
        }
Exemplo n.º 12
0
        public static void HandleChatClientPrivateMessage(WorldClient client, ChatClientPrivateMessage message)
        {
            if (string.IsNullOrEmpty(message.content))
            {
                return;
            }

            var sender   = client.Character;
            var receiver = World.Instance.GetCharacter(message.receiver);

            if (receiver == null)
            {
                SendChatErrorMessage(client, ChatErrorEnum.CHAT_ERROR_RECEIVER_NOT_FOUND);
                return;
            }

            if (sender.IsMuted())
            {
                //Le principe de précaution vous a rendu muet pour %1 seconde(s).
                client.Character.SendInformationMessage(TextInformationTypeEnum.TEXT_INFORMATION_ERROR, 123, (int)client.Character.GetMuteRemainingTime().TotalSeconds);
                return;
            }

            if (receiver.IsMuted())
            {
                //Message automatique : Le joueur <b>%1</b> a été rendu muet pour ne pas avoir respecté les règles. <b>%1</b> ne pourra pas vous répondre avant <b>%2</b> minutes.
                sender.SendInformationMessage(TextInformationTypeEnum.TEXT_INFORMATION_MESSAGE, 168, receiver.Name, (int)receiver.GetMuteRemainingTime().TotalMinutes);
                return;
            }

            if (sender == receiver)
            {
                //Le joueur %1 était absent et n'a donc pas reçu votre message.
                SendChatErrorMessage(client, ChatErrorEnum.CHAT_ERROR_INTERIOR_MONOLOGUE);
                return;
            }

            var badword = ChatManager.Instance.CanSendMessage(message.content);

            if (badword != string.Empty)
            {
                client.Character.SendServerMessage($"Message non envoyé. Le terme <b>{badword}</b> est interdit sur le serveur !");
                return;
            }

            if (receiver.FriendsBook.IsIgnored(sender.Account.Id))
            {
                //Le joueur %1 était absent et n'a donc pas reçu votre message.
                sender.SendInformationMessage(TextInformationTypeEnum.TEXT_INFORMATION_ERROR, 14, receiver.Name);
                return;
            }

            if (!receiver.IsAvailable(sender, true))
            {
                //Le joueur %1 était absent et n'a donc pas reçu votre message.
                sender.SendInformationMessage(TextInformationTypeEnum.TEXT_INFORMATION_ERROR, 14, receiver.Name);
                return;
            }

            if (sender.Status.statusId != (sbyte)PlayerStatusEnum.PLAYER_STATUS_AVAILABLE &&
                sender.Status.statusId != (sbyte)PlayerStatusEnum.PLAYER_STATUS_PRIVATE || !sender.FriendsBook.IsFriend(receiver.Account.Id))
            {
                sender.SetStatus(PlayerStatusEnum.PLAYER_STATUS_AVAILABLE);
            }

            var document = new BsonDocument
            {
                { "SenderId", sender.Id },
                { "SenderName", sender.Name },
                { "SenderAccountId", sender.Account.Id },
                { "ReceiverId", receiver.Id },
                { "ReceiverName", receiver.Name },
                { "ReceiverAccountId", receiver.Account.Id },
                { "Message", message.content },
                { "Channel", (int)ChatActivableChannelsEnum.PSEUDO_CHANNEL_PRIVATE },
                { "Date", DateTime.Now.ToString(CultureInfo.InvariantCulture) }
            };

            MongoLogger.Instance.Insert("Chats", document);

            //Send to receiver
            SendChatServerMessage(receiver.Client, sender, ChatActivableChannelsEnum.PSEUDO_CHANNEL_PRIVATE, message.content);
            //Send a copy to sender
            SendChatServerCopyMessage(client, sender, receiver, ChatActivableChannelsEnum.PSEUDO_CHANNEL_PRIVATE, message.content);

            if (receiver.Status.statusId == (sbyte)PlayerStatusEnum.PLAYER_STATUS_AFK && receiver.Status is PlayerStatusExtended)
            {
                SendChatServerMessage(sender.Client, receiver, ChatActivableChannelsEnum.PSEUDO_CHANNEL_PRIVATE, $"Réponse automatique:{((PlayerStatusExtended)receiver.Status).message}");
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Say a message in the specified canal.
        /// </summary>
        /// <returns>The result.</returns>
        private List <string> Say()
        {
            char   canal   = char.Parse(GetParamValue("-c"));
            string message = GetParamValue("-m").Replace('/', ' ');
            string dest    = GetParamValue("-dest");

            try
            {
                if (canal == 'w' && dest != "null")
                {
                    using (BigEndianWriter writer = new BigEndianWriter())
                    {
                        ChatClientPrivateMessage msg = new ChatClientPrivateMessage(message, dest);
                        msg.Serialize(writer);
                        writer.Content = account.HumanCheck.hash_function(writer.Content);
                        MessagePackaging pack = new MessagePackaging(writer);
                        pack.Pack((int)msg.MessageID);
                        account.SocketManager.Send(pack.Writer.Content);
                        result.Add("à " + dest + " : " + message + "\n");
                        if (account.DebugMode.Checked)
                        {
                            account.Log(new DebugTextInformation("[SND] 851 (ChatClientPrivateMessage)"), 0);
                        }
                    }
                }
                else
                {
                    switch (canal)
                    {
                    case 'g':
                        account.Flood.SendMessage(2, message);
                        result.Add("Message envoyé. \n");
                        break;

                    case 'r':
                        account.Flood.SendMessage(6, message);
                        result.Add("Message envoyé. \n");
                        break;

                    case 'b':
                        account.Flood.SendMessage(5, message);
                        result.Add("Message envoyé. \n");
                        break;

                    case 'a':
                        account.Flood.SendMessage(3, message);
                        result.Add("Message envoyé. \n");
                        break;

                    case 's':
                        account.Flood.SendMessage(0, message);
                        result.Add("Message envoyé. \n");
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                result.Add("[ERROR] " + ex.Message + "\n");
                return(result);
            }
            if (!(result.Count > 0))
            {
                return(Usage("say"));
            }
            else
            {
                return(result);
            }
        }
Exemplo n.º 14
0
        public static void HandleChatClientPrivateMessage(WorldClient client, ChatClientPrivateMessage message)
        {
            if (!string.IsNullOrEmpty(message.content))
            {
                Character character = Singleton <World> .Instance.GetCharacter(message.receiver);

                if (character != null)
                {
                    if (client.Character.IsMuted())
                    {
                        client.Character.SendInformationMessage(TextInformationTypeEnum.TEXT_INFORMATION_ERROR, 123, new object[]
                        {
                            (int)client.Character.GetMuteRemainingTime().TotalSeconds
                        });
                    }
                    else
                    {
                        if (client.Character != character)
                        {
                            if (!character.IsAway)
                            {
                                if (client.Character.IsAway)
                                {
                                    client.Character.SendInformationMessage(TextInformationTypeEnum.TEXT_INFORMATION_MESSAGE, 72, new object[0]);
                                }
                                ChatHandler.SendChatServerCopyMessage(client, character, character, ChatActivableChannelsEnum.PSEUDO_CHANNEL_PRIVATE, message.content);
                                ChatHandler.SendChatServerMessage(character.Client, client.Character, ChatActivableChannelsEnum.PSEUDO_CHANNEL_PRIVATE, message.content);
                                BsonDocument document = new BsonDocument
                                {
                                    {
                                        "SenderId",
                                        client.Character.Id
                                    },

                                    {
                                        "ReceiverId",
                                        character.Id
                                    },

                                    {
                                        "Message",
                                        message.content
                                    },

                                    {
                                        "Date",
                                        System.DateTime.Now.ToString(System.Globalization.CultureInfo.InvariantCulture)
                                    }
                                };
                                Singleton <MongoLogger> .Instance.Insert("PrivateMSG", document);
                            }
                            else
                            {
                                client.Character.SendInformationMessage(TextInformationTypeEnum.TEXT_INFORMATION_ERROR, 14, new object[]
                                {
                                    character.Name
                                });
                            }
                        }
                        else
                        {
                            ChatHandler.SendChatErrorMessage(client, ChatErrorEnum.CHAT_ERROR_INTERIOR_MONOLOGUE);
                        }
                    }
                }
                else
                {
                    ChatHandler.SendChatErrorMessage(client, ChatErrorEnum.CHAT_ERROR_RECEIVER_NOT_FOUND);
                }
            }
        }
Exemplo n.º 15
0
 private void ChatClientPrivateMessageHandler(DofusClient client, ChatClientPrivateMessage message)
 {
     //
 }