Beispiel #1
0
        public static byte[] PerMsgBotTo(ib0tClient userobj)
        {
            String name = Settings.Get <String>("bot");
            String text = Settings.VERSION;

            return(WebSockets.Html5TextPacket("PERSMSG:" + name.Length + "," + text.Length + ":" + name + text, userobj.WebCredentials.OldProto));
        }
Beispiel #2
0
 public static byte[] ScribbleHead(ib0tClient userobj, String sender, int count, String height)
 {
     return(WebSockets.Html5TextPacket("SCRIBBLE_HEAD:" + sender.Length + "," +
                                       count.ToString().Length + "," +
                                       height.Length +
                                       ":" + sender + count + height,
                                       userobj.WebCredentials.OldProto));
 }
        private static void Command(ib0tClient client, String args)
        {
            Command cmd = new Command {
                Text = args, Args = String.Empty
            };

            Helpers.PopulateCommand(cmd);
            Events.Command(client, args, cmd.Target, cmd.Args);
        }
Beispiel #4
0
        public static byte[] AvatarTo(ib0tClient userobj, String name, byte[] av)
        {
            String str   = "AVATAR:";
            String avstr = Convert.ToBase64String(av);

            str += name.Length + "," + avstr.Length + ":";
            str += name + avstr;
            byte[] packet = WebSockets.Html5TextPacket(str, userobj.WebCredentials.OldProto);
            return(packet);
        }
 internal static byte[] Server(ib0t.ib0tClient client)
 {
     if (server_avatar == null)
     {
         return(ib0t.WebOutbound.AvatarClearTo(client, Settings.Get <String>("bot")));
     }
     else
     {
         return(ib0t.WebOutbound.AvatarTo(client, Settings.Get <String>("bot"), server_avatar));
     }
 }
Beispiel #6
0
        public static byte[] EmoteTo(ib0tClient userobj, String name, String text)
        {
            String str = text;

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

            return(WebSockets.Html5TextPacket("EMOTE:" + name.Length + "," + str.Length + ":" + name + str, userobj.WebCredentials.OldProto));
        }
Beispiel #7
0
        public static byte[] NoSuchTo(ib0tClient userobj, String text)
        {
            String str = text;

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

            return(WebSockets.Html5TextPacket("NOSUCH:" + str.Length + ":" + str, userobj.WebCredentials.OldProto));
        }
        private static void Ignore(ib0tClient client, String args)
        {
            String tmp    = args;
            int    finder = tmp.IndexOf(":");

            String[] lens = tmp.Substring(0, finder).Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            tmp = tmp.Substring(finder + 1);
            int n_len = int.Parse(lens[0]);

            String name   = tmp.Substring(0, n_len);
            bool   ignore = int.Parse(tmp.Substring(tmp.Length - 1)) == 1;

            if (client.Quarantined)
            {
                return;
            }

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

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

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

            if (target != null)
            {
                if (!ignore)
                {
                    client.IgnoreList.RemoveAll(x => x == name);
                    Events.IgnoredStateChanged(client, target, ignore);
                }
                else if (Events.Ignoring(client, target))
                {
                    if (client.SocketConnected)
                    {
                        if (!client.IgnoreList.Contains(name))
                        {
                            client.IgnoreList.Add(name);
                        }

                        Events.IgnoredStateChanged(client, target, ignore);
                    }
                }
            }
        }
        private static void Login(ib0tClient client, String args, ulong time)
        {
            String[] arg_items = GetArgItems(args);

            client.Extended = int.Parse(arg_items[0]) >= 2000;

            byte[] g = new byte[16];

            for (int i = 0; i < g.Length; i++)
            {
                g[i] = byte.Parse(arg_items[1].Substring((i * 2), 2), NumberStyles.HexNumber);
            }

            using (MD5 md5 = MD5.Create())
                client.Guid = new Guid(md5.ComputeHash(g));

            client.OrgName = arg_items[2].Trim();
            Helpers.FormatUsername(client);
            client.Name         = client.OrgName;
            client.FastPing     = false;
            client.FileCount    = 0;
            client.DataPort     = 0;
            client.NodeIP       = IPAddress.Parse("0.0.0.0");
            client.NodePort     = 0;
            client.Version      = arg_items[4] + " [" + arg_items[3] + "]";
            client._pmsg        = arg_items[4];
            client.CustomClient = true;
            client.LocalIP      = client.ExternalIP;
            client.Browsable    = false;
            client.Age          = 0;
            client.Sex          = 0;
            client.Country      = 0;
            client.Region       = String.Empty;
            IPAddress p_check = new IPAddress(client.ExternalIP.GetAddressBytes());

            ObSalt.GetSalt(client);
            client.Captcha = !Settings.Get <bool>("captcha");

            if (!client.Captcha)
            {
                client.Captcha = CaptchaManager.HasCaptcha(client);
            }

            if ((UserPool.AUsers.FindAll(x => x.ExternalIP.Equals(client.ExternalIP)).Count +
                 UserPool.WUsers.FindAll(x => x.ExternalIP.Equals(client.ExternalIP)).Count) > 3)
            {
                Events.Rejected(client, RejectedMsg.TooManyClients);
                throw new Exception("too many clients from this ip");
            }

            if (UserHistory.IsJoinFlooding(client, time))
            {
                Events.Rejected(client, RejectedMsg.TooSoon);
                throw new Exception("joined too quickly");
            }

            IClient hijack = UserPool.AUsers.Find(x => (x.Name == client.Name ||
                                                        x.OrgName == client.OrgName) && x.ID != client.ID && x.LoggedIn);

            if (hijack == null)
            {
                hijack = UserPool.WUsers.Find(x => (x.Name == client.Name ||
                                                    x.OrgName == client.OrgName) && x.ID != client.ID && x.LoggedIn);
            }

            if (hijack != null)
            {
                if (hijack.ExternalIP.Equals(client.ExternalIP))
                {
                    if (!hijack.WebClient)
                    {
                        ((AresClient)hijack).Disconnect(true);
                    }
                    else
                    {
                        ((ib0t.ib0tClient)hijack).Disconnect();
                    }

                    client.Name = client.OrgName;
                }
                else
                {
                    Events.Rejected(client, RejectedMsg.NameInUse);
                    throw new Exception("name in use");
                }
            }

            UserHistory.AddUser(client, time);

            if (BanSystem.IsBanned(client))
            {
                if (!Helpers.IsLocalHost(client))
                {
                    if (hijack != null && hijack is AresClient)
                    {
                        ((AresClient)hijack).SendDepart();
                    }

                    Events.Rejected(client, RejectedMsg.Banned);
                    throw new Exception("banned user");
                }
            }

            if (Proxies.Check(p_check, client.DNS))
            {
                if (!Helpers.IsLocalHost(client))
                {
                    if (Events.ProxyDetected(client))
                    {
                        if (hijack != null && hijack is AresClient)
                        {
                            ((AresClient)hijack).SendDepart();
                        }

                        Events.Rejected(client, RejectedMsg.Proxy);
                        throw new Exception("proxy detected");
                    }
                }
            }

            client.Quarantined = !client.Captcha && Settings.Get <int>("captcha_mode") == 1;

            if (!Events.Joining(client))
            {
                if (!Helpers.IsLocalHost(client))
                {
                    if (hijack != null && hijack is AresClient)
                    {
                        ((AresClient)hijack).SendDepart();
                    }

                    Events.Rejected(client, RejectedMsg.UserDefined);
                    throw new Exception("user defined rejection");
                }
            }

            if (Helpers.IsLocalHost(client))
            {
                client.Captcha     = true;
                client.Quarantined = false;
                client.Registered  = true;
                client.Owner       = true;
            }

            if (!client.Quarantined)
            {
                if (hijack == null || !(hijack is AresClient))
                {
                    LinkLeaf.LinkUser other = null;

                    if (ServerCore.Linker.Busy)
                    {
                        foreach (LinkLeaf.Leaf leaf in ServerCore.Linker.Leaves)
                        {
                            other = leaf.Users.Find(x => x.Vroom == client.Vroom && x.Name == client.Name && x.Link.Visible);

                            if (other != null)
                            {
                                other.LinkCredentials.Visible = false;
                                break;
                            }
                        }
                    }

                    UserPool.AUsers.ForEachWhere(x => x.SendPacket(other == null ? TCPOutbound.Join(x, client) : TCPOutbound.UpdateUserStatus(x, client)),
                                                 x => x.LoggedIn && x.Vroom == client.Vroom && !x.Quarantined);

                    UserPool.WUsers.ForEachWhere(x => x.QueuePacket(other == null ? ib0t.WebOutbound.JoinTo(x, client.Name, client.Level) : ib0t.WebOutbound.UpdateTo(x, client.Name, client.Level)),
                                                 x => x.LoggedIn && x.Vroom == client.Vroom && !x.Quarantined);
                }

                client.LoggedIn = true;
                client.QueuePacket(WebOutbound.AckTo(client, client.Name));
                client.QueuePacket(WebOutbound.TopicFirstTo(client, Settings.Get <String>("topic")));
                client.QueuePacket(WebOutbound.UserlistItemTo(client, Settings.Get <String>("bot"), ILevel.Host));

                UserPool.AUsers.ForEachWhere(x => client.QueuePacket(WebOutbound.UserlistItemTo(client, x.Name, x.Level)),
                                             x => x.LoggedIn && x.Vroom == client.Vroom && !x.Quarantined);

                UserPool.WUsers.ForEachWhere(x => client.QueuePacket(WebOutbound.UserlistItemTo(client, x.Name, x.Level)),
                                             x => x.LoggedIn && x.Vroom == client.Vroom && !x.Quarantined);

                if (ServerCore.Linker.Busy)
                {
                    foreach (LinkLeaf.Leaf leaf in ServerCore.Linker.Leaves)
                    {
                        leaf.Users.ForEachWhere(x => client.QueuePacket(WebOutbound.UserlistItemTo(client, x.Name, x.Level)),
                                                x => x.Vroom == client.Vroom && x.Link.Visible);
                    }
                }

                client.QueuePacket(WebOutbound.UserlistEndTo(client));
                client.QueuePacket(WebOutbound.UrlTo(client, Settings.Get <String>("link", "url"), Settings.Get <String>("text", "url")));

                UserPool.AUsers.ForEachWhere(x => x.SendPacket(TCPOutbound.Avatar(x, client)),
                                             x => x.LoggedIn && x.Vroom == client.Vroom && !x.Quarantined);

                UserPool.WUsers.ForEachWhere(x => x.QueuePacket(WebOutbound.AvatarTo(x, client.Name, client.Avatar)),
                                             x => x.LoggedIn && x.Vroom == client.Vroom && !x.Quarantined && x.Extended);

                UserPool.AUsers.ForEachWhere(x => x.SendPacket(TCPOutbound.PersonalMessage(x, client)),
                                             x => x.LoggedIn && x.Vroom == client.Vroom && !x.Quarantined);

                UserPool.WUsers.ForEachWhere(x => x.QueuePacket(WebOutbound.PersMsgTo(x, client.Name, client.PersonalMessage)),
                                             x => x.LoggedIn && x.Vroom == client.Vroom && !x.Quarantined && x.Extended);

                if (client.Extended)
                {
                    client.QueuePacket(WebOutbound.PerMsgBotTo(client));

                    if (Avatars.GotServerAvatar)
                    {
                        client.QueuePacket(Avatars.Server(client));
                    }

                    UserPool.AUsers.ForEachWhere(x => client.QueuePacket(WebOutbound.AvatarTo(client, x.Name, x.Avatar)),
                                                 x => x.LoggedIn && x.Vroom == client.Vroom && x.Avatar.Length > 0 && !x.Quarantined);

                    UserPool.WUsers.ForEachWhere(x => client.QueuePacket(WebOutbound.AvatarTo(client, x.Name, x.Avatar)),
                                                 x => x.LoggedIn && x.Vroom == client.Vroom && !x.Quarantined);

                    if (ServerCore.Linker.Busy)
                    {
                        foreach (LinkLeaf.Leaf leaf in ServerCore.Linker.Leaves)
                        {
                            leaf.Users.ForEachWhere(x => client.QueuePacket(WebOutbound.AvatarTo(client, x.Name, x.Avatar)),
                                                    x => x.Vroom == client.Vroom && x.Link.Visible && x.Avatar.Length > 0);
                        }
                    }

                    UserPool.AUsers.ForEachWhere(x => client.QueuePacket(WebOutbound.PersMsgTo(client, x.Name, x.PersonalMessage)),
                                                 x => x.LoggedIn && x.Vroom == client.Vroom && x.PersonalMessage.Length > 0 && !x.Quarantined);

                    UserPool.WUsers.ForEachWhere(x => client.QueuePacket(WebOutbound.PersMsgTo(client, x.Name, x.PersonalMessage)),
                                                 x => x.LoggedIn && x.Vroom == client.Vroom && !x.Quarantined);

                    UserPool.AUsers.ForEachWhere(x =>
                    {
                        AresFont f = (AresFont)x.Font;
                        client.QueuePacket(WebOutbound.FontTo(client, x.Name, f.oldN, f.oldT));
                    }, x => x.LoggedIn && x.Vroom == client.Vroom && !x.Quarantined && x.Font.Enabled);

                    if (ServerCore.Linker.Busy)
                    {
                        foreach (LinkLeaf.Leaf leaf in ServerCore.Linker.Leaves)
                        {
                            leaf.Users.ForEachWhere(x => client.QueuePacket(WebOutbound.PersMsgTo(client, x.Name, x.PersonalMessage)),
                                                    x => x.Vroom == client.Vroom && x.Link.Visible && x.PersonalMessage.Length > 0);
                        }
                    }
                }

                FloodControl.Remove(client);

                if (client.SocketConnected)
                {
                    IdleManager.Set(client);
                }

                if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
                {
                    ServerCore.Linker.SendPacket(LinkLeaf.LeafOutbound.LeafJoin(ServerCore.Linker, client));
                }

                Events.Joined(client);

                if (client.Owner)
                {
                    client.Level = ILevel.Host;
                }
            }
            else
            {
                if (hijack != null && hijack is AresClient)
                {
                    ((AresClient)hijack).SendDepart();
                }

                client.LoggedIn = true;
                client.QueuePacket(WebOutbound.AckTo(client, client.Name));
                client.QueuePacket(WebOutbound.TopicFirstTo(client, Settings.Get <String>("topic")));
                client.QueuePacket(WebOutbound.UserlistEndTo(client));
                client.QueuePacket(WebOutbound.PerMsgBotTo(client));
                client.QueuePacket(Avatars.Server(client));

                CaptchaItem cap = Captcha.Create();
                client.CaptchaWord = cap.Word;
                Events.CaptchaSending(client);
                client.QueuePacket(WebOutbound.NoSuchTo(client, String.Empty));

                foreach (String str in cap.Lines)
                {
                    client.QueuePacket(WebOutbound.NoSuchTo(client, str));
                }

                client.QueuePacket(WebOutbound.NoSuchTo(client, String.Empty));
            }
        }
        private static void PM(ib0tClient client, String ags, ulong time)
        {
            String tmp    = ags;
            int    finder = tmp.IndexOf(":");

            String[] lens = tmp.Substring(0, finder).Split(new String[] { "," }, StringSplitOptions.RemoveEmptyEntries);
            tmp = tmp.Substring(finder + 1);
            int n_len = int.Parse(lens[0]);
            int t_len = int.Parse(lens[1]);

            String name = tmp.Substring(0, n_len);
            String text = tmp.Substring(n_len, t_len);

            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.QueuePacket(WebOutbound.OfflineTo(client, name));
                }
                else if (target.IgnoreList.Contains(client.Name) || client.Muzzled)
                {
                    client.QueuePacket(WebOutbound.IgnoringTo(client, name));
                }
                else
                {
                    if (target.Cloaked)
                    {
                        client.QueuePacket(WebOutbound.OfflineTo(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);
                    }
                }
            }
        }
Beispiel #11
0
 public static byte[] FontTo(ib0tClient userobj, String name, int col1, int col2)
 {
     return(WebSockets.Html5TextPacket("FONT:" + name.Length + "," + col1.ToString().Length + "," + col2.ToString().Length + ":" + name + col1.ToString() + col2.ToString(), userobj.WebCredentials.OldProto));
 }
 private static void Lag(ib0tClient client, String args)
 {
     client.QueuePacket(WebOutbound.LagTo(client, args));
 }
        private static void Emote(ib0tClient client, String args, ulong time)
        {
            if (!client.Captcha)
            {
                return;
            }

            String text = args;

            Events.EmoteReceived(client, text);

            if (client.SocketConnected)
            {
                text = Events.EmoteSending(client, text);

                if (!String.IsNullOrEmpty(text) && client.SocketConnected && !client.Muzzled)
                {
                    if (client.Idled)
                    {
                        uint seconds_away = (uint)((Time.Now - client.IdleStart) / 1000);
                        IdleManager.Remove(client);
                        Events.Unidled(client, seconds_away);
                    }

                    if (client.SocketConnected)
                    {
                        if (text.StartsWith("idles"))
                        {
                            if (!IdleManager.CheckIfCanIdle(client))
                            {
                                return;
                            }

                            IdleManager.Add(client);
                            Events.Idled(client);
                        }

                        if (client.SocketConnected)
                        {
                            byte[] js_style = null;

                            UserPool.AUsers.ForEachWhere(x =>
                            {
                                if (x.SupportsHTML)
                                {
                                    if (js_style != null)
                                    {
                                        x.SendPacket(js_style);
                                    }
                                }

                                x.SendPacket(TCPOutbound.Emote(x, client.Name, text));
                            }, x => x.LoggedIn && x.Vroom == client.Vroom && !x.IgnoreList.Contains(client.Name) && !x.Quarantined);

                            UserPool.WUsers.ForEachWhere(x => x.QueuePacket(ib0t.WebOutbound.EmoteTo(x, client.Name, text)),
                                                         x => x.LoggedIn && x.Vroom == client.Vroom && !x.IgnoreList.Contains(client.Name) && !x.Quarantined);

                            if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
                            {
                                ServerCore.Linker.SendPacket(LinkLeaf.LeafOutbound.LeafEmoteText(ServerCore.Linker, client.Name, text));
                            }

                            Events.EmoteSent(client, text);
                        }
                    }
                }
            }
        }
Beispiel #14
0
 public static byte[] LagTo(ib0tClient userobj, String args)
 {
     return(WebSockets.Html5TextPacket("LAG:" + args.Length + ":" + args, userobj.WebCredentials.OldProto));
 }
Beispiel #15
0
 public static byte[] PersMsgTo(ib0tClient userobj, String name, String text)
 {
     return(WebSockets.Html5TextPacket("PERSMSG:" + name.Length + "," + text.Length + ":" + name + text, userobj.WebCredentials.OldProto));
 }
Beispiel #16
0
 public static byte[] IgnoringTo(ib0tClient userobj, String name)
 {
     return(WebSockets.Html5TextPacket("IGNORING:" + name.Length + ":" + name, userobj.WebCredentials.OldProto));
 }
Beispiel #17
0
 public static byte[] OfflineTo(ib0tClient userobj, String name)
 {
     return(WebSockets.Html5TextPacket("OFFLINE:" + name.Length + ":" + name, userobj.WebCredentials.OldProto));
 }
Beispiel #18
0
 public static byte[] TopicFirstTo(ib0tClient userobj, String text)
 {
     return(WebSockets.Html5TextPacket("TOPIC_FIRST:" + text.Length + ":" + text, userobj.WebCredentials.OldProto));
 }
Beispiel #19
0
 public static byte[] UrlTo(ib0tClient userobj, String addr, String tag)
 {
     return(WebSockets.Html5TextPacket("URL:" + addr.Length + "," + tag.Length + ":" + addr + tag, userobj.WebCredentials.OldProto));
 }
        public static void Evaluate(ib0tClient client, String ident, String args, ulong time)
        {
            if (!client.LoggedIn && !ident.StartsWith("LOGIN"))
            {
                throw new Exception("unordered login routine");
            }

            if (client.LoggedIn && ident.StartsWith("LOGIN"))
            {
                return;
            }

            if (client.LoggedIn)
            {
                if (FloodControl.IsFlooding(client, ident, Encoding.UTF8.GetBytes(args), time))
                {
                    if (Events.Flooding(client, (byte)FloodControl.WebMsgToTCPMsg(ident)))
                    {
                        Events.Flooded(client);
                        client.Disconnect();
                        return;
                    }
                }
            }

            switch (ident)
            {
            case "LOGIN":
                Login(client, args, time);
                break;

            case "PUBLIC":
                Text(client, args, time);
                break;

            case "EMOTE":
                Emote(client, args, time);
                break;

            case "COMMAND":
                Command(client, args);
                break;

            case "PING":
                client.Time = time;
                break;

            case "PM":
                PM(client, args, time);
                break;

            case "IGNORE":
                Ignore(client, args);
                break;

            case "LAG":
                Lag(client, args);
                break;

            default:
                throw new Exception();
            }
        }
        private static void Text(ib0tClient client, String args, ulong time)
        {
            String text = args;

            if (text.StartsWith("#login") || text.StartsWith("#register"))
            {
                Command(client, text.Substring(1));
                return;
            }

            if (text.StartsWith("#") && client.SocketConnected)
            {
                Command(client, text.Substring(1));
            }

            if (client.SocketConnected)
            {
                if (!client.Captcha)
                {
                    if (String.IsNullOrEmpty(client.CaptchaWord) || (client.CaptchaWord.Length > 0 && client.CaptchaWord.ToUpper() != Helpers.StripColors(text).Trim().ToUpper()))
                    {
                        if (client.CaptchaWord.Length > 0 && client.CaptchaWord.ToUpper() != Helpers.StripColors(text).Trim().ToUpper())
                        {
                            Events.CaptchaReply(client, text);

                            if (!client.SocketConnected)
                            {
                                return;
                            }
                        }

                        CaptchaItem cap = Captcha.Create();
                        client.CaptchaWord = cap.Word;
                        Events.CaptchaSending(client);
                        client.QueuePacket(WebOutbound.NoSuchTo(client, String.Empty));

                        foreach (String str in cap.Lines)
                        {
                            client.QueuePacket(WebOutbound.NoSuchTo(client, str));
                        }

                        client.QueuePacket(WebOutbound.NoSuchTo(client, String.Empty));
                        return;
                    }
                    else
                    {
                        client.Captcha = true;
                        Events.CaptchaReply(client, text);
                        CaptchaManager.AddCaptcha(client);

                        if (client.Quarantined)
                        {
                            client.Unquarantine();
                        }

                        return;
                    }
                }
                else
                {
                    Events.TextReceived(client, text);
                }
            }
            else
            {
                return;
            }

            if (client.SocketConnected)
            {
                text = Events.TextSending(client, text);

                if (!String.IsNullOrEmpty(text) && client.SocketConnected && !client.Muzzled)
                {
                    if (client.Idled)
                    {
                        uint seconds_away = (uint)((Time.Now - client.IdleStart) / 1000);
                        IdleManager.Remove(client);
                        Events.Unidled(client, seconds_away);
                    }

                    if (client.SocketConnected)
                    {
                        byte[] js_style = null;

                        UserPool.AUsers.ForEachWhere(x =>
                        {
                            if (x.SupportsHTML)
                            {
                                if (String.IsNullOrEmpty(client.CustomName) || x.BlockCustomNames)
                                {
                                    if (x.SupportsHTML)
                                    {
                                        if (js_style != null)
                                        {
                                            x.SendPacket(js_style);
                                        }
                                    }

                                    x.SendPacket(TCPOutbound.Public(x, client.Name, text));
                                }
                                else
                                {
                                    if (x.SupportsHTML)
                                    {
                                        if (js_style != null)
                                        {
                                            x.SendPacket(js_style);
                                        }
                                    }

                                    x.SendPacket(TCPOutbound.NoSuch(x, client.CustomName + text));
                                }
                            }
                            else
                            {
                                if (String.IsNullOrEmpty(client.CustomName) || x.BlockCustomNames)
                                {
                                    x.SendPacket(TCPOutbound.Public(x, client.Name, text));
                                }
                                else
                                {
                                    x.SendPacket(TCPOutbound.NoSuch(x, client.CustomName + text));
                                }
                            }
                        }, x => x.LoggedIn && x.Vroom == client.Vroom && !x.IgnoreList.Contains(client.Name) && !x.Quarantined);

                        UserPool.WUsers.ForEachWhere(x => x.QueuePacket(String.IsNullOrEmpty(client.CustomName) ?
                                                                        ib0t.WebOutbound.PublicTo(x, client.Name, text) : ib0t.WebOutbound.NoSuchTo(x, client.CustomName + text)),
                                                     x => x.LoggedIn && x.Vroom == client.Vroom && !x.IgnoreList.Contains(client.Name) && !x.Quarantined);

                        if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
                        {
                            ServerCore.Linker.SendPacket(LinkLeaf.LeafOutbound.LeafPublicText(ServerCore.Linker, client.Name, text));
                        }

                        Events.TextSent(client, text);
                    }
                }
            }
        }
Beispiel #22
0
 public static byte[] UserlistEndTo(ib0tClient userobj)
 {
     return(WebSockets.Html5TextPacket("USERLIST_END:", userobj.WebCredentials.OldProto));
 }
Beispiel #23
0
 public static byte[] ScribbleBlock(ib0tClient userobj, String text)
 {
     return(WebSockets.Html5TextPacket("SCRIBBLE_BLOCK:" + text.Length + ":" + text, userobj.WebCredentials.OldProto));
 }
Beispiel #24
0
 public static byte[] AvatarClearTo(ib0tClient userobj, String name)
 {
     return(WebSockets.Html5TextPacket("AVATAR:" + name.Length + ":" + name, userobj.WebCredentials.OldProto));
 }
        public static void FakeRejoinSequence(ib0t.ib0tClient client, bool features)
        {
            if (!client.Cloaked)
            {
                LinkLeaf.LinkUser other = null;

                if (ServerCore.Linker.Busy)
                {
                    foreach (LinkLeaf.Leaf leaf in ServerCore.Linker.Leaves)
                    {
                        other = leaf.Users.Find(x => x.Vroom == client.Vroom && x.Name == client.Name && x.Link.Visible);

                        if (other != null)
                        {
                            other.LinkCredentials.Visible = false;
                            break;
                        }
                    }
                }

                UserPool.AUsers.ForEachWhere(x => x.SendPacket(other == null ? TCPOutbound.Join(x, client) : TCPOutbound.UpdateUserStatus(x, client)),
                                             x => x.LoggedIn && x.Vroom == client.Vroom && !x.Quarantined);

                UserPool.WUsers.ForEachWhere(x => x.QueuePacket(other == null ? ib0t.WebOutbound.JoinTo(x, client.Name, client.Level) : ib0t.WebOutbound.UpdateTo(x, client.Name, client.Level)),
                                             x => x.LoggedIn && x.Vroom == client.Vroom && !x.Quarantined);
            }

            client.LoggedIn = true;
            client.QueuePacket(WebOutbound.AckTo(client, client.Name));
            client.QueuePacket(WebOutbound.UserlistItemTo(client, Settings.Get <String>("bot"), ILevel.Host));

            UserPool.AUsers.ForEachWhere(x => client.QueuePacket(WebOutbound.UserlistItemTo(client, x.Name, x.Level)),
                                         x => x.LoggedIn && x.Vroom == client.Vroom && !x.Cloaked && !x.Quarantined);

            UserPool.WUsers.ForEachWhere(x => client.QueuePacket(WebOutbound.UserlistItemTo(client, x.Name, x.Level)),
                                         x => x.LoggedIn && x.Vroom == client.Vroom && !x.Cloaked && !x.Quarantined);

            UserPool.AUsers.ForEachWhere(x =>
            {
                AresFont f = (AresFont)x.Font;
                client.QueuePacket(ib0t.WebOutbound.FontTo(client, x.Name, f.oldN, f.oldT));
            }, x => x.LoggedIn && x.Vroom == client.Vroom && !x.Quarantined && x.Font.Enabled);

            if (ServerCore.Linker.Busy)
            {
                foreach (LinkLeaf.Leaf leaf in ServerCore.Linker.Leaves)
                {
                    leaf.Users.ForEachWhere(x => client.QueuePacket(WebOutbound.UserlistItemTo(client, x.Name, x.Level)),
                                            x => x.Vroom == client.Vroom && x.Link.Visible);
                }
            }

            client.QueuePacket(WebOutbound.UserlistEndTo(client));

            if (features)
            {
                client.QueuePacket(WebOutbound.UrlTo(client, Settings.Get <String>("link", "url"), Settings.Get <String>("text", "url")));
            }

            if (client.Extended)
            {
                client.QueuePacket(WebOutbound.PerMsgBotTo(client));
                client.QueuePacket(Avatars.Server(client));

                UserPool.AUsers.ForEachWhere(x => client.QueuePacket(WebOutbound.AvatarTo(client, x.Name, x.Avatar)),
                                             x => x.LoggedIn && x.Vroom == client.Vroom && x.Avatar.Length > 0 && !x.Cloaked && !x.Quarantined);

                UserPool.WUsers.ForEachWhere(x => client.QueuePacket(WebOutbound.AvatarTo(client, x.Name, x.Avatar)),
                                             x => x.LoggedIn && x.Vroom == client.Vroom && !x.Cloaked && !x.Quarantined);

                if (ServerCore.Linker.Busy)
                {
                    foreach (LinkLeaf.Leaf leaf in ServerCore.Linker.Leaves)
                    {
                        leaf.Users.ForEachWhere(x => client.QueuePacket(WebOutbound.AvatarTo(client, x.Name, x.Avatar)),
                                                x => x.Vroom == client.Vroom && x.Link.Visible && x.Avatar.Length > 0);
                    }
                }

                UserPool.AUsers.ForEachWhere(x => client.QueuePacket(WebOutbound.PersMsgTo(client, x.Name, x.PersonalMessage)),
                                             x => x.LoggedIn && x.Vroom == client.Vroom && x.PersonalMessage.Length > 0 && !x.Cloaked && !x.Quarantined);

                UserPool.WUsers.ForEachWhere(x => client.QueuePacket(WebOutbound.PersMsgTo(client, x.Name, x.PersonalMessage)),
                                             x => x.LoggedIn && x.Vroom == client.Vroom && !x.Cloaked && !x.Quarantined);

                if (ServerCore.Linker.Busy)
                {
                    foreach (LinkLeaf.Leaf leaf in ServerCore.Linker.Leaves)
                    {
                        leaf.Users.ForEachWhere(x => client.QueuePacket(WebOutbound.PersMsgTo(client, x.Name, x.PersonalMessage)),
                                                x => x.Vroom == client.Vroom && x.Link.Visible && x.PersonalMessage.Length > 0);
                    }
                }
            }

            if (client.Avatar.Length > 0)
            {
                if (!client.Cloaked)
                {
                    UserPool.AUsers.ForEachWhere(x => x.SendPacket(TCPOutbound.Avatar(x, client)),
                                                 x => x.LoggedIn && x.Vroom == client.Vroom && !x.Quarantined);

                    UserPool.WUsers.ForEachWhere(x => x.QueuePacket(WebOutbound.AvatarTo(x, client.Name, client.Avatar)),
                                                 x => x.LoggedIn && x.Vroom == client.Vroom && !x.Quarantined && x.Extended);

                    if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
                    {
                        ServerCore.Linker.SendPacket(LinkLeaf.LeafOutbound.LeafAvatar(ServerCore.Linker, client));
                    }
                }
            }

            if (!String.IsNullOrEmpty(client.PersonalMessage))
            {
                if (!client.Cloaked)
                {
                    UserPool.AUsers.ForEachWhere(x => x.SendPacket(TCPOutbound.PersonalMessage(x, client)),
                                                 x => x.LoggedIn && x.Vroom == client.Vroom && !x.Quarantined);

                    UserPool.WUsers.ForEachWhere(x => x.QueuePacket(WebOutbound.PersMsgTo(x, client.Name, client.PersonalMessage)),
                                                 x => x.LoggedIn && x.Vroom == client.Vroom && !x.Quarantined && x.Extended);

                    if (ServerCore.Linker.Busy && ServerCore.Linker.LoginPhase == LinkLeaf.LinkLogin.Ready)
                    {
                        ServerCore.Linker.SendPacket(LinkLeaf.LeafOutbound.LeafPersonalMessage(ServerCore.Linker, client));
                    }
                }
            }

            if (features)
            {
                if (client.SocketConnected)
                {
                    IdleManager.Set(client);
                }

                Events.Joined(client);
            }
        }
Beispiel #26
0
 public static byte[] JoinTo(ib0tClient userobj, String name, ILevel level)
 {
     return(WebSockets.Html5TextPacket("JOIN:" + name.Length + ",1:" + name + ((byte)level), userobj.WebCredentials.OldProto));
 }