private static void VCFirstTo(AresClient client, TCPPacketReader packet)
        {
            if (Settings.Get <bool>("voice"))
            {
                String     name   = packet.ReadString(client);
                AresClient target = UserPool.AUsers.Find(x => x.Name == name);
                byte[]     data   = packet;

                if (target != null)
                {
                    if (!target.VoiceChatIgnoreList.Contains(client.Name) && !target.IgnoreList.Contains(client.Name))
                    {
                        if (target.VoiceChatPrivate)
                        {
                            target.SendPacket(TCPOutbound.VoiceChatFirstTo(target, client.Name, data));
                        }
                        else
                        {
                            client.SendPacket(TCPOutbound.VoiceChatNoPrivate(client, name));
                        }
                    }
                    else
                    {
                        client.SendPacket(TCPOutbound.VoiceChatIgnored(client, name));
                    }
                }
                else
                {
                    client.SendPacket(TCPOutbound.OfflineUser(client, name));
                }
            }
        }
Ejemplo n.º 2
0
        private static void Private(AresClient client, TCPPacketReader packet)
        {
            String name = packet.ReadString(client);
            String text = packet.ReadString(client);

            if (text.Length > 300)
            {
                text = text.Substring(0, 300);
            }

            PMEventArgs args = new PMEventArgs {
                Cancel = false, Text = text
            };

            if (name == Settings.Get <String>("bot"))
            {
                if (text.StartsWith("#login") || text.StartsWith("#register"))
                {
                    Command(client, text.Substring(1));
                    return;
                }
                else
                {
                    if (text.StartsWith("#") || text.StartsWith("/"))
                    {
                        Command(client, text.Substring(1));
                    }

                    if (!client.Quarantined)
                    {
                        Events.BotPrivateSent(client, args.Text);
                    }
                }
            }
            else
            {
                if (!client.Captcha)
                {
                    return;
                }

                IClient target = UserPool.AUsers.Find(x => x.Name == name && x.LoggedIn);

                if (target == null)
                {
                    target = UserPool.WUsers.Find(x => x.Name == name && x.LoggedIn);
                }

                if (target == null && ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
                {
                    target = ServerCore.Linker.FindUser(x => x.Name == name);

                    if (target != null)
                    {
                        ServerCore.Linker.SendPacket(LinkLeaf.LeafOutbound.LeafPrivateText(ServerCore.Linker, client.Name, target, text));
                        return;
                    }
                }

                if (target == null)
                {
                    client.SendPacket(TCPOutbound.OfflineUser(client, name));
                }
                else if (target.IgnoreList.Contains(client.Name) || client.Muzzled)
                {
                    client.SendPacket(TCPOutbound.IsIgnoringYou(client, name));
                }
                else
                {
                    if (target.Cloaked)
                    {
                        client.SendPacket(TCPOutbound.OfflineUser(client, name));
                        return;
                    }

                    Events.PrivateSending(client, target, args);

                    if (!args.Cancel && !String.IsNullOrEmpty(args.Text) && client.SocketConnected)
                    {
                        target.IUser.PM(client.Name, args.Text);
                        Events.PrivateSent(client, target, args.Text);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private static void CustomData(AresClient client, TCPPacketReader packet)
        {
            if (client.Quarantined || !client.Captcha)
            {
                return;
            }

            String ident = packet.ReadString(client);
            String name  = packet.ReadString(client);

            byte[]     data   = packet;
            AresClient target = UserPool.AUsers.Find(x => x.Name == name && x.LoggedIn && x.CustomClient);

            if (ident == "cb0t_pm_msg")
            {
                if (target != null)
                {
                    if (target.IgnoreList.Contains(client.Name) || client.Muzzled)
                    {
                        client.SendPacket(TCPOutbound.IsIgnoringYou(client, name));
                    }
                    else
                    {
                        if (target.Cloaked)
                        {
                            client.SendPacket(TCPOutbound.OfflineUser(client, name));
                            return;
                        }

                        PMEventArgs args = new PMEventArgs {
                            Cancel = false, Text = "          "
                        };
                        Events.PrivateSending(client, target, args);

                        if (!args.Cancel && client.SocketConnected)
                        {
                            target.SendPacket(TCPOutbound.CustomData(target, client.Name, ident, data));
                            Events.PrivateSent(client, target, args.Text);
                        }
                    }
                }
                else
                {
                    client.SendPacket(TCPOutbound.OfflineUser(client, name));
                }
            }
            else if (ident == "cb0t_scribble_once" && target != null)
            {
                if (!Events.CanPrivateMessage(client, target) || !Events.CanScribble(client, true))
                {
                    return;
                }

                PMEventArgs args = new PMEventArgs {
                    Cancel = false, Text = "", IsScribble = true
                };
                Events.PrivateSending(client, target, args);

                if (args.Cancel || !client.SocketConnected)
                {
                    return;
                }

                if (target.IgnoreList.Contains(client.Name))
                {
                    return;
                }

                target.SendPacket(TCPOutbound.CustomData(target, client.Name, ident, data));
                Events.PrivateSent(client, target, args.Text);
            }
            else
            {
                if (target != null)
                {
                    if (!target.IgnoreList.Contains(client.Name))
                    {
                        target.SendPacket(TCPOutbound.CustomData(target, client.Name, ident, data));
                    }
                }
                else if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
                {
                    IClient linked = ServerCore.Linker.FindUser(x => x.Name == name && x.CustomClient);

                    if (linked != null)
                    {
                        ServerCore.Linker.SendPacket(LinkLeaf.LeafOutbound.LeafCustomDataTo(ServerCore.Linker,
                                                                                            linked.IUser.Link.Ident,
                                                                                            client.Name, linked.Name,
                                                                                            ident, data));
                    }
                }
            }
        }