private void Eval_UserlistItem(TCPPacketReader packet) { User u = new User(); ushort files = packet; packet.SkipBytes(4); u.ExternalIP = packet; u.Port = packet; packet.SkipBytes(4); u.SupportsPMEnc = ((ushort)packet) == 65535; packet.SkipByte(); u.Name = packet.ReadString(this.crypto); u.LocalIP = packet; u.HasFiles = ((byte)packet) == 1 && files > 0; u.Level = packet; u.Age = packet; u.Gender = packet; byte country = packet; u.Country = Helpers.CountryCodeToString(country); u.Region = packet.ReadString(this.crypto); if (packet.Remaining > 0) { ClientFeatures features = (ClientFeatures)((byte)packet); u.SupportsVC = ((features & ClientFeatures.CLIENT_SUPPORTS_VC) == ClientFeatures.CLIENT_SUPPORTS_VC); u.SupportsOpusVC = ((features & ClientFeatures.CLIENT_SUPPORTS_OPUS_VC) == ClientFeatures.CLIENT_SUPPORTS_OPUS_VC); if (u.SupportsOpusVC) { u.SupportsVC = true; } } u.IsFriend = Friends.IsFriend(u.Name); if (this.users.Find(x => x.Name == u.Name) != null) { return; } this.users.Add(u); this.Panel.Userlist.AddUserItem(u); Scripting.ScriptManager.AddUser(this.EndPoint, u); if (u.Name == this.MyName) { u.IsAway = Settings.IsAway; this.Panel.Userlist.MyLevel = u.Level; } }
public VoicePlayerInboundItem(TCPPacketReader packet, CryptoService c, IPEndPoint ep) { this.EndPoint = ep; this.Sender = packet.ReadString(c); this.Ident = packet; packet.SkipByte(); this.compression_count = packet; this.uncompressed_length = packet; for (int i = 0; i < this.compression_count; i++) { this.compressed_length = packet; } if (this.compressed_length == 0) { this.compressed_length = this.uncompressed_length; } this.is_opus = (this.compressed_length == this.uncompressed_length); this.data_in.AddRange(((byte[])packet)); }
private void Eval_Join(TCPPacketReader packet) { User u = new User(); ushort files = packet; packet.SkipBytes(4); u.ExternalIP = packet; u.Port = packet; packet.SkipBytes(4); u.SupportsPMEnc = ((ushort)packet) == 65535; packet.SkipByte(); u.Name = packet.ReadString(this.crypto); u.LocalIP = packet; u.HasFiles = ((byte)packet) == 1 && files > 0; u.Level = packet; u.Age = packet; u.Gender = packet; byte country = packet; u.Country = Helpers.CountryCodeToString(country); u.Region = packet.ReadString(this.crypto); u.IsFriend = Friends.IsFriend(u.Name); if (packet.Remaining > 0) { ClientFeatures features = (ClientFeatures)((byte)packet); u.SupportsVC = ((features & ClientFeatures.CLIENT_SUPPORTS_VC) == ClientFeatures.CLIENT_SUPPORTS_VC); u.SupportsOpusVC = ((features & ClientFeatures.CLIENT_SUPPORTS_OPUS_VC) == ClientFeatures.CLIENT_SUPPORTS_OPUS_VC); if (u.SupportsOpusVC) { u.SupportsVC = true; } } User ghost = this.users.Find(x => x.Name == u.Name); if (ghost != null) { this.users.RemoveAll(x => x.Name == ghost.Name); if (ghost.Writing) { ghost.Writing = false; this.Panel.UpdateWriter(ghost); } this.Panel.Userlist.RemoveUserItem(ghost); if (ScriptEvents.OnUserParting(this, ghost)) { this.Panel.AnnounceText(GlobalSettings.GetDefaultColorString(GlobalSettings.DefaultColorType.Part, this.BlackBG) + StringTemplate.Get(STType.Messages, 12).Replace("+x", ghost.Name)); } ScriptEvents.OnUserParted(this, ghost); Scripting.ScriptManager.RemoveUser(this.EndPoint, u); ghost.Dispose(); ghost = null; } this.users.Add(u); this.Panel.Userlist.AddUserItem(u); Scripting.ScriptManager.AddUser(this.EndPoint, u); if (ScriptEvents.OnUserJoining(this, u)) { this.Panel.AnnounceText(GlobalSettings.GetDefaultColorString(GlobalSettings.DefaultColorType.Join, this.BlackBG) + StringTemplate.Get(STType.Messages, 13).Replace("+x", u.Name)); } if (u.Name == this.MyName) { u.IsAway = Settings.IsAway; this.Panel.Userlist.MyLevel = u.Level; } ScriptEvents.OnUserJoined(this, u); if (u.IsFriend) { if (!Settings.GetReg <bool>("block_friend_popup", false)) { this.ShowPopup("cb0t :: " + StringTemplate.Get(STType.Messages, 4), StringTemplate.Get(STType.Messages, 14).Replace("+x", u.Name).Replace("+y", this.Credentials.Name), PopupSound.Friend); } } }
private void Eval_Features(TCPPacketReader packet) { String version = packet.ReadString(this.crypto); this.Credentials.Server = version; this.Panel.ServerText(StringTemplate.Get(STType.Messages, 17) + ": " + version); this.Panel.Userlist.UpdateServerVersion(version); this.should_check_for_current_topic_update = true; if (version.StartsWith("sb0t 5.")) { version = version.Substring(version.IndexOf(" ") + 1).Split(' ')[0]; String vnum_str = new String(version.Where(x => Char.IsNumber(x)).ToArray()); uint vnum; if (!uint.TryParse(vnum_str, out vnum)) { vnum = 0; } this.new_sbot = (vnum >= 514); } else if (version.StartsWith("Ares 2.") || version.StartsWith("Ares_2.")) { this.new_sbot = true; // maybe future Ares Server will support cb0t Custom Fonts? } ServerFeatures flag = (ServerFeatures)((byte)packet); this.CanVC = ((flag & ServerFeatures.SERVER_SUPPORTS_VC) == ServerFeatures.SERVER_SUPPORTS_VC); bool has_html = ((flag & ServerFeatures.SERVER_SUPPORTS_HTML) == ServerFeatures.SERVER_SUPPORTS_HTML); bool has_scribble = ((flag & ServerFeatures.SERVER_SUPPORTS_ROOM_SCRIBBLES) == ServerFeatures.SERVER_SUPPORTS_ROOM_SCRIBBLES); bool has_pm_scribble = ((flag & ServerFeatures.SERVER_SUPPORTS_PM_SCRIBBLES) == ServerFeatures.SERVER_SUPPORTS_PM_SCRIBBLES); this.CanOpusVC = ((flag & ServerFeatures.SERVER_SUPPORTS_OPUS_VC) == ServerFeatures.SERVER_SUPPORTS_OPUS_VC); this.Panel.CanVC(this.CanVC); this.Panel.CanScribbleAll(has_scribble); this.Panel.CanScribblePM(has_pm_scribble); this.Panel.InitScribbleButton(); this.CanNP = true; if (has_html) { this.Panel.Userlist.AcquireServerIcon(this.EndPoint); } packet.SkipByte(); this.Panel.ServerText(StringTemplate.Get(STType.Messages, 16) + ": " + (RoomLanguage)((byte)packet)); uint cookie = packet; if (!String.IsNullOrEmpty(this.Credentials.Password)) { this.sock.Send(TCPOutbound.SecureAdminLogin(this.Credentials.Password, cookie, this.Credentials.IP)); } this.UpdatePersonalMessage(); if (Avatar.Data != null) { this.sock.SendTrickle(TCPOutbound.Avatar()); } if (Settings.GetReg <bool>("user_font_enabled", false)) { this.sock.SendTrickle(TCPOutbound.Font(this.new_sbot, this.crypto)); } if (Settings.GetReg <bool>("block_custom_names", false)) { this.sock.SendTrickle(TCPOutbound.BlockCustomNames(true)); } ScriptEvents.OnConnected(this); }