protected override async Task HandleMessage(BaseMessage payload) { payload.OriginalQueue = queue_cs_profiles; // Remove any keys that can't be deserialised var json = JObject.Parse(JsonConvert.SerializeObject(payload.Message)); var key = json.Property("PICSProfileInfo"); key?.Remove(); // Get the message in the payload var message = JsonConvert.DeserializeObject <ProfileMessage>(json.ToString()); // Validation if (message.ID.ToString().Length != 17) { return; } // Get profile data var id = new SteamID(); id.SetFromUInt64(message.ID); var JobID = Steam.steamFriends.RequestProfileInfo(id); var callback = await JobID; payload.Message = new ProfileMessage { ID = message.ID, PICSProfileInfo = callback }; Produce(queue_go_profiles, payload); }
private static EResult ResolveVanityURL(string input, EVanityURLType urlType, out SteamID steamID) { steamID = new SteamID(); using (dynamic steamUser = WebAPI.GetInterface("ISteamUser", Settings.Current.Steam.WebAPIKey)) { steamUser.Timeout = (int)TimeSpan.FromSeconds(5).TotalMilliseconds; KeyValue response; try { response = steamUser.ResolveVanityURL(vanityurl: input, url_type: (int)urlType); } catch (WebException) { return(EResult.Timeout); } var eResult = (EResult)response["success"].AsInteger(); if (eResult == EResult.OK) { steamID.SetFromUInt64((ulong)response["steamid"].AsLong()); } return(eResult); } }
// Renders from a "76561198224231904" form. public static SteamID FromSteamID64(ulong steamID64) { var id = new SteamID(); id.SetFromUInt64(steamID64); return(id); }
private static async Task <(EResult result, SteamID steamID)> ResolveVanityURL(string input, EVanityURLType urlType) { var steamID = new SteamID(); EResult eResult; using (var steamUser = Steam.Configuration.GetAsyncWebAPIInterface("ISteamUser")) { steamUser.Timeout = TimeSpan.FromSeconds(5); KeyValue response; try { response = await steamUser.CallAsync(HttpMethod.Get, "ResolveVanityURL", 1, new Dictionary <string, object> { { "vanityurl", input }, { "url_type", (int)urlType } }); } catch (HttpRequestException) { return(EResult.Timeout, steamID); } eResult = (EResult)response["success"].AsInteger(); if (eResult == EResult.OK) { steamID.SetFromUInt64((ulong)response["steamid"].AsLong()); } } return(eResult, steamID); }
/// <summary> /// Reads how many days of escrow the user has /// </summary> /// <param name="trade">Trade object containing user information</param> /// <returns>Returns EscrowDuration class, if failed returns null</returns> public int GetUserEscrowWaitingPeriod(Config.TradeObject trade) { string url = "https://steamcommunity.com/tradeoffer/new/"; SteamID steamId = new SteamID(); steamId.SetFromUInt64(trade.SteamId); var data = new NameValueCollection(); data.Add("partner", steamId.AccountID.ToString()); data.Add("token", trade.RU_Token); string response = string.Empty; for (int i = 0; i < 3; i++) { try { response = mSteam.Web.Fetch(url, "GET", data, false); } catch (WebException ex) { var webResponse = new StreamReader(ex.Response.GetResponseStream()).ReadToEnd(); mLogOffer.Write(Log.LogLevel.Error, $"Web exception when getting user escrow waiting period at {ex.Message}"); } } return(Functions.ParseEscrowResponse(response)); }
public async Task LinkAsync(string idArg) { SocketUser sender = Context.User; UserData user = new UserData(sender.Id); SteamID steamId = new SteamID(); // Checks steamid input to determine what type of id it is if (idArg.Contains("STEAM_")) { steamId.SetFromString(idArg, EUniverse.Public); } else if (ulong.TryParse(idArg, out ulong id)) { steamId.SetFromUInt64(id); } else if (Regex.Match(idArg, @"^\[{1}\b[A-Z]\:{1}[0-9]\b").Success) { steamId.SetFromSteam3String(idArg); } else { await Error(); } // Stores the steamid to an int64 user.SteamId = steamId.ConvertToUInt64(); // Creates an user. Returns true if an error accures // Duplicates do not need to be checked both discord and steam ids are unique bool errored = await user.Create(); var persona = await Program.SteamWebManager.GetUserName(user.SteamId); Console.WriteLine($"{persona}"); // If errored bot responds the the error messaged set in user or confirms linked accounts // These are made to be more user friendly if (errored) { await ReplyAsync(user.err); } else { await ReplyAsync($"Account Linked! {sender.Mention} -> {persona}"); } }
public void LongConstructorAndSetterGetterValid() { SteamID sid = new SteamID(103582791432294076); Assert.Equal(2772668u, sid.AccountID); Assert.Equal(SteamID.AllInstances, sid.AccountInstance); Assert.Equal(EUniverse.Public, sid.AccountUniverse); Assert.Equal(EAccountType.Clan, sid.AccountType); sid.SetFromUInt64(157626004137848889); Assert.Equal(12345u, sid.AccountID); Assert.Equal(SteamID.WebInstance, sid.AccountInstance); Assert.Equal(EUniverse.Beta, sid.AccountUniverse); Assert.Equal(EAccountType.GameServer, sid.AccountType); Assert.Equal(157626004137848889ul, sid.ConvertToUInt64()); }
private static bool TrySetSteamID(string input, out SteamID steamID) { steamID = new SteamID(); if (steamID.SetFromString(input, EUniverse.Public) || steamID.SetFromSteam3String(input)) { return(true); } if (ulong.TryParse(input, out var numericInput)) { steamID.SetFromUInt64(numericInput); return(true); } return(false); }