/// <summary> /// Returns the <seealso cref="HProfile"/> from the specified hotel associated with the given unique identifier in an asynchronous operation. /// </summary> /// <param name="uniqueId">The unique identifier of the player you wish to retrieve the <see cref="HProfile"/> from.</param> /// <param name="hotel">The <seealso cref="HHotel"/> that the target user is located on.</param> /// <returns></returns> public static async Task <HProfile> GetProfileAsync(string uniqueId, HHotel hotel) { string profileJson = await _httpClient.GetStringAsync( string.Format(PROFILE_API_FORMAT, hotel.ToUrl(), uniqueId)); return(HProfile.Create(profileJson)); }
/// <summary> /// Returns the <see cref="HHotel"/> associated with the specified value. /// </summary> /// <param name="host">The string representation of the <see cref="HHotel"/> object.</param> /// <returns></returns> public static HHotel ToHotel(string host) { HHotel hotel = HHotel.Com; string identifier = host.GetChild("game-", '.') .Replace("us", "com"); if (string.IsNullOrWhiteSpace(identifier)) { if (host.StartsWith(".")) { host = ("habbo" + host); } identifier = host.GetChild("habbo.", '/') .Replace(".", string.Empty); } else if (identifier == "tr" || identifier == "br") { identifier = "com" + identifier; } if (!string.IsNullOrWhiteSpace(identifier)) { Enum.TryParse(identifier, true, out hotel); } return(hotel); }
/// <summary> /// Returns the <seealso cref="HUser"/> from the specified hotel associated with the given name in an asynchronous operation. /// </summary> /// <param name="name">The name of the player you wish to retrieve the <seealso cref="HUser"/> from.</param> /// <param name="hotel">The <seealso cref="HHotel"/> that the target user is located on.</param> /// <returns></returns> public static async Task <HUser> GetUserAsync(string name, HHotel hotel) { string userJson = await _httpClient.GetStringAsync( hotel.ToUrl() + USER_API_SUFFIX + name); return(HUser.Create(userJson)); }
/// <summary> /// Returns the <see cref="HHotel"/> associated with the specified value. /// </summary> /// <param name="host">The string representation of the <see cref="HHotel"/> object.</param> /// <returns></returns> public static HHotel ToHotel(string host) { HHotel hotel = HHotel.Com; string identifier = host.GetChild("game-", '.') .Replace("us", "com"); if (string.IsNullOrWhiteSpace(identifier)) { if (host.StartsWith(".")) { host = ("habbo" + host); } identifier = host.GetChild("habbo.", '/') .Replace(".", string.Empty); } else if (identifier == "tr" || identifier == "br") { identifier = "com" + identifier; } if (!Enum.TryParse(identifier, true, out hotel)) { throw new ArgumentException( "The specified host is not a valid hotel.", nameof(host)); } return(hotel); }
/// <summary> /// Returns the user's basic information associated with the given name using the specified <see cref="HHotel"/> in an asynchronous operation. /// </summary> /// <param name="name">The name of the user.</param> /// <param name="hotel">The hotel where the target user is from.</param> public static async Task <HUser> GetUserAsync(string name, HHotel hotel) { using (var client = new WebClient()) { client.Proxy = null; client.Headers[HttpRequestHeader.UserAgent] = ChromeAgent; client.Headers.Add(HttpRequestHeader.Cookie, "YPF8827340282Jdskjhfiw_928937459182JAX666=127.0.0.1"); string userJson = null; try { userJson = await client.DownloadStringTaskAsync(string.Format(USER_API_FORMAT, hotel.ToUrl(true), name)).ConfigureAwait(false); } catch (WebException ex) { using (WebResponse response = ex.Response) using (var responseReader = new StreamReader(response.GetResponseStream())) { userJson = await responseReader.ReadToEndAsync().ConfigureAwait(false); } } if (userJson.StartsWith("{\"error")) { return(null); } var user = HUser.Create(userJson); if (!_uniqueIds.ContainsKey(hotel)) { _uniqueIds[hotel] = new Dictionary <string, string>(); } _uniqueIds[hotel][user.Name] = user.UniqueId; return(user); } }
public static string ToDomain(this HHotel hotel) { if (hotel == HHotel.Unknown) { throw new ArgumentException("Hotel cannot be 'Unknown'.", nameof(hotel)); } string value = hotel.ToString().ToLower(); return(value.Length != 5 ? value : value.Insert(3, ".")); }
public static string ToDomain(this HHotel hotel) { string outCome = hotel.ToString().ToLower(); if (hotel == HHotel.ComBr || hotel == HHotel.ComTr) { outCome = "com." + outCome.Substring(3, 2); } return(outCome); }
public HSession(string email, string password, HHotel hotel) { Email = email; Hotel = hotel; Password = password; Triggers = new HTriggers(false); Cookies = new CookieContainer(); _disconnectLock = new object(); _hotelUri = new Uri(Hotel.ToUrl()); }
/// <summary> /// Returns the player motto relative to the specified player name, and hotel. /// </summary> /// <param name="playerName">The name of the player of whom to grab the motto from.</param> /// <param name="hotel">The hotel where the specified player name exists on.</param> /// <returns></returns> public static string GetPlayerMotto(string playerName, HHotel hotel) { using (var webClientEx = new WebClientEx()) { webClientEx.Proxy = null; webClientEx.Headers["Cookie"] = GetIpCookie(hotel); webClientEx.Headers["User-Agent"] = ChromeAgent; string body = webClientEx.DownloadString(hotel.ToUrl(false) + "/habblet/habbosearchcontent?searchString=" + playerName); return(body.IndexOf(playerName, StringComparison.OrdinalIgnoreCase) != -1 ? body.GetChild("<b>" + playerName + "</b><br />", '<') : string.Empty); } }
/// <summary> /// Returns your external Internet Protocol (IP) address that is required to successfully send GET/POST request to the specified <seealso cref="HHotel"/> in an asynchronous operation. /// </summary> /// <param name="hotel">The hotel you wish to retrieve the cookie containing your external Internet Protocol (IP) address from.</param> /// <returns></returns> public static async Task <string> GetIPCookieAsync(HHotel hotel) { if (!string.IsNullOrEmpty(_ipCookie)) { return(_ipCookie); } string body = await _httpClient.GetStringAsync(hotel.ToUrl()); return(_ipCookie = (body.Contains("setCookie")) ? IP_COOKIE_PREFIX + body.GetChilds("setCookie", '\'', false)[3] : string.Empty); }
/// <summary> /// Returns the player figure id relative to the specified player name, and hotel. /// </summary> /// <param name="playerName">The name of the player of whom to grab the player figure id from.</param> /// <param name="hotel">The hotel where the specified player name exists on.</param> /// <returns></returns> public static string GetPlayerFigureId(string playerName, HHotel hotel) { using (var webClientEx = new WebClientEx()) { webClientEx.Proxy = null; webClientEx.Headers["Cookie"] = GetIpCookie(hotel); webClientEx.Headers["User-Agent"] = ChromeAgent; string body = webClientEx.DownloadString(hotel.ToUrl(false) + "/habblet/habbosearchcontent?searchString=" + playerName); return(body.Contains("habbo-imaging/avatar/") ? body.GetChild("habbo-imaging/avatar/", ',') : string.Empty); } }
/// <summary> /// Returns the current online player count for the specified hotel. /// </summary> /// <param name="hotel">The hotel to retrieve the online player count from.</param> /// <returns></returns> public static int GetPlayersOnline(HHotel hotel) { using (var webClientEx = new WebClientEx()) { webClientEx.Proxy = null; webClientEx.Headers["Cookie"] = GetIpCookie(hotel); webClientEx.Headers["User-Agent"] = ChromeAgent; string body = webClientEx.DownloadString(hotel.ToUrl(false) + "/login_popup"); return(body.Contains("stats-fig") ? int.Parse(body.GetChild("<span class=\"stats-fig\">", '<')) : -1); } }
public static async Task <HProfile> GetProfileAsync(string name, HHotel hotel) { HUser user = await GetUserAsync(name, hotel).ConfigureAwait(false); if (user.IsProfileVisible == true) { return(await GetProfileAsync(user.UniqueId).ConfigureAwait(false)); } return(new HProfile { User = user }); }
public HSession(string email, string password, HHotel hotel) { Email = email; Hotel = hotel; Password = password; Requester = new HRequest(); Triggers = new HTriggers(false); _disconnectLock = new object(); _hotelUri = new Uri(Hotel.ToUrl(true)); }
public static async Task <string> GetLatestRevisionAsync(HHotel hotel) { string body = await ReadContentAsync <string>(hotel.ToUri(), "/gamedata/external_variables/1").ConfigureAwait(false); int revisionStartIndex = body.LastIndexOf("/gordon/") + 8; if (revisionStartIndex != 7) { int revisionEndIndex = body.IndexOf('/', revisionStartIndex); if (revisionEndIndex != -1) { return(body[revisionStartIndex..revisionEndIndex]);
public HSession(string email, string password, HHotel hotel) { Email = email; Password = password; Hotel = hotel; _firstTimeLoadProfile = true; _disconnectLock = new object(); Cookies = new CookieContainer(); }
/// <summary> /// Returns the player avatar relative to the specified player name, and hotel. /// </summary> /// <param name="playerName">The name of the player of whom to grab the avatar from.</param> /// <param name="hotel">The hotel where the specified player name exists on.</param> /// <returns></returns> public static Bitmap GetPlayerAvatar(string playerName, HHotel hotel) { using (var webClientEx = new WebClientEx()) { webClientEx.Proxy = null; webClientEx.Headers["Cookie"] = GetIpCookie(hotel); webClientEx.Headers["User-Agent"] = ChromeAgent; byte[] avatarData = webClientEx.DownloadData(hotel.ToUrl(false) + "/habbo-imaging/avatarimage?user="******"&action=&direction=&head_direction=&gesture=&size="); using (var memoryStream = new MemoryStream(avatarData)) return(new Bitmap(memoryStream)); } }
/// <summary> /// Returns the user's unique identifier associated with the given name using the specified <see cref="HHotel"/> in an asynchronous operation. /// </summary> /// <param name="name">The name of the user.</param> /// <param name="hotel">The hotel where the target user is from.</param> public static async Task <string> GetUniqueIdAsync(string name, HHotel hotel) { if (_uniqueIds.ContainsKey(hotel) && _uniqueIds[hotel].ContainsKey(name)) { return(_uniqueIds[hotel][name]); } HUser user = await GetUserAsync( name, hotel).ConfigureAwait(false); return(user?.UniqueId); }
public static string Juice(this HPage page, HHotel hotel) { switch (page) { case HPage.Profile: return(hotel.ToUrl(true) + "/profile/"); case HPage.Settings: return(hotel.ToUrl(true) + "/settings"); case HPage.Client: return(hotel.ToUrl(true) + "/api/client/clienturl"); default: return(string.Empty); } }
public HSession(string email, string password, HHotel hotel) { Email = email; Hotel = hotel; Password = password; _cookies = new CookieContainer(); _httpHotelUri = new Uri(Hotel.ToUrl(false)); _httpsHotelUri = new Uri(Hotel.ToUrl(true)); _inBuffer = new byte[1024]; _client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); }
public async Task <HUser> GetUserAsync(string name, HHotel hotel) { if (!_userCache.ContainsKey(hotel)) { _userCache[hotel] = new Dictionary <string, HUser>(); } if (!_userCache[hotel].ContainsKey(name)) { HUser profile = await SKore.GetUserAsync(name, hotel).ConfigureAwait(false); _userCache[hotel][name] = profile; } return(_userCache[hotel][name]); }
/// <summary> /// Returns a cookie containing your external IP address that is required by most hotels to retrieve a remote resource from their host. /// </summary> /// <returns></returns> public static string GetIpCookie(HHotel hotel) { if (!string.IsNullOrEmpty(_ipCookie)) { return(_ipCookie); } using (var webClientEx = new WebClientEx()) { webClientEx.Proxy = null; webClientEx.Headers["User-Agent"] = ChromeAgent; string body = webClientEx.DownloadString(hotel.ToUrl(false)); return(_ipCookie = (body.Contains(("setCookie")) ? "YPF8827340282Jdskjhfiw_928937459182JAX666=" + body.GetChilds("setCookie", '\'', false)[3] : string.Empty)); } }
/// <summary> /// Returns the user's basic information associated with the given name using the specified <see cref="HHotel"/> in an asynchronous operation. /// </summary> /// <param name="name">The name of the user.</param> /// <param name="hotel">The hotel where the target user is from.</param> public static async Task <HUser> GetUserAsync(string name, HHotel hotel) { string userJson = await _hRequest.DownloadStringAsync( string.Format(USER_API_FORMAT, hotel.ToUrl(true), name)).ConfigureAwait(false); var user = HUser.Create(userJson); if (!_uniqueIds.ContainsKey(hotel)) { _uniqueIds[hotel] = new Dictionary <string, string>(); } _uniqueIds[hotel][user.Name] = user.UniqueId; return(user); }
public async Task <HProfile> GetProfileAsync(string name, HHotel hotel) { if (!_profileCache.ContainsKey(hotel)) { _profileCache[hotel] = new Dictionary <string, HProfile>(); } if (!_profileCache[hotel].ContainsKey(name)) { HProfile profile = await SKore.GetProfileAsync( name, hotel).ConfigureAwait(false); _profileCache[hotel][name] = profile; } return(_profileCache[hotel][name]); }
private void ExtractVariables() { _variables.Clear(); MatchCollection matches = Regex.Matches(Source, FLASH_VAR_PATTERN, RegexOptions.Multiline); foreach (Match match in matches) { string value = match.Groups["value"].Value; string variable = match.Groups["variable"].Value; if (value.Contains("\\/")) { value = value.Replace("\\/", "/"); } _variables[variable] = value; } Hotel = HotelEndPoint.GetHotel(InfoHost); }
/// <summary> /// Returns the player's last online date relative to the specified player name, and hotel. /// </summary> /// <param name="playerName">The name of the player of whom to grab the player's last online date from.</param> /// <param name="hotel">The hotel where the specified player name exists on.</param> /// <param name="exact">true to return the time span; otherwise, false for the full date of when the player was last online.</param> /// <returns></returns> public static DateTime GetPlayerLastOnline(string playerName, HHotel hotel) { using (var webClientEx = new WebClientEx()) { webClientEx.Proxy = null; webClientEx.Headers["Cookie"] = GetIpCookie(hotel); webClientEx.Headers["User-Agent"] = ChromeAgent; string body = webClientEx.DownloadString(hotel.ToUrl(false) + "/habblet/habbosearchcontent?searchString=" + playerName); if (!body.Contains("lastlogin")) { return(DateTime.MinValue); } body = body.GetChild("<div class=\"lastlogin\">").GetChild("span title="); return(DateTime.Parse(body.Split('"')[1])); } }
public async Task <Bitmap> GetAvatarAsync(string name, HHotel hotel) { HUser user = await GetUserAsync(name, hotel).ConfigureAwait(false); if (user == null) { return(Resources.Avatar); } if (!_avatarCache.ContainsKey(user.FigureId)) { using (Bitmap avatar = await SKore.GetAvatarAsync(user.FigureId, HSize.Medium).ConfigureAwait(false)) { _avatarCache[user.FigureId] = TrimAvatar(avatar); } } return(_avatarCache[user.FigureId]); }
/// <summary> /// Returns the unique identifier from the specified <seealso cref="HHotel"/> associated with the given name in an asynchronous operation. /// </summary> /// <param name="name">The name of the player you wish to retrieve the unique identifier from.</param> /// <param name="hotel">The <seealso cref="HHotel"/> that the target user is located on.</param> /// <returns></returns> public static async Task <string> GetUniqueIdAsync(string name, HHotel hotel) { bool hotelInitialized = _uniqueIds.ContainsKey(hotel); if (!hotelInitialized) { _uniqueIds.Add(hotel, new Dictionary <string, string>()); } else if (_uniqueIds[hotel].ContainsKey(name)) { return(_uniqueIds[hotel][name]); } string uniqueId = (await GetUserAsync(name, hotel)).UniqueId; _uniqueIds[hotel][name] = uniqueId; return(uniqueId); }
public static void MimicOtherPlayer(this Extension E, string PlayerName, HHotel Hotel) { try { if (!SKore.CheckPlayerName(PlayerName, Hotel)) { E.ChangeClothes(PlayerName, Hotel); E.ChangeMotto(PlayerName, Hotel); } else { MessageBox.Show(string.Format("Sorry the player '{0}' could not be found on {1}", PlayerName, Hotel.ToDomain()), "Error"); } } catch (Exception e) { MessageBox.Show(e.ToString()); } }
public async Task <Bitmap> GetAvatarAsync(string name, HHotel hotel) { HProfile profile = await GetProfileAsync( name, hotel).ConfigureAwait(false); if (profile == null) { return(Resources.Avatar); } if (!_avatarCache.ContainsKey(profile.User.FigureId)) { Bitmap avatar = await SKore.GetAvatarAsync( profile.User.FigureId, HSize.Medium).ConfigureAwait(false); _avatarCache[profile.User.FigureId] = avatar; } return(_avatarCache[profile.User.FigureId]); }
public Main(Extension extension) { E = extension; InitializeComponent(); _loadedPlayers = new Dictionary<string, PDU>(); CurHotel = E.Contractor.Hotel; AutoLoad.Checked = true; #region Event Subscribing E.Triggers.InAttach(Data.Default.PlayerDataLoaded, OnPlayerDataLoaded); E.Triggers.InAttach(Data.Default.PlayerChangeData, OnPlayerChangeData); E.Triggers.InAttach(Data.Default.PlayerActionsDetected, OnPlayerActionsDetected); E.Triggers.InAttach(Data.Default.PlayerGesture, OnPlayerGesture); E.Triggers.InAttach(Data.Default.PlayerDance, OnPlayerDance); E.Triggers.InAttach(Data.Default.PlayerSay, OnPlayerSay); E.Triggers.InAttach(Data.Default.PlayerShout, OnPlayerShout); E.Triggers.InAttach(Data.Default.PlayerWhisper, OnPlayerWhisper); E.Triggers.InAttach(Data.Default.PlayerSendMessage, OnPlayerMessage); E.Triggers.InAttach(Data.Default.PlayerSign, OnPlayerSign); E.Triggers.OutAttach(Data.Default.HostShout, OnHostShout); #endregion }
public static void ChangeMotto(this Extension E, string PlayerName, HHotel Hotel) { string Motto = SKore.GetPlayerMotto(PlayerName, Hotel); E.Contractor.SendToServer(HMessage.Construct(Data.Default.HostChangeMotto, Motto)); }
public static void ChangeClothes(this Extension E, string PlayerName, HHotel Hotel) { string FigureID = SKore.GetPlayerFigureId(PlayerName, Hotel); E.Contractor.SendToServer(HMessage.Construct(Data.Default.HostChangeClothes, HGender.Male.ToString()[0], FigureID)); }