public static byte[] CreateServerTicket( SteamID id, byte[] auth, byte[] ownershipTicket) { long size = 8 + // steam ID auth.Length + 4 + // length of ticket ownershipTicket.Length; var stream = new MemoryStream(); using (var writer = new BinaryWriter(stream)) { writer.Write((ushort)size); writer.Write(id.ConvertToUInt64()); writer.Write(auth.ToArray()); writer.Write(ownershipTicket.Length); writer.Write(ownershipTicket); writer.Write(0); } return(stream.ToArray()); }
private void GetOldFriends() { int numFriends = Bot.SteamFriends.GetFriendCount(); for (int count = 0; count < numFriends; count++) { SteamID friend = Bot.SteamFriends.GetFriendByIndex(count); ulong friendID = friend.ConvertToUInt64(); if (Bot.SteamFriends.GetFriendPersonaState(friendID) == EPersonaState.Offline) { var jsonstring = new WebClient().DownloadString("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=CC46B4B42227A9D657D47E406E372A88&steamids=" + friendID); JsonValue value = JsonValue.Parse(jsonstring); JsonObject result = value as JsonObject; try { string lastlogoff = (string)result["response"]["players"][0]["lastlogoff"]; Int32 unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; if ((unixTimestamp - 1210000) >= Int32.Parse(lastlogoff)) { Bot.SteamFriends.RemoveFriend(friendID); Console.WriteLine("Remove " + friendID); } } catch { Bot.SteamFriends.RemoveFriend(friendID); Console.WriteLine("Remove " + friendID + ". ERROR"); } } } Console.WriteLine("Done loop."); }
/// <summary> /// Creates a new trade offer with a token /// </summary> /// <param name="message">A message to include with the trade offer</param> /// <param name="otherSteamId">The SteamID of the partner we are trading with</param> /// <param name="status">The list of items we and they are going to trade</param> /// <param name="token">The token of the partner we are trading with</param> /// <param name="newTradeOfferId">The trade offer Id that will be created if successful</param> /// <returns>True if successfully returns a newTradeOfferId, else false</returns> public bool SendTradeOfferWithToken(string message, SteamID otherSteamId, global::TreasureHunter.SteamTrade.TradeOffer.TradeOffer.TradeStatus status, string token, out string newTradeOfferId) { if (String.IsNullOrEmpty(token)) { throw new ArgumentNullException("token", "Partner trade offer token is missing"); } var offerToken = new OfferAccessToken() { TradeOfferAccessToken = token }; var data = new NameValueCollection(); data.Add("sessionid", _steamWeb.SessionId); data.Add("serverid", "1"); data.Add("partner", otherSteamId.ConvertToUInt64().ToString()); data.Add("tradeoffermessage", message); data.Add("json_tradeoffer", JsonConvert.SerializeObject(status, JsonSerializerSettings)); data.Add("trade_offer_create_params", JsonConvert.SerializeObject(offerToken, JsonSerializerSettings)); string referer = $"https://steamcommunity.com/tradeoffer/new/?partner={otherSteamId.AccountID}&token={token}"; return(Request(SendUrl, data, referer, null, out newTradeOfferId)); }
/// <summary> /// Creates a new trade offer with a token /// </summary> /// <param name="message">A message to include with the trade offer</param> /// <param name="otherSteamId">The SteamID of the partner we are trading with</param> /// <param name="status">The list of items we and they are going to trade</param> /// <param name="token">The token of the partner we are trading with</param> /// <returns>True if successfully returns a newTradeOfferId, else false</returns> public string SendTradeOfferWithToken(string message, SteamID otherSteamId, TradeStatus status, string token) { if (string.IsNullOrEmpty(token)) { throw new ArgumentNullException(nameof(token), @"Partner trade offer token is missing"); } var offerToken = new OfferAccessToken { TradeOfferAccessToken = token }; var data = new NameValueCollection { { "sessionid", this._sessionId }, { "captcha", string.Empty }, { "serverid", "1" }, { "partner", otherSteamId.ConvertToUInt64().ToString() }, { "tradeoffermessage", message }, { "json_tradeoffer", JsonConvert.SerializeObject(status, this.JsonSerializerSettings) }, { "trade_offer_create_params", JsonConvert.SerializeObject(offerToken, this.JsonSerializerSettings) } }; var referer = $"https://steamcommunity.com/tradeoffer/new/?partner={otherSteamId.AccountID}&token={token}"; return(this.Request(SendUrl, data, referer)); }
/// <summary> /// Fetchs the inventories of both the bot and the other user as well as the TF2 item schema. /// </summary> /// <param name='me'> /// The <see cref="SteamID"/> of the bot. /// </param> /// <param name='other'> /// The <see cref="SteamID"/> of the other trade partner. /// </param> /// <remarks> /// This should be done anytime a new user is traded with or the inventories are out of date. It should /// be done sometime before calling <see cref="StartTrade"/>. /// </remarks> public void InitializeTrade(SteamID me, SteamID other) { // fetch other player's inventory from the Steam API. OtherInventory = Inventory.FetchInventory(other.ConvertToUInt64(), apiKey); //if (OtherInventory == null) //{ // throw new InventoryFetchException (other); //} // fetch our inventory from the Steam API. MyInventory = Inventory.FetchInventory(me.ConvertToUInt64(), apiKey); if (MyInventory == null) { throw new InventoryFetchException(me); } // check that the schema was already successfully fetched if (Trade.CurrentSchema == null) { Trade.CurrentSchema = Schema.FetchSchema(apiKey); } if (Trade.CurrentSchema == null) { throw new TradeException("Could not download the latest item schema."); } }
/// <summary> /// Creates a new counter offer /// </summary> /// <param name="message">A message to include with the trade offer</param> /// <param name="otherSteamId">The SteamID of the partner we are trading with</param> /// <param name="status">The list of items we and they are going to trade</param> /// <param name="newTradeOfferId">The trade offer Id that will be created if successful</param> /// <param name="tradeOfferId">The trade offer Id of the offer being countered</param> /// <returns></returns> public bool CounterOffer(string message, SteamID otherSteamId, global::TreasureHunter.SteamTrade.TradeOffer.TradeOffer.TradeStatus status, out string newTradeOfferId, string tradeOfferId) { if (String.IsNullOrEmpty(tradeOfferId)) { throw new ArgumentNullException("tradeOfferId", "Trade Offer Id must be set for counter offers."); } var data = new NameValueCollection(); data.Add("sessionid", _steamWeb.SessionId); data.Add("serverid", "1"); data.Add("partner", otherSteamId.ConvertToUInt64().ToString()); data.Add("tradeoffermessage", message); data.Add("json_tradeoffer", JsonConvert.SerializeObject(status, JsonSerializerSettings)); data.Add("tradeofferid_countered", tradeOfferId); data.Add("trade_offer_create_params", "{}"); string referer = string.Format("https://steamcommunity.com/tradeoffer/{0}/", tradeOfferId); if (!Request(SendUrl, data, referer, tradeOfferId, out newTradeOfferId)) { var state = _webApi.GetOfferState(tradeOfferId); if (state == TradeOfferState.TradeOfferStateCountered) { return(true); } return(false); } return(true); }
/// <summary> /// Gets chatroom settings and adds them to chatroom list if needed /// </summary> // TODO: There could be a function that directly return settings without check // This would be used in chat messages (to speed it up) and then use this on joins public Settings GetChatRoomSettings(SteamID chatRoomID) { // Shortcut var chatID = chatRoomID.ConvertToUInt64(); // Debug Log($"Debug: Requesting chatroom settings for {chatID}"); // If there are settings, return them if (chatrooms.ContainsKey(chatID)) { return(chatrooms[chatID]); } // Otherwise, look in files // TODO: Move (most of) loading of settings to Settings.Load? // TODO: We need a way to parse 'legacy settings' to new ones Log("Debug: Settings not found in chatrooms, looking in files"); Settings s; if (File.Exists($"./settings/{chatID}.json")) { Log("Debug: Settings found in file, saving to chatrooms"); s = Settings.Load(chatID); } else { Log("Debug: Settings not found. Creating new ones"); s = new Settings(chatID); } chatrooms[chatRoomID] = s; s.Save(); return(s); }
public void PostComment(SteamID userID, string comment) { if (!community.IsLoggedOn) { Log("Warning: Trying to post comment without being logged in to Community"); return; } var postData = $"comment={comment}&count=6&sessionid={community.SessionID}"; var url = $"http://steamcommunity.com/comment/Profile/post/{userID.ConvertToUInt64()}/-1/"; var bytes = Encoding.UTF8.GetBytes(postData); var request = (HttpWebRequest)WebRequest.Create(url); request.KeepAlive = false; request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8"; request.ContentLength = bytes.Length; request.CookieContainer = community.Cookies; var stream = request.GetRequestStream(); stream.Write(bytes, 0, bytes.Length); stream.Close(); var response = (HttpWebResponse)request.GetResponse(); Log(new StreamReader(response.GetResponseStream()).ReadToEnd()); Log("Posted comment"); }
public void AuthCurrentAccount() { this.InfoGridView.Rows.Clear(); Task.Run( () => { Dispatcher.AsMainForm( () => { this.LoginLable.Text = CurrentSession.SteamManager.Guard.AccountName; }); var avatar = ImageUtils.GetSteamProfileBigImage(CurrentSession.SteamManager.Guard.Session.SteamID); if (avatar != null) { avatar = ImageUtils.ResizeImage(avatar, 184, 184); this.AvatarImageBox.BackgroundImage = avatar; } var steamId = new SteamID( ulong.Parse(CurrentSession.SteamManager.Guard.Session.SteamID.ToString())); this.AddInfoTableRow("SteamId-64", steamId.ConvertToUInt64().ToString()); this.AddInfoTableRow("AccountId", steamId.AccountID.ToString()); this.AddInfoTableRow( "TradeToken", SavedSteamAccount.Get().FirstOrDefault(a => a.Login == this.LoginLable.Text)?.TradeToken); try { var walletInfo = CurrentSession.SteamManager.MarketClient.WalletInfo(); if (walletInfo != null) { this.AddInfoTableRow("Wallet country", walletInfo.WalletCountry); this.AddInfoTableRow( "Currency", CurrentSession.SteamManager.MarketClient.Currencies[walletInfo.Currency .ToString()]); this.AddInfoTableRow( "Max balance", walletInfo.MaxBalance.ToString(CultureInfo.InvariantCulture)); this.AddInfoTableRow( "Wallet balance", walletInfo.WalletBalance.ToString(CultureInfo.InvariantCulture)); this.AddInfoTableRow( "Wallet fee", walletInfo.WalletFee.ToString(CultureInfo.InvariantCulture)); this.AddInfoTableRow( "Wallet fee minimum", walletInfo.WalletFeeMinimum.ToString(CultureInfo.InvariantCulture)); this.AddInfoTableRow("Wallet fee percent", walletInfo.WalletFeePercent.ToString()); this.AddInfoTableRow( "Wallet trade max balance", walletInfo.WalletTradeMaxBalance.ToString(CultureInfo.InvariantCulture)); } } catch (SteamException e) { Logger.Error(string.Empty, e); } }); }
/// <summary> /// Add the user to the friendslist /// Invite the user to our group and the group passed by the admin /// Allowed string passed by admin: group url, groupID32 and groupID64, groupID64 is prefered because of error measures /// If a url is passed, so get the groupID64 from the grouppage /// groupID32 will be converted into a groupID64 /// Welcome the user to the service and tell him we invited him to our Group /// </summary> /// <param name="_steamFriends"></param> /// <param name="_friendSteamID"></param> /// <param name="_groupID"></param> /// <param name="_steamUserWebAPI"></param> public async Task AcceptFriendRequestAndInviteToGroup(SteamFriends _steamFriends, SteamID _friendSteamID, SteamUserWebAPI _steamUserWebAPI, string _groupID = "") { _steamFriends.AddFriend(_friendSteamID); for (int i = 0; i < _steamFriends.GetClanCount(); i++) { SteamID groupID = _steamFriends.GetClanByIndex(i); if (groupID.ConvertToUInt64().Equals(103582791458407475) && _steamFriends.GetClanName(groupID).ToUpper().Contains("XETAS")) { await _steamUserWebAPI.InviteToGroup(groupID.ToString(), _friendSteamID.ConvertToUInt64().ToString()).ConfigureAwait(false); } if (!string.IsNullOrEmpty(_groupID)) { string groupID64; if (_groupID.Contains("steamcommunity") && _groupID.Contains("groups")) { groupID64 = await _steamUserWebAPI.GetGroupIDFromGroupAdress(_groupID).ConfigureAwait(false); } else { groupID64 = GetGroupID64String(_groupID); } await _steamUserWebAPI.InviteToGroup(groupID64, _friendSteamID.ConvertToUInt64().ToString()).ConfigureAwait(false); } } _steamFriends.SendChatMessage(_friendSteamID, EChatEntryType.ChatMsg, "Hello and welcome to my Service!" + "\nI've invited you to my group, where you can check the other bots or get to learn and trade with other steamusers." + "\nYou can type !c or !commands to see all available commands."); }
public User(string id, ID_TYPE type) { if (type == ID_TYPE.STEAMID_32) { SteamID sid = new SteamID(id, EUniverse.Public); Steamid64 = sid.ConvertToUInt64().ToString(); Steamid32 = id; } else if (type == ID_TYPE.STEAMID_64) { Steamid64 = id; Steamid32 = SteamID64To32(id); } if (type == ID_TYPE.INTERNAL) { InternalId = id; Steamid32 = InternalIDToSteamID32(id); SteamID sid = new SteamID(Steamid32, EUniverse.Public); Steamid64 = sid.ConvertToUInt64().ToString(); } else { InternalId = SteamID32ToInternalID(Steamid32); } }
private void SendChatMessage(Bot bot, GameServerRequest gsr) { string[] steamID_msg = gsr.Arguments.Split(new char[] { '/' }, 2); SteamID steamID = GetSteamIDFromString(steamID_msg[0]); if (steamID == null || !steamID.IsValid) { bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.Simple, "Invalid steam ID (STEAM_X:Y:ZZZZ) !"); } else if (!bot.Friends.Contains(steamID.ConvertToUInt64())) { bot.Manager.Send(gsr.ServerID, gsr.ModuleID, NetworkCode.ASteambotCode.NotFriends, steamID.ConvertToUInt64().ToString()); } else { if (steamID_msg[1].StartsWith("steam://connect/")) { bot.GSMH.SendGameInvite(bot.getSteamID(), steamID, steamID_msg[1].Replace("steam://connect/", "")); } else { new Thread(() => { Thread.CurrentThread.IsBackground = true; foreach (string line in steamID_msg[1].Split(new[] { "\n" }, StringSplitOptions.None)) { bot.SteamFriends.SendChatMessage(steamID, EChatEntryType.ChatMsg, line); Thread.Sleep(1300); } }).Start(); } } }
// TODO: Please remove me immediately after https://github.com/SteamRE/SteamKit/issues/254 gets fixed internal void HackedLogOn(SteamUser.LogOnDetails details) { if (!Client.IsConnected) { return; } SteamID steamID = new SteamID(details.AccountID, details.AccountInstance, Client.ConnectedUniverse, EAccountType.Individual); ClientMsgProtobuf <CMsgClientLogon> logon = new ClientMsgProtobuf <CMsgClientLogon>(EMsg.ClientLogon); if (details.LoginID != null) { logon.Body.obfustucated_private_ip = details.LoginID.Value; } logon.ProtoHeader.client_sessionid = 0; logon.ProtoHeader.steamid = steamID.ConvertToUInt64(); logon.Body.account_name = details.Username; logon.Body.password = details.Password; logon.Body.should_remember_password = details.ShouldRememberPassword; logon.Body.protocol_version = MsgClientLogon.CurrentProtocol; logon.Body.client_os_type = (uint)details.ClientOSType; logon.Body.client_language = details.ClientLanguage; logon.Body.cell_id = details.CellID; logon.Body.steam2_ticket_request = details.RequestSteam2Ticket; logon.Body.client_package_version = 1771; logon.Body.auth_code = details.AuthCode; logon.Body.two_factor_code = details.TwoFactorCode; logon.Body.login_key = details.LoginKey; logon.Body.sha_sentryfile = details.SentryFileHash; logon.Body.eresult_sentryfile = (int)(details.SentryFileHash != null ? EResult.OK : EResult.FileNotFound); Client.Send(logon); }
/// <summary> /// Fetchs the inventories of both the bot and the other user as well as the TF2 item schema. /// </summary> /// <param name='me'> /// The <see cref="SteamID"/> of the bot. /// </param> /// <param name='other'> /// The <see cref="SteamID"/> of the other trade partner. /// </param> /// <remarks> /// This should be done anytime a new user is traded with or the inventories are out of date. It should /// be done sometime before calling <see cref="CreateTrade"/>. /// </remarks> public void InitializeTrade(SteamID me, SteamID other) { // fetch other player's inventory from the Steam API. _otherInventoryTask = Task.Factory.StartNew(() => Inventory.FetchInventory(other.ConvertToUInt64(), _apiKey, _steamWeb, _sendChatMessage)); //if (OtherInventory == null) //{ // throw new InventoryFetchException (other); //} // fetch our inventory from the Steam API. _myInventoryTask = Task.Factory.StartNew(() => Inventory.FetchInventory(me.ConvertToUInt64(), _apiKey, _steamWeb, _sendChatMessage)); // check that the schema was already successfully fetched if (Trade.CurrentSchema == null) { Trade.CurrentSchema = Schema.FetchSchema(_apiKey); } if (Trade.CurrentSchema == null) { throw new TradeException("Could not download the latest item schema."); } }
public SteamAccountHyperlinkModel(SteamID steamId) { this.AccountName = SettingsProvider.GetInstance().SteamAccounts.FirstOrDefault(a => a.SteamId == steamId)?.Login ?? steamId.ConvertToUInt64().ToString(); this.AccountLink = $"https://steamcommunity.com/profiles/{steamId}/"; }
public void AddVictim(SteamID steamID) { _victims.Add(new Victims.Victim { SteamID = steamID.ConvertToUInt64(), Ticks = DateTime.Now.Ticks }); }
public static void sendChatMessage(SteamID id, String msg) { AccountController.getAccount(user).updateChatLogs(new Friend() { steamFrindsID = id.ConvertToUInt64().ToString() }, msg, true); steamFriends.SendChatMessage(id, EChatEntryType.ChatMsg, msg); }
public bool RequestBanInfo(SteamID steamID, out BanInfo banInfo) { if (steamID != null && !string.IsNullOrEmpty(_keyManager.SWAKey)) { try { using (dynamic steamUser = WebAPI.GetInterface("ISteamUser", _keyManager.SWAKey)) { KeyValue pair = steamUser.GetPlayerBans(steamids: steamID.ConvertToUInt64()); foreach (var get in pair["players"].Children) { if (get["SteamId"].AsUnsignedLong() == steamID.ConvertToUInt64()) { banInfo = new BanInfo { SteamID = get["SteamId"].AsUnsignedLong(), CommunityBanned = get["CommunityBanned"].AsBoolean(), VacBanned = get["VACBanned"].AsBoolean(), VacBanCount = get["NumberOfVACBans"].AsInteger(), DaysSinceLastBan = get["DaysSinceLastBan"].AsInteger(), GameBanCount = get["NumberOfGameBans"].AsInteger(), EconomyBan = get["EconomyBan"].AsString() }; return(true); } } } } catch (WebException ex) { Log.Error(ex, "A error occured when trying to get the Ban Information for {SteamID}.", steamID.ConvertToUInt64()); } Log.Warning("Did not receive ban informations for {SteamID}. Skipping...", steamID.ConvertToUInt64()); banInfo = null; return(false); } Log.Warning("No valid Web API key has been found. Skipping ban checking..."); banInfo = null; return(false); }
public void AddVictim(SteamID steamID) { _victims.Add(new Victims.Victim { SteamID = steamID.ConvertToUInt64(), Timestamp = DateTime.Now.ToEpochTime() }); }
public static void CreateFriendsListIfNecessary() { if (Friends != null) { return; } Friends = new List <SteamID>(); for (int i = 0; i < steamFriends.GetFriendCount(); i++) { SteamID allfriends = steamFriends.GetFriendByIndex(i); if (allfriends.ConvertToUInt64() != 0 && steamFriends.GetFriendRelationship(allfriends.ConvertToUInt64()) == EFriendRelationship.Friend) { Friends.Add(allfriends.ConvertToUInt64()); } } }
private void Init() { sessionIdEsc = Uri.UnescapeDataString(SteamWeb.SessionId); Version = 1; baseTradeURL = string.Format(SteamTradeUrl, OtherSID.ConvertToUInt64()); }
static void OnPersonaState(SteamFriends.PersonaStateCallback callback) { SteamID friendID = callback.FriendID; SteamID sourceSteamID = callback.SourceSteamID.ConvertToUInt64(); EClanRank clanRank = (EClanRank)callback.ClanRank; EPersonaState state = callback.State; //ListFriends.UpdateName(friendId.ConvertToUInt64(), callback.Name); not yet //ListFriends.UpdateStatus(friendId.ConvertToUInt64(), state.ToString()); not yet if (friendID.ConvertToUInt64() == steamClient.SteamID) { if (sourceSteamID.IsClanAccount) { switch (clanRank) { case EClanRank.Owner: // case EClanRank.Officer: //case EClanRank.Moderator: if (!OfficerClanDictionary.ContainsKey(sourceSteamID)) { OfficerClanDictionary.Add(sourceSteamID, friendID.ConvertToUInt64()); } break; } } // if (callback.GameID > 0) { UserPlaying = true; } else { UserPlaying = false; } if (steamFriends.GetPersonaState() != EPersonaState.Online) //detect when user goes afk { //isAwayState = true; } else { //isAwayState = false; } } }
public static void sendChatMessage(SteamID id, String msg) { fObject.updateChatLog(new Friend() { steamFrindsID = id.ConvertToUInt64().ToString() }, msg, true); steamFriends.SendChatMessage(id, EChatEntryType.ChatMsg, msg); }
/* * __ __ _ _ _ | \/ | ___ | |_ | |__ ___ __| | ___ | |\/| | / _ \| __|| '_ \ / _ \ / _` |/ __| | | | || __/| |_ | | | || (_) || (_| |\__ \ |_| |_| \___| \__||_| |_| \___/ \__,_||___/ | */ // TODO: Remove me once https://github.com/SteamRE/SteamKit/issues/305 is fixed internal void LogOnWithoutMachineID(SteamUser.LogOnDetails details) { if (details == null) { throw new ArgumentNullException(nameof(details)); } if (string.IsNullOrEmpty(details.Username) || (string.IsNullOrEmpty(details.Password) && string.IsNullOrEmpty(details.LoginKey))) { throw new ArgumentException("LogOn requires a username and password to be set in 'details'."); } if (!string.IsNullOrEmpty(details.LoginKey) && !details.ShouldRememberPassword) { // Prevent consumers from screwing this up. // If should_remember_password is false, the login_key is ignored server-side. // The inverse is not applicable (you can log in with should_remember_password and no login_key). throw new ArgumentException("ShouldRememberPassword is required to be set to true in order to use LoginKey."); } ClientMsgProtobuf <CMsgClientLogon> logon = new ClientMsgProtobuf <CMsgClientLogon>(EMsg.ClientLogon); SteamID steamId = new SteamID(details.AccountID, details.AccountInstance, Client.ConnectedUniverse, EAccountType.Individual); if (details.LoginID.HasValue) { logon.Body.obfustucated_private_ip = details.LoginID.Value; } logon.ProtoHeader.client_sessionid = 0; logon.ProtoHeader.steamid = steamId.ConvertToUInt64(); logon.Body.account_name = details.Username; logon.Body.password = details.Password; logon.Body.should_remember_password = details.ShouldRememberPassword; logon.Body.protocol_version = MsgClientLogon.CurrentProtocol; logon.Body.client_os_type = (uint)details.ClientOSType; logon.Body.client_language = details.ClientLanguage; logon.Body.cell_id = details.CellID; logon.Body.steam2_ticket_request = details.RequestSteam2Ticket; logon.Body.client_package_version = 1771; logon.Body.supports_rate_limit_response = true; // steam guard logon.Body.auth_code = details.AuthCode; logon.Body.two_factor_code = details.TwoFactorCode; logon.Body.login_key = details.LoginKey; logon.Body.sha_sentryfile = details.SentryFileHash; logon.Body.eresult_sentryfile = (int)(details.SentryFileHash != null ? EResult.OK : EResult.FileNotFound); Client.Send(logon); }
/// <summary> /// Declines the invite to a Steam Group /// </summary> /// <param name="group">SteamID of the group to decline the invite from.</param> private void DeclineGroupInvite(SteamID group) { var DeclineInvite = new ClientMsg <CMsgGroupInviteAction>((int)EMsg.ClientAcknowledgeClanInvite); DeclineInvite.Body.GroupID = group.ConvertToUInt64(); DeclineInvite.Body.AcceptInvite = false; this.SteamClient.Send(DeclineInvite); }
/// <summary> /// Accepts the invite to a Steam Group /// </summary> /// <param name="group">SteamID of the group to accept the invite from.</param> private void AcceptGroupInvite(SteamID group) { var AcceptInvite = new ClientMsg <CMsgGroupInviteAction>((int)EMsg.ClientAcknowledgeClanInvite); AcceptInvite.Body.GroupID = group.ConvertToUInt64(); AcceptInvite.Body.AcceptInvite = true; this.SteamClient.Send(AcceptInvite); }
private static async Task <UserInventoryApp[]> GetInventoryOverview( SteamWebAccess steamWebAccess, SteamID steamId) { var regex = new Regex("var g_rgAppContextData = (.*?);"); Match matched = null; for (var i = 0; i < 3; i++) { try { var inventoryPageResponse = await steamWebAccess.FetchString( new SteamWebAccessRequest( string.Format(UserInventoryUrl, steamId.ConvertToUInt64()), SteamWebAccessRequestMethod.Get, null ) ).ConfigureAwait(false); if (!string.IsNullOrWhiteSpace(inventoryPageResponse)) { matched = regex.Match(inventoryPageResponse); if (matched.Success) { break; } } } catch (WebException) { continue; } await Task.Delay(TimeSpan.FromSeconds(0.3)).ConfigureAwait(false); } if (matched?.Success != true || matched.Groups.Count <= 1 || !matched.Groups[1].Success || string.IsNullOrWhiteSpace(matched.Groups[1].Value)) { throw new UserInventoryFetchOverviewException(steamId); } try { var overviewResult = JsonConvert.DeserializeObject <Dictionary <long, InventoryApp> >(matched.Groups[1].Value); return(overviewResult?.Values.Select(app => app.ToUserInventoryApp()).ToArray()); } catch (Exception e) { throw new UserInventoryFetchOverviewException(steamId, e); } }
private void SendFriendInvitation(Bot bot, GameServerRequest gsr) { SteamID steamID = GetSteamIDFromString(gsr.Arguments); if (steamID.IsValid) { bot.SteamFriends.AddFriend(steamID.ConvertToUInt64()); } }
public void ScreenshotProfile(SteamID steamID) { var image = ScreenshotSite("https://steamcommunity.com/profiles/" + steamID.ConvertToUInt64()); if (image != null) { var file = new FileInfo(Path.Combine(_directory.ToString(), steamID.ConvertToUInt64() + ".orig.png")); if (file.Exists) { file = new FileInfo(Path.Combine(_directory.ToString(), steamID.ConvertToUInt64() + ".banned.png")); } using (var writer = File.OpenWrite(file.ToString())) { image.Save(writer, ImageFormat.Png); } } }
/// <summary> /// Invites a use to the specified Steam Group /// </summary> /// <param name="user">SteamID of the user to invite.</param> /// <param name="groupId">SteamID of the group to invite the user to.</param> public void InviteUserToGroup(SteamID user, SteamID groupId) { var InviteUser = new ClientMsg <CMsgInviteUserToGroup>((int)EMsg.ClientInviteUserToClan); InviteUser.Body.GroupID = groupId.ConvertToUInt64(); InviteUser.Body.Invitee = user.ConvertToUInt64(); InviteUser.Body.UnknownInfo = true; this.SteamClient.Send(InviteUser); }