public static void PrivateSending(IClient client, IClient target, PMEventArgs e)
        {
            PrivateMsg pm = new PrivateMsg(e.Text);

            if (DefaultCommands)
            {
                cmds.PrivateSending(client != null ? client.IUser : null, target != null ? target.IUser : null, pm);
            }

            if (!String.IsNullOrEmpty(pm.Text))
            {
                js.PrivateSending(client != null ? client.IUser : null, target != null ? target.IUser : null, pm);
            }

            if (!String.IsNullOrEmpty(pm.Text))
            {
                ExtensionManager.Plugins.ForEach(x =>
                {
                    try
                    {
                        x.Plugin.PrivateSending(client != null ? client.IUser : null, target != null ? target.IUser : null, pm);

                        if (String.IsNullOrEmpty(pm.Text) || pm.Cancel)
                        {
                            return;
                        }
                    }
                    catch { }
                });
            }

            String result = pm.Text;

            if (String.IsNullOrEmpty(result))
            {
                e.Cancel = true;
            }
            else if (!client.Connected || !target.Connected)
            {
                e.Cancel = true;
            }
            else if (pm.Cancel)
            {
                e.Cancel = true;
            }
            else
            {
                e.Text = result;
            }
        }
示例#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);
                    }
                }
            }
        }
示例#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));
                    }
                }
            }
        }