public override void OnNewTradeOffer(TradeOffer offer) { if (offer.OfferState != TradeOfferState.TradeOfferStateActive) { return; } Log.Debug("Trade offer from user {0}.", OtherSID.ToString()); if (IsAdmin) { offer.Accept(); Log.Success("Accepted trade offer from admin '{0}'.", Bot.SteamFriends.GetFriendPersonaName(OtherSID)); SendChatMessage("Trade offer complete."); Console.Beep(); } else { bool? hasMatchingOrder = Bot.Orders.HasMatchingOrder(this, offer); Order ord = Bot.Orders.GetMatchingOrder(this, offer); bool isFullStock = IsFullStock(ord); if (hasMatchingOrder == true && !isFullStock) { offer.Accept(); Log.Success("Accepted valid trade offer from user {0}.", OtherSID.ToString()); SendChatMessage("I have accepted your trade offer."); SendChatToAdmins("Accepted trade offer from user {0}: {1}", OtherSID.ToString(), ord.ToString(Trade.CurrentSchema, true)); Console.Beep(); } else if (isFullStock) { offer.Decline(); Log.Warn("Declined trade offer from user {0}, as stock was full."); SendChatMessage("Unfortunately I seem to have full stock of that item. Your offer has been declined."); } else if (hasMatchingOrder != null) { offer.Decline(); Log.Warn("Declined invalid trade offer from user {0}.", OtherSID.ToString()); SendChatMessage("There seems to be a problem with your trade offer. It has been declined."); } else { SendChatMessage("Unable to retrieve your inventory, and thus am unable to respond to your offer."); //SendChatToAdmins("There was an error retrieving the inventory of {0}.", OtherSID.ToString()); } //offer.Decline(); //Log.Warn("Declined trade offer from user {0}.", OtherSID.ToString()); //SendChatMessage("I don't know you. I cannot accept your trade offer."); } }
/// <summary> /// On new trade offer event /// </summary> /// <param name="offer">Tradeoffer passed from event</param> private void TradeOfferManager_OnNewTradeOffer(TradeOffer offer) { if (offer.Message == EndPoints.Steam.STORAGE_MESSAGE) { for (int i = 0; i < 10; i++) { try { if (offer.Accept()) { mLog.Write(Log.LogLevel.Success, $"Inhouse trade offer accepted {offer.Items.GetTheirItems().Count} items"); return; } } catch (WebException ex) { mLog.Write(Log.LogLevel.Debug, $"Unable to accept storage offer from {offer.PartnerSteamId}. Retrying in 3s..."); Thread.Sleep(3000); } } mLog.Write(Log.LogLevel.Error, $"Could not accept storage offer..."); } else { mLog.Write(Log.LogLevel.Warn, $"{offer.PartnerSteamId} tried to send {mSettings.username} a trade offer...?"); offer.Decline(); } }
/// <summary> /// Decline a trade offer by id /// </summary> /// <param name="offerId">Trade offer to decline</param> /// <returns>Returns true if declined</returns> public bool DeclineTradeOffer(string offerId) { TradeOffer offer = GetTradeOffer(offerId); if (offer != null) { return(offer.Decline()); } return(false); }
public override void OnNewTradeOffer(TradeOffer offer) { //receiving a trade offer if (IsAdmin) { //parse inventories of bot and other partner //either with webapi or generic inventory //Bot.GetInventory(); //Bot.GetOtherInventory(OtherSID); var myItems = offer.Items.GetMyItems(); var theirItems = offer.Items.GetTheirItems(); Log.Info("They want " + myItems.Count + " of my items."); Log.Info("And I will get " + theirItems.Count + " of their items."); //do validation logic etc if (DummyValidation(myItems, theirItems)) { string tradeid; if (offer.Accept(out tradeid)) { Bot.AcceptAllMobileTradeConfirmations(); Log.Success("Accepted trade offer successfully : Trade ID: " + tradeid); } } else { // maybe we want different items or something //offer.Items.AddMyItem(0, 0, 0); //offer.Items.RemoveTheirItem(0, 0, 0); if (offer.Items.NewVersion) { string newOfferId; string tradeError; if (offer.CounterOffer(out newOfferId, out tradeError)) { Bot.AcceptAllMobileTradeConfirmations(); Log.Success("Counter offered successfully : New Offer ID: " + newOfferId); } } } } else { //we don't know this user so we can decline if (offer.Decline()) { Log.Info("Declined trade offer : " + offer.TradeOfferId + " from untrusted user " + OtherSID.ConvertToUInt64()); } } }
public override void OnNewTradeOffer(TradeOffer offer) { if (IsAdmin) { Log.Info("New Tradeoffer from admin! Accepting and confirming."); //Make this log something somewhere that tells us the trade value of outgoing items. offer.Accept(); Bot.AcceptAllMobileTradeConfirmations(); } else { string password = System.IO.File.ReadAllText(@"../cstrade_admin_password.txt"); string postData = "password="******"&other_steam_id=" + OtherSID.ConvertToUInt64(); string url = "http://skinbonanza.com/backend/check_bot.php"; var updaterequest = (HttpWebRequest)WebRequest.Create(url); var data = Encoding.ASCII.GetBytes(postData); updaterequest.Method = "POST"; updaterequest.ContentType = "application/x-www-form-urlencoded"; updaterequest.ContentLength = data.Length; using (var stream = updaterequest.GetRequestStream()) { stream.Write(data, 0, data.Length); } for (int attempts = 0;; attempts++) { try { var response = (HttpWebResponse)updaterequest.GetResponse(); var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd(); if (responseString.Contains("success")) { Log.Success("Confirming trade from fellow bot."); offer.Accept(); Bot.AcceptAllMobileTradeConfirmations(); } break; } catch (Exception e) { Log.Error(e.Message); if (attempts > 4) { offer.Decline(); throw e; } } } } }
public override void OnNewTradeOffer(TradeOffer offer) { //receiving a trade offer if (IsAdmin) { //parse inventories of bot and other partner //either with webapi or generic inventory //Bot.GetInventory(); //Bot.GetOtherInventory(OtherSID); var myItems = offer.Items.GetMyItems(); var theirItems = offer.Items.GetTheirItems(); Log.Info("They want " + myItems.Count + " of my items."); Log.Info("And I will get " + theirItems.Count + " of their items."); //do validation logic etc if (DummyValidation(myItems, theirItems)) { TradeOfferAcceptResponse acceptResp = offer.Accept(); if (acceptResp.Accepted) { Bot.AcceptAllMobileTradeConfirmations(); Log.Success("Accepted trade offer successfully : Trade ID: " + acceptResp.TradeId); } } else { // maybe we want different items or something //offer.Items.AddMyItem(0, 0, 0); //offer.Items.RemoveTheirItem(0, 0, 0); if (offer.Items.NewVersion) { string newOfferId; if (offer.CounterOffer(out newOfferId)) { Bot.AcceptAllMobileTradeConfirmations(); Log.Success("Counter offered successfully : New Offer ID: " + newOfferId); } } } } else { //we don't know this user so we can decline if (offer.Decline()) { Log.Info("Declined trade offer : " + offer.TradeOfferId + " from untrusted user " + OtherSID.ConvertToUInt64()); } } }
public override void OnNewTradeOffer(TradeOffer offer) { if (IsAdmin) { offer.Accept(); Log.Success("Accepted trade offer from admin {0}.", Bot.SteamFriends.GetFriendPersonaName(OtherSID)); SendChatMessage("Trade offer complete."); } else { offer.Decline(); Log.Warn("Declined trade offer from user {0}.", OtherSID.ToString()); SendChatMessage("I don't know you. I cannot accept your trade offer."); } }
private void PartenarTradeOfferUpdated(TradeOffer offer) { Console.WriteLine("Received offer {0} has been updated, status : {1}", offer.TradeOfferId, offer.OfferState.ToString()); if (offer.OfferState == TradeOfferState.TradeOfferStateActive) { if (offer.Items.GetMyItems().Count == 0) { offer.Accept(); } else { offer.Decline(); } } }
public override void OnNewTradeOffer(TradeOffer offer) { var escrow = Bot.GetEscrowDuration(offer.TradeOfferId); if (escrow.DaysMyEscrow != 0 || escrow.DaysTheirEscrow != 0) { doWebWithCatch(1, () => { if (offer.Decline()) { Log.Error("User has not been using the Mobile Authenticator for 7 days or has turned off trade confirmations, offer declined."); } }); } else { //Get password from file on desktop string pass = Bot.BotDBPassword; //Get items in the trade, and ID of user sending trade var theirItems = offer.Items.GetTheirItems(); var myItems = offer.Items.GetMyItems(); var userID = offer.PartnerSteamId; bool shouldDecline = false; //Check if they are trying to get items from the bot if (myItems.Count > 0 || theirItems.Count == 0) { //shouldDecline = true; Log.Error("Offer declined because the offer wasn't a gift; the user wanted items instead of giving."); } //Check to make sure all items are for CS: GO. foreach (TradeAsset item in theirItems) { if (item.AppId != 730) { shouldDecline = true; Log.Error("Offer declined because one or more items was not for CS: GO."); } } //Check if there are more than 10 items in the trade if (theirItems.Count > 5) { shouldDecline = true; Log.Error("Offer declined because there were more than 5 items in the deposit."); } if (shouldDecline) { doWebWithCatch(1, () => { if (offer.Decline()) { Log.Error("Offer declined."); } }); return; } Log.Success("Offer approved, accepting."); //Send items to server and check if all items add up to more than $1. //If they do, accept the trade. If they don't, decline the trade. string postData = "password="******"&owner=" + userID; string theirItemsJSON = JsonConvert.SerializeObject(theirItems); postData += "&items=" + theirItemsJSON; string url = Bot.BotWebsiteURL + "/php/check-items.php"; var request = (HttpWebRequest)WebRequest.Create(url); var data = Encoding.ASCII.GetBytes(postData); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = data.Length; using (var stream = request.GetRequestStream()) { stream.Write(data, 0, data.Length); } var response = (HttpWebResponse)request.GetResponse(); var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd(); //Uncomment this line to view the response from check-items.php //Log.Success ("Response received from check-items.php: \n" + responseString); JSONClass responseJsonObj = JsonConvert.DeserializeObject<JSONClass>(responseString); if (responseJsonObj.success == 1) { //Get data array from json var jsonData = responseJsonObj.data; if (jsonData.minDeposit == 1) { doWebWithCatch(10, () => { if (offer.Accept()) { Log.Success("Offer accepted from " + userID); //Put items into the pot string urlPutItemsIn = Bot.BotWebsiteURL + "/php/deposit.php"; var requestUrlPutItemsIn = (HttpWebRequest)WebRequest.Create(urlPutItemsIn); string postDataPutItemsIn = "password="******"&owner=" + userID; postDataPutItemsIn += "&items=" + jsonData.allItems; //Log.Success (jsonData.allItems); var dataPutItemsIn = Encoding.ASCII.GetBytes(postDataPutItemsIn); requestUrlPutItemsIn.Method = "POST"; requestUrlPutItemsIn.ContentType = "application/x-www-form-urlencoded"; requestUrlPutItemsIn.ContentLength = dataPutItemsIn.Length; using (var stream = requestUrlPutItemsIn.GetRequestStream()) { stream.Write(dataPutItemsIn, 0, dataPutItemsIn.Length); } var responsePutItemsIn = (HttpWebResponse)requestUrlPutItemsIn.GetResponse(); string responsePutItemsInString = new StreamReader(responsePutItemsIn.GetResponseStream()).ReadToEnd(); //Uncomment this line to view the response from deposit.php //Log.Success ("Response received from deposit.php: " + responsePutItemsInString); JSONClass responseJsonObjPutItemsIn = JsonConvert.DeserializeObject<JSONClass>(responsePutItemsInString); jsonData = responseJsonObjPutItemsIn.data; } }); //Check if it should start the timer if (jsonData.startTimer == 1) { //Check if the timer is already running. if (!timerRunning) { timer = new System.Timers.Timer(); timer.Elapsed += new ElapsedEventHandler(timerEvent); timer.Interval = 1000; timer.Start(); timerRunning = true; } } //Check if the pot is over if (jsonData.potOver == 1) { //End the timer timerTime = 0; timer.Stop(); //Get items to give and keep, and the winner and their trade token var itemsToGive = jsonData.tradeItems; var itemsToKeep = jsonData.profitItems; string winnerSteamIDString = jsonData.winnerSteamId; SteamID winnerSteamID = new SteamID(winnerSteamIDString); string winnerTradeToken = jsonData.winnerTradeToken; Log.Success("Winner steam id: " + winnerSteamIDString + ", token: " + winnerTradeToken); //Get bot's inventory json string botInvUrl = "http://steamcommunity.com/profiles/" + Bot.SteamUser.SteamID.ConvertToUInt64() + "/inventory/json/730/2"; var botInvRequest = (HttpWebRequest)WebRequest.Create(botInvUrl); var botInvResponse = (HttpWebResponse)botInvRequest.GetResponse(); string botInvString = new StreamReader(botInvResponse.GetResponseStream()).ReadToEnd(); BotInventory botInventory = JsonConvert.DeserializeObject<BotInventory>(botInvString); if (botInventory.success != true) { Log.Error("An error occured while fetching the bot's inventory."); return; } var rgInventory = botInventory.rgInventory; //Create trade offer for the winner var winnerTradeOffer = Bot.NewTradeOffer(winnerSteamID); //Loop through all winner's items and add them to trade List<long> alreadyAddedToWinnerTrade = new List<long>(); foreach (CSGOItemFromWeb item in itemsToGive) { long classId = item.classId, instanceId = item.instanceId; //Loop through all inventory items and find the asset id for the item long assetId = 0; foreach (var inventoryItem in rgInventory) { var value = inventoryItem.Value; long tAssetId = value.id, tClassId = value.classid, tInstanceId = value.instanceid; if (tClassId == classId && tInstanceId == instanceId) { //Check if this assetId has already been added to the trade if (alreadyAddedToWinnerTrade.Contains(tAssetId)) { continue; //This is for when there are 2 of the same weapon, but they have different assetIds } assetId = tAssetId; break; } } //Log.Success ("Adding item to winner trade offer. Asset ID: " + assetId); winnerTradeOffer.Items.AddMyItem(730, 2, assetId, 1); alreadyAddedToWinnerTrade.Add(assetId); } //Send trade offer to winner if (itemsToGive.Count > 0) { string winnerTradeOfferId, winnerMessage = "Congratulations, you have won on " + Bot.BotWebsiteName + "! Here are your items."; doWebWithCatch(-1, () => { if (winnerTradeOffer.SendWithToken(out winnerTradeOfferId, winnerTradeToken, winnerMessage)) { Bot.AcceptAllMobileTradeConfirmations(); Log.Success("Offer sent to winner."); } }); } else { Log.Info("No items to give... strange"); } //Now, send all of the profit items to my own account //Put your own Steam ID here var profitTradeOffer = Bot.NewTradeOffer(new SteamID(Bot.ProfitAdmin)); //Loop through all profit items and add them to trade List<long> alreadyAddedToProfitTrade = new List<long>(); foreach (CSGOItemFromWeb item in itemsToKeep) { long classId = item.classId, instanceId = item.instanceId; //Loop through all inventory items and find the asset id for the item long assetId = 0; foreach (var inventoryItem in rgInventory) { var value = inventoryItem.Value; long tAssetId = value.id, tClassId = value.classid, tInstanceId = value.instanceid; if (tClassId == classId && tInstanceId == instanceId) { //Check if this assetId has already been added to the trade if (alreadyAddedToProfitTrade.Contains(tAssetId)) { continue; //This is for when there are 2 of the same weapon, but they have different assetIds } assetId = tAssetId; break; } } //Log.Success ("Adding item to winner trade offer. Asset ID: " + assetId); profitTradeOffer.Items.AddMyItem(730, 2, assetId, 1); alreadyAddedToProfitTrade.Add(assetId); } //Send trade offer to myself with profit items Log.Success(itemsToKeep.Count + ""); if (itemsToKeep.Count > 0) { string profitTradeOfferId, profitMessage = "Here are the profit items from the round."; doWebWithCatch(10, () => { if (profitTradeOffer.Send(out profitTradeOfferId, profitMessage)) { //Don't need the token because I am friends with the bot. Bot.AcceptAllMobileTradeConfirmations(); Log.Success("Profit trade offer sent."); } }); } } else { //Only try this one time, because even if it gives an error, it still gets declined. doWebWithCatch(1, () => { if (offer.Decline()) { Log.Error("Server deposit request failed, declining trade. Error message:\n" + responseJsonObj.errMsg); } }); } } else { //Only try this one time, because even if it gives an error, it still gets declined. doWebWithCatch(1, () => { if (offer.Decline()) { Log.Error("Minimum deposit not reached, offer declined."); } }); } } } }
public bool DeclineOffer(Offer offer) { var tradeOffer = new TradeOffer(session, offer); return(tradeOffer.Decline()); }
public override void OnNewTradeOffer(TradeOffer offer) { //Get password from file on desktop string pass = System.IO.File.ReadAllText(@"C:\Users\Jordan Turley\Desktop\password.txt"); //Get items in the trade, and ID of user sending trade var theirItems = offer.Items.GetTheirItems(); var myItems = offer.Items.GetMyItems(); var userID = offer.PartnerSteamId; bool shouldDecline = false; //Check if they are trying to get items from the bot if (myItems.Count > 0 || theirItems.Count == 0) { shouldDecline = true; Log.Error("Offer declined because the offer wasn't a gift; the user wanted items instead of giving."); } //Check to make sure all items are for CS: GO. foreach (TradeAsset item in theirItems) { if (item.AppId != 730) { shouldDecline = true; Log.Error("Offer declined because one or more items was not for CS: GO."); } } //Check if there are more than 10 items in the trade if (theirItems.Count > 10) { shouldDecline = true; Log.Error("Offer declined because there were more than 10 items in the deposit."); } if (shouldDecline) { if (offer.Decline()) { Log.Error("Offer declined."); } return; } Log.Success("Offer approved, accepting."); //Send items to server and check if all items add up to more than $1. //If they do, accept the trade. If they don't, decline the trade. string postData = "password="******"&owner=" + userID; string theirItemsJSON = JsonConvert.SerializeObject(theirItems); postData += "&items=" + theirItemsJSON; string url = "http://csgowinbig.com/php/check-items.php"; var request = (HttpWebRequest)WebRequest.Create(url); var data = Encoding.ASCII.GetBytes(postData); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = data.Length; using (var stream = request.GetRequestStream()) { stream.Write(data, 0, data.Length); } var response = (HttpWebResponse)request.GetResponse(); var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd(); //Log.Success ("Response received from server: \n" + responseString); JSONClass responseJsonObj = JsonConvert.DeserializeObject <JSONClass> (responseString); if (responseJsonObj.success == 1) { //Get data array from json var jsonData = responseJsonObj.data; if (jsonData.minDeposit == 1) { if (offer.Accept()) { Log.Success("Offer accepted from " + userID); //Put items into the pot string urlPutItemsIn = "http://csgowinbig.com/php/deposit.php"; var requestUrlPutItemsIn = (HttpWebRequest)WebRequest.Create(urlPutItemsIn); string postDataPutItemsIn = "password="******"&owner=" + userID; postDataPutItemsIn += "&items=" + jsonData.allItems; //Log.Success (jsonData.allItems); var dataPutItemsIn = Encoding.ASCII.GetBytes(postDataPutItemsIn); requestUrlPutItemsIn.Method = "POST"; requestUrlPutItemsIn.ContentType = "application/x-www-form-urlencoded"; requestUrlPutItemsIn.ContentLength = dataPutItemsIn.Length; using (var stream = requestUrlPutItemsIn.GetRequestStream()) { stream.Write(dataPutItemsIn, 0, dataPutItemsIn.Length); } var responsePutItemsIn = (HttpWebResponse)requestUrlPutItemsIn.GetResponse(); string responsePutItemsInString = new StreamReader(responsePutItemsIn.GetResponseStream()).ReadToEnd(); JSONClass responseJsonObjPutItemsIn = JsonConvert.DeserializeObject <JSONClass> (responsePutItemsInString); jsonData = responseJsonObjPutItemsIn.data; } //Check if the pot is over if (jsonData.potOver == 1) { //Get items to give and keep, and the winner and their trade token var itemsToGive = jsonData.tradeItems; var itemsToKeep = jsonData.profitItems; string winnerSteamIDString = jsonData.winnerSteamID; SteamID winnerSteamID = new SteamID(winnerSteamIDString); string winnerTradeToken = jsonData.winnerTradeToken; Log.Success("Winner steam id: " + winnerSteamIDString + ", token: " + winnerTradeToken); //Get bot's inventory json string botInvUrl = "http://steamcommunity.com/profiles/76561198238743988/inventory/json/730/2"; var botInvRequest = (HttpWebRequest)WebRequest.Create(botInvUrl); var botInvResponse = (HttpWebResponse)botInvRequest.GetResponse(); string botInvString = new StreamReader(botInvResponse.GetResponseStream()).ReadToEnd(); BotInventory botInventory = JsonConvert.DeserializeObject <BotInventory> (botInvString); if (botInventory.success != true) { Log.Error("An error occured while fetching the bot's inventory."); return; } var rgInventory = botInventory.rgInventory; //Create trade offer for the winner var winnerTradeOffer = Bot.NewTradeOffer(winnerSteamID); //Loop through all winner's items and add them to trade List <long> alreadyAddedToWinnerTrade = new List <long> (); foreach (CSGOItemFromWeb item in itemsToGive) { long classId = item.classId, instanceId = item.instanceId; //Loop through all inventory items and find the asset id for the item long assetId = 0; foreach (var inventoryItem in rgInventory) { var value = inventoryItem.Value; long tAssetId = value.id, tClassId = value.classid, tInstanceId = value.instanceid; if (tClassId == classId && tInstanceId == instanceId) { //Check if this assetId has already been added to the trade if (alreadyAddedToWinnerTrade.Contains(tAssetId)) { continue; //This is for when there are 2 of the same weapon, but they have different assetIds } assetId = tAssetId; break; } } //Log.Success ("Adding item to winner trade offer. Asset ID: " + assetId); winnerTradeOffer.Items.AddMyItem(730, 2, assetId, 1); alreadyAddedToWinnerTrade.Add(assetId); } //Send trade offer to winner if (itemsToGive.Count > 0) { string winnerTradeOfferId, winnerMessage = "Congratulations, you have won on CSGO Win Big! Here are your items."; winnerTradeOffer.SendWithToken(out winnerTradeOfferId, winnerTradeToken, winnerMessage); Log.Success("Offer sent to winner."); } else { Log.Info("No items to give... strange"); } } } else { if (offer.Decline()) { Log.Error("Minimum deposit not reached, offer declined."); } } } else { Log.Error("Server deposit request failed, declining trade. Error message:\n" + responseJsonObj.errMsg); offer.Decline(); } }
public override void OnNewTradeOffer(TradeOffer offer) { if (offer.OfferState != TradeOfferState.TradeOfferStateActive) { return; } Log.Debug("Trade offer from user {0}.", OtherSID.ToString()); if (IsAdmin) { offer.Accept(); Log.Success("Accepted trade offer from admin '{0}'.", Bot.SteamFriends.GetFriendPersonaName(OtherSID)); SendChatMessage("Trade offer complete."); Console.Beep(); } else { bool? hasMatchingOrder = Bot.Orders.HasMatchingOrder(this, offer); Order ord = Bot.Orders.GetMatchingOrder(this, offer); bool isFullStock = IsFullStock(ord); if (hasMatchingOrder == true && !isFullStock) { offer.Accept(); Log.Success("Accepted valid trade offer from user {0}.", OtherSID.ToString()); SendChatMessage("I have accepted your trade offer."); SendChatToAdmins("Accepted trade offer from user {0}: {1}", OtherSID.ToString(), ord.ToString(Trade.CurrentSchema, true)); Console.Beep(); } else if (isFullStock) { offer.Decline(); Log.Warn("Declined trade offer from user {0}, as stock was full."); SendChatMessage("Unfortunately I seem to have full stock of that item. Your offer has been declined."); } else if (hasMatchingOrder != null) { offer.Decline(); Log.Warn("Declined invalid trade offer from user {0}.", OtherSID.ToString()); SendChatMessage("There seems to be a problem with your trade offer. It has been declined."); } else { SendChatMessage("Unable to retrieve your inventory, and thus am unable to respond to your offer."); //SendChatToAdmins("There was an error retrieving the inventory of {0}.", OtherSID.ToString()); } //offer.Decline(); //Log.Warn("Declined trade offer from user {0}.", OtherSID.ToString()); //SendChatMessage("I don't know you. I cannot accept your trade offer."); } }
public override void OnNewTradeOffer(TradeOffer offer) { var escrow = Bot.GetEscrowDuration(offer.TradeOfferId); Log.Success (escrow.DaysMyEscrow + " | " + escrow.DaysTheirEscrow); //Code for limiting pot for only specific users /* if (offer.PartnerSteamId.ConvertToUInt64() != 76561198020620333 && offer.PartnerSteamId.ConvertToUInt64() != 76561197995164153) { if (offer.Decline ()) { Log.Error ("Not one of the 2 verified accounts."); return; } } */ if (escrow.DaysMyEscrow != 0) { doWebWithCatch(1, () => { if (offer.Decline()) { Log.Error("This bot has not been using the Mobile Authenticator for 7 days or has turned off trade confirmations, offer declined."); } }); } else if (escrow.DaysTheirEscrow != 0) { doWebWithCatch(1, () => { if (offer.Decline()) { Log.Error("User has not been using the Mobile Authenticator for 7 days or has turned off trade confirmations, offer declined."); } }); } else { //Get password from bot configuration file string pass = Bot.BotDBPassword; //Get items in the trade, and ID of user sending trade var theirItems = offer.Items.GetTheirItems(); var myItems = offer.Items.GetMyItems(); bool shouldDecline = false; //Check if they are trying to get items from the bot if (myItems.Count > 0 || theirItems.Count == 0) { //shouldDecline = true; Log.Error("Offer declined because the offer wasn't a gift; the user wanted items instead of giving."); } //Check to make sure all items are for CS: GO. foreach (TradeAsset item in theirItems) { if (item.AppId != 730) { shouldDecline = true; Log.Error("Offer declined because one or more items was not for CS: GO."); } } //Check if there are more than 10 items in the trade if (theirItems.Count > 10) { shouldDecline = true; Log.Error("Offer declined because there were more than 10 items in the deposit."); } if (shouldDecline) { doWebWithCatch(1, () => { if (offer.Decline()) { Log.Error("Offer declined."); } }); return; } Log.Success("Offer approved, accepting."); //Send items to server and check if all items add up to more than the minimum deposit. //If they do, accept the trade. If they don't, decline. if (timerTime <= 15) { acceptTrade (offer); } else { Log.Success ("Offer sent within 15 seconds of round end, delaying to next round."); System.Timers.Timer acceptDelayTimer = new System.Timers.Timer (); acceptDelayTimer.Interval = 20000; //20 seconds acceptDelayTimer.Elapsed += delegate { acceptTrade (offer); acceptDelayTimer.Stop (); }; acceptDelayTimer.Start (); } } }
private void acceptTrade(TradeOffer offer) { string pass = Bot.BotDBPassword; List<TradeAsset> theirItems = offer.Items.GetTheirItems (); SteamID userID = offer.PartnerSteamId; string postData = "password="******"&owner=" + userID; string theirItemsJSON = JsonConvert.SerializeObject(theirItems); postData += "&items=" + theirItemsJSON; string url = Bot.BotWebsiteURL + "/php/check-items.php"; var request = (HttpWebRequest)WebRequest.Create(url); var data = Encoding.ASCII.GetBytes(postData); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = data.Length; using (var stream = request.GetRequestStream()) { stream.Write(data, 0, data.Length); } var response = (HttpWebResponse)request.GetResponse(); var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd(); //Uncomment this line to view the response from check-items.php Log.Success ("Response received from check-items.php: \n" + responseString); JSONClass responseJsonObj = JsonConvert.DeserializeObject<JSONClass>(responseString); if (responseJsonObj.success == 1) { //Get data array from json var jsonData = responseJsonObj.data; if (jsonData.minDeposit == 1) { doWebWithCatch (10, () => { if (offer.Accept ()) { Log.Success ("Offer accepted from " + userID); //Put items into the pot string urlPutItemsIn = Bot.BotWebsiteURL + "/php/deposit.php"; var requestUrlPutItemsIn = (HttpWebRequest)WebRequest.Create (urlPutItemsIn); string postDataPutItemsIn = "password="******"&owner=" + userID; postDataPutItemsIn += "&items=" + jsonData.allItems; //Log.Success (jsonData.allItems); var dataPutItemsIn = Encoding.ASCII.GetBytes (postDataPutItemsIn); requestUrlPutItemsIn.Method = "POST"; requestUrlPutItemsIn.ContentType = "application/x-www-form-urlencoded"; requestUrlPutItemsIn.ContentLength = dataPutItemsIn.Length; using (var stream = requestUrlPutItemsIn.GetRequestStream ()) { stream.Write (dataPutItemsIn, 0, dataPutItemsIn.Length); } var responsePutItemsIn = (HttpWebResponse)requestUrlPutItemsIn.GetResponse (); string responsePutItemsInString = new StreamReader (responsePutItemsIn.GetResponseStream ()).ReadToEnd (); //Uncomment this line to view the response from deposit.php //Log.Success ("Response received from deposit.php: " + responsePutItemsInString); JSONClass responseJsonObjPutItemsIn = JsonConvert.DeserializeObject<JSONClass> (responsePutItemsInString); jsonData = responseJsonObjPutItemsIn.data; } }); //Check if it should start the timer if (jsonData.startTimer == 1) { //Check if the timer is already running. if (!timerRunning) { timer = new System.Timers.Timer (); timer.Elapsed += new ElapsedEventHandler (timerEvent); timer.Interval = 1000; timer.Start (); timerRunning = true; } } //Check if the pot is over if (jsonData.potOver == 1) { //End the timer timerTime = 0; timer.Stop (); sendWinnings (responseJsonObj); } else { //Only try this one time, because even if it gives an error, it still gets declined. doWebWithCatch (1, () => { if (offer.Decline ()) { Log.Error ("Server deposit request failed, declining trade. Error message:\n" + responseJsonObj.errMsg); } }); } } else { //Only try this one time, because even if it gives an error, it still gets declined. doWebWithCatch (1, () => { if (offer.Decline ()) { Log.Error ("Minimum deposit not reached, offer declined."); } }); } } else { doWebWithCatch (1, () => { if (offer.Decline ()) { Log.Error ("The depositor's inventory could not be accessed."); } }); } }
public override void OnTradeOfferUpdated(TradeOffer offer) { //Log.Info($"Handling offer. Message: [{offer.Message}]"); switch (offer.OfferState) { case TradeOfferState.TradeOfferStateAccepted: return; case TradeOfferState.TradeOfferStateActive: var their = offer.Items.GetTheirItems(); var my = offer.Items.GetMyItems(); if (my.Count == 0) { var tradeAccept = offer.Accept(); if (tradeAccept.Accepted) { string st = "Offer completed."; if (their.Count != 0) { st += " Received: " + their.Count + " items."; } Log.Warn(st); return; } else { if (tradeAccept.TradeError.Length == 0) { Log.Error("Could not accept for unknown reason. Restarting bot"); try { offer.Decline(); } catch { } Bot.MarketBot.GetLog().Error(CSGOTM.TMBot.RestartPriority.CriticalError, "Could not accept for unknown reason. Restarting bot"); } else { Bot.MarketBot.GetLog().Error($"Could not accept offer {tradeAccept.TradeError}."); } } break; } long aid = -1, cid = -1; bool unstable = false; foreach (var item in their) { if (aid == -1) { aid = item.AppId; } else { if (aid != item.AppId) { unstable = true; } aid = item.AppId; } if (cid == -1) { cid = item.ContextId; } else { if (cid != item.ContextId) { unstable = true; } cid = item.ContextId; } } foreach (var item in my) { if (aid == -1) { aid = item.AppId; } else { if (aid != item.AppId) { unstable = true; } aid = item.AppId; } if (cid == -1) { cid = item.ContextId; } else { if (cid != item.ContextId) { unstable = true; } cid = item.ContextId; } } string appid_contextid; if (unstable) { appid_contextid = "unstable"; } else { appid_contextid = aid + "-" + cid; } switch (appid_contextid) { case "730-2": if (my.Count > 0 && !offer.IsOurOffer) //if the offer is bad we decline it. { offer.Decline(); Log.Error("Offer failed. Invalid trade request. (not issued by me, has my items there)"); return; } else { if (offer.IsOurOffer) { Log.Info("Doing nothing, this is my offer."); break; } var tradeAccept = offer.Accept(); if (tradeAccept.Accepted) { string st = "Offer completed."; if (their.Count != 0) { st += " Received: " + their.Count + " items."; } if (my.Count != 0) { st += " Lost: " + my.Count + " items."; } Log.Warn(st); return; } else { Log.Error($"Could not accept offer: {tradeAccept.TradeError}"); return; } } case "unstable": break; default: break; } return; case TradeOfferState.TradeOfferStateNeedsConfirmation: return; case TradeOfferState.TradeOfferStateInEscrow: return; case TradeOfferState.TradeOfferStateCountered: return; case TradeOfferState.TradeOfferStateCanceled: return; case TradeOfferState.TradeOfferStateCanceledBySecondFactor: return; case TradeOfferState.TradeOfferStateInvalidItems: return; case TradeOfferState.TradeOfferStateDeclined: return; default: Log.Info($"Trade offer {offer.TradeOfferId} failed, status is {offer.OfferState}"); return; } }
public override void OnNewTradeOffer(TradeOffer offer) { //receiving a trade offer if (IsAdmin) { //parse inventories of bot and other partner //either with webapi or generic inventory //Bot.GetInventory(); //Bot.GetOtherInventory(OtherSID); var myItems = offer.Items.GetMyItems(); var theirItems = offer.Items.GetTheirItems(); Log.Info("They want " + myItems.Count + " of my items."); Log.Info("And I will get " + theirItems.Count + " of their items."); //do validation logic etc if (DummyValidation(myItems, theirItems)) { string tradeid; if (offer.Accept(out tradeid)) { if (myItems.Count > 0 && Bot.SteamGuardAccount != null) { // confirmation is needed if bot is giving away items and mobile auth is linked if (Bot.AcceptTradeConfirmation(tradeid)) { Log.Success("Accepted trade offer successfully : Trade ID: " + tradeid); } else { Log.Error("Failed to confirm trade offer #{0}!", tradeid); } } else if (Bot.SteamGuardAccount == null) { Log.Success("Accepted trade offer successfully : Trade ID: " + tradeid); } } } else { // maybe we want different items or something //offer.Items.AddMyItem(0, 0, 0); //offer.Items.RemoveTheirItem(0, 0, 0); if (offer.Items.NewVersion) { string newOfferId; if (offer.CounterOffer(out newOfferId)) { if (myItems.Count > 0 && Bot.SteamGuardAccount != null) { // confirmation is needed if bot is giving away items and mobile auth is linked if (Bot.AcceptTradeConfirmation(newOfferId)) { Log.Success("Counter offered successfully : New Offer ID: " + newOfferId); } else { Log.Error("Failed to confirm trade offer #{0}!", newOfferId); } } else if (Bot.SteamGuardAccount == null) { Log.Success("Counter offered successfully : New Offer ID: " + newOfferId); } } } } } else { //we don't know this user so we can decline if (offer.Decline()) { Log.Info("Declined trade offer : " + offer.TradeOfferId + " from untrusted user " + OtherSID.ConvertToUInt64()); } } }
public override void OnNewTradeOffer(TradeOffer offer) { var myItems = offer.Items.GetMyItems(); var theirItems = offer.Items.GetTheirItems(); Log.Info("They want " + myItems.Count + " of my items."); Log.Info("And I will get " + theirItems.Count + " of their items."); //TODO: What happens when you have multiple trade offer comming in... TradeId = offer.TradeOfferId; //TODO: Add real validation if (Validate(theirItems)) { string tradeid; if (offer.Accept(out tradeid)) { Log.Success("Accepted trade offer successfully : Trade ID: " + tradeid); } } else { //Doesn't validate if (offer.Decline()) { Log.Info("Declined trade offer : " + offer.TradeOfferId + " from untrusted user " + OtherSID.ConvertToUInt64()); } } }
public override void OnNewTradeOffer(TradeOffer offer) { var escrow = Bot.GetEscrowDuration(offer.TradeOfferId); Log.Success(escrow.DaysMyEscrow + " | " + escrow.DaysTheirEscrow); //Code for limiting pot for only specific users /* if (offer.PartnerSteamId.ConvertToUInt64() != 76561198020620333 && offer.PartnerSteamId.ConvertToUInt64() != 76561197995164153) { * if (offer.Decline ()) { * Log.Error ("Not one of the 2 verified accounts."); * return; * } * } */ if (escrow.DaysMyEscrow != 0) { doWebWithCatch(1, () => { if (offer.Decline()) { Log.Error("This bot has not been using the Mobile Authenticator for 7 days or has turned off trade confirmations, offer declined."); } }); } else if (escrow.DaysTheirEscrow != 0) { doWebWithCatch(1, () => { if (offer.Decline()) { Log.Error("User has not been using the Mobile Authenticator for 7 days or has turned off trade confirmations, offer declined."); } }); } else { //Get password from bot configuration file string pass = Bot.BotDBPassword; //Get items in the trade, and ID of user sending trade var theirItems = offer.Items.GetTheirItems(); var myItems = offer.Items.GetMyItems(); bool shouldDecline = false; //Check if they are trying to get items from the bot if (myItems.Count > 0 || theirItems.Count == 0) { //shouldDecline = true; Log.Error("Offer declined because the offer wasn't a gift; the user wanted items instead of giving."); } //Check to make sure all items are for CS: GO. foreach (TradeAsset item in theirItems) { if (item.AppId != 730) { shouldDecline = true; Log.Error("Offer declined because one or more items was not for CS: GO."); } } //Check if there are more than 10 items in the trade if (theirItems.Count > 10) { shouldDecline = true; Log.Error("Offer declined because there were more than 10 items in the deposit."); } if (shouldDecline) { doWebWithCatch(1, () => { if (offer.Decline()) { Log.Error("Offer declined."); } }); return; } Log.Success("Offer approved, accepting."); //Send items to server and check if all items add up to more than the minimum deposit. //If they do, accept the trade. If they don't, decline. if (timerTime <= 15) { acceptTrade(offer); } else { Log.Success("Offer sent within 15 seconds of round end, delaying to next round."); System.Timers.Timer acceptDelayTimer = new System.Timers.Timer(); acceptDelayTimer.Interval = 20000; //20 seconds acceptDelayTimer.Elapsed += delegate { acceptTrade(offer); acceptDelayTimer.Stop(); }; acceptDelayTimer.Start(); } } }
public override void OnTradeOfferUpdated(TradeOffer offer) { var escowDuration = Bot.GetEscrowDuration(offer.TradeOfferId); var error = Bot.CheckIfBotCanAcceptTradeOffer(offer.TradeOfferId); if (error != null) { Log.Warn(error); if (error.Contains("unable to trade")) { SendChatMessage("Bot Unable to Trade. Please Cancel your trade Offer"); return; } if (error.Contains("This trade offer is no longer valid.")) { return; } } var itemsTuple = GetItems(offer); var ourItemString = Environment.NewLine + string.Join(Environment.NewLine + " ", itemsTuple.Item1.Select(i => i.ToString())); var theirItemString = Environment.NewLine + string.Join(Environment.NewLine + " ", itemsTuple.Item2.Select(i => i.ToString())); Log.Info($"Order Update from {Bot.SteamFriends.GetFriendPersonaName(offer.PartnerSteamId)} OrderId = " + offer.TradeOfferId); Log.Info("They want " + ourItemString); Log.Info("I will get " + theirItemString); double price = Bot.Valuate(itemsTuple.Item1, itemsTuple.Item2); var transaction = Bot .UpdateTradeOffer(new TradeOfferTransaction(offer.TradeOfferId), DataAccessActionType.Retrieve); var oldTransaction = transaction; if (transaction == null) { transaction = new TradeOfferTransaction(offer, TradeOfferTransactionState.New, price, Bot); } else { transaction = new TradeOfferTransaction(transaction, offer); } Log.Info(transaction); if (transaction.State != TradeOfferTransactionState.Paid && oldTransaction?.State == transaction.State && oldTransaction?.OfferState == transaction.OfferState) //force update paid status { Log.Info("Incoming TradeOffer is not updated, Skip"); return; } switch (offer.OfferState) { case TradeOfferState.TradeOfferStateAccepted: Log.Info($"Trade offer {offer.TradeOfferId} from {Bot.SteamFriends.GetFriendPersonaName(offer.PartnerSteamId)} has been completed!"); transaction = new TradeOfferTransaction(transaction, TradeOfferTransactionState.Completed); SendChatMessage("Trade completed, thank you!"); Log.Info("Update the Offer..."); Bot.UpdateTradeOffer(transaction, DataAccessActionType.UpdateTradeOffer); return; case TradeOfferState.TradeOfferStateActive: Log.Info("Update the Offer..."); Bot .UpdateTradeOffer(transaction, DataAccessActionType.UpdateTradeOffer); if (!offer.IsOurOffer) { switch (transaction.State) { case TradeOfferTransactionState.New: Log.Info("New Trade Found"); if (escowDuration.DaysMyEscrow > 0) { SendChatMessage( $"WARNING!!!!! This Bot is under Trade escowDuration and the items you buying will be hold by steam for {escowDuration.DaysMyEscrow}, if you don't want to proceed please cancel the tradeoffer and do not pay"); } if (escowDuration.DaysTheirEscrow > 0) { SendChatMessage( $"WARNING!!!!! You are under Trade escowDuration and the items you buying will be hold by steam for {escowDuration.DaysMyEscrow}, if you don't want to proceed please cancel the tradeoffer and do not pay"); } SendChatMessage($"Please pay SGD ${transaction.Price} to {"Kiljaeden"} for Order {transaction.Id}"); break; case TradeOfferTransactionState.Paid: case TradeOfferTransactionState.Completed: Log.Info($"Existing Trade, Paid completed {transaction.Id}"); Bot.PaymentNotifySelf(transaction); break; case TradeOfferTransactionState.PartialPaid: Log.Info($"Existing Trade, Partial Paid, Price = {transaction.Price}, PaidAmmount = {transaction.PaidAmmount} {transaction.Id}"); SendChatMessage( $"Please pay SGD ${transaction.Price - transaction.PaidAmmount} to {"Kiljaeden"} for Order {transaction.Id}"); break; case TradeOfferTransactionState.Expired: Log.Info($"Existing Trade, Transaction Expired"); SendChatMessage( $"Payment Period Expired for Order {transaction.Id}"); offer.Decline(); break; default: throw new ArgumentOutOfRangeException(); } } break; case TradeOfferState.TradeOfferStateNeedsConfirmation: Log.Info("Update the Offer..."); Bot .UpdateTradeOffer(transaction, DataAccessActionType.UpdateTradeOffer); Log.Info($"Trade offer {offer.TradeOfferId} from {Bot.SteamFriends.GetFriendPersonaName(offer.PartnerSteamId)} Needs Confirmation - " + Environment.NewLine + "Bot:" + (offer.Items.GetMyItems().Count > 0) + Environment.NewLine + "{Bot.SteamFriends.GetFriendPersonaName(offer.PartnerSteamId)}: " + (offer.Items.GetTheirItems().Count > 0)); switch (transaction.State) { case TradeOfferTransactionState.Completed: if (offer.Items.GetTheirItems().Count > 0) { SendChatMessage($"Please Confirm Trade"); } break; case TradeOfferTransactionState.Paid: if (offer.Items.GetTheirItems().Count > 0) { SendChatMessage($"Please Confirm Trade"); } Bot.PaymentNotifySelf(transaction); break; case TradeOfferTransactionState.New: case TradeOfferTransactionState.PartialPaid: Log.Error("Trade reachs confirmation stage but transaction is at " + transaction.State); break; } break; case TradeOfferState.TradeOfferStateInEscrow: Log.Info("Update the Offer..."); Bot .UpdateTradeOffer(transaction, DataAccessActionType.UpdateTradeOffer); Log.Info($"Trade offer {offer.TradeOfferId} from {Bot.SteamFriends.GetFriendPersonaName(offer.PartnerSteamId)} in Escow"); switch (transaction.State) { case TradeOfferTransactionState.Completed: Log.Info($"Trade offer {offer.TradeOfferId} from {Bot.SteamFriends.GetFriendPersonaName(offer.PartnerSteamId)} Needs {(offer.IsOurOffer ? "bot" : offer.TradeOfferId)} Confirmation"); string @object = offer.IsOurOffer ? "Bot's" : "Your"; Log.Info($"Existing Trade, Paid completed {transaction.Id}¡£ Due to {@object} Account Limitation, the Trade is on-hold by steam"); SendChatMessage($"Due to {@object} Account Limitation, the Trade is on-hold by steam"); break; case TradeOfferTransactionState.New: case TradeOfferTransactionState.Paid: case TradeOfferTransactionState.PartialPaid: Log.Error("Trade reachs escow stage but transaction is at " + transaction.State); break; } break; case TradeOfferState.TradeOfferStateCountered: Log.Info("Update the Offer..."); Bot .UpdateTradeOffer(transaction, DataAccessActionType.UpdateTradeOffer); Log.Info($"Trade offer {offer.TradeOfferId} was countered by " + (offer.IsOurOffer ? "bot" : Bot.SteamFriends.GetFriendPersonaName(offer.PartnerSteamId))); break; case TradeOfferState.TradeOfferStateInvalid: case TradeOfferState.TradeOfferStateExpired: case TradeOfferState.TradeOfferStateCanceled: case TradeOfferState.TradeOfferStateDeclined: case TradeOfferState.TradeOfferStateInvalidItems: case TradeOfferState.TradeOfferStateCanceledBySecondFactor: case TradeOfferState.TradeOfferStateUnknown: Log.Info("Update the Offer..."); Bot .UpdateTradeOffer(transaction, DataAccessActionType.UpdateTradeOffer); Log.Info($"Trade offer {offer.TradeOfferId} failed because of {offer.OfferState}"); switch (transaction.State) { case TradeOfferTransactionState.Completed: Log.Info($"Existing Trade, Paid completed {transaction.Id}"); SendChatMessage($"Due to Unknown failure, we have received your payment but the item is not traded, Please contact our support"); break; case TradeOfferTransactionState.PartialPaid: Log.Info($"Existing Trade, Paid partially ammount = {transaction.PaidAmmount} for {transaction.Id}"); SendChatMessage($"Due to Unknown failure, we have received your partial payment but the item is not traded, Please contact our support"); break; case TradeOfferTransactionState.New: case TradeOfferTransactionState.Paid: Log.Error("Trade reachs escow stage but transaction is at " + transaction.State); break; } break; } Log.Info("Update the Offer..."); Bot .UpdateTradeOffer(transaction, DataAccessActionType.UpdateTradeOffer); }
private void acceptTrade(TradeOffer offer) { string pass = Bot.BotDBPassword; List <TradeAsset> theirItems = offer.Items.GetTheirItems(); SteamID userID = offer.PartnerSteamId; string postData = "password="******"&owner=" + userID; string theirItemsJSON = JsonConvert.SerializeObject(theirItems); postData += "&items=" + theirItemsJSON; string url = Bot.BotWebsiteURL + "/php/check-items.php"; var request = (HttpWebRequest)WebRequest.Create(url); var data = Encoding.ASCII.GetBytes(postData); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = data.Length; using (var stream = request.GetRequestStream()) { stream.Write(data, 0, data.Length); } var response = (HttpWebResponse)request.GetResponse(); var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd(); //Uncomment this line to view the response from check-items.php Log.Success("Response received from check-items.php: \n" + responseString); JSONClass responseJsonObj = JsonConvert.DeserializeObject <JSONClass>(responseString); if (responseJsonObj.success == 1) { //Get data array from json var jsonData = responseJsonObj.data; if (jsonData.minDeposit == 1) { doWebWithCatch(10, () => { if (offer.Accept()) { Log.Success("Offer accepted from " + userID); //Put items into the pot string urlPutItemsIn = Bot.BotWebsiteURL + "/php/deposit.php"; var requestUrlPutItemsIn = (HttpWebRequest)WebRequest.Create(urlPutItemsIn); string postDataPutItemsIn = "password="******"&owner=" + userID; postDataPutItemsIn += "&items=" + jsonData.allItems; //Log.Success (jsonData.allItems); var dataPutItemsIn = Encoding.ASCII.GetBytes(postDataPutItemsIn); requestUrlPutItemsIn.Method = "POST"; requestUrlPutItemsIn.ContentType = "application/x-www-form-urlencoded"; requestUrlPutItemsIn.ContentLength = dataPutItemsIn.Length; using (var stream = requestUrlPutItemsIn.GetRequestStream()) { stream.Write(dataPutItemsIn, 0, dataPutItemsIn.Length); } var responsePutItemsIn = (HttpWebResponse)requestUrlPutItemsIn.GetResponse(); string responsePutItemsInString = new StreamReader(responsePutItemsIn.GetResponseStream()).ReadToEnd(); //Uncomment this line to view the response from deposit.php //Log.Success ("Response received from deposit.php: " + responsePutItemsInString); JSONClass responseJsonObjPutItemsIn = JsonConvert.DeserializeObject <JSONClass> (responsePutItemsInString); jsonData = responseJsonObjPutItemsIn.data; } }); //Check if it should start the timer if (jsonData.startTimer == 1) { //Check if the timer is already running. if (!timerRunning) { timer = new System.Timers.Timer(); timer.Elapsed += new ElapsedEventHandler(timerEvent); timer.Interval = 1000; timer.Start(); timerRunning = true; } } //Check if the pot is over if (jsonData.potOver == 1) { //End the timer timerTime = 0; timer.Stop(); sendWinnings(responseJsonObj); } else { //Only try this one time, because even if it gives an error, it still gets declined. doWebWithCatch(1, () => { if (offer.Decline()) { Log.Error("Server deposit request failed, declining trade. Error message:\n" + responseJsonObj.errMsg); } }); } } else { //Only try this one time, because even if it gives an error, it still gets declined. doWebWithCatch(1, () => { if (offer.Decline()) { Log.Error("Minimum deposit not reached, offer declined."); } }); } } else { doWebWithCatch(1, () => { if (offer.Decline()) { Log.Error("The depositor's inventory could not be accessed."); } }); } }
public override void OnNewTradeOffer(TradeOffer offer) { if (IsAdmin) { offer.Accept(); Log.Success("Accepted trade offer from admin {0}.", Bot.SteamFriends.GetFriendPersonaName(OtherSID)); SendChatMessage("Trade offer complete."); } else { offer.Decline(); Log.Warn("Declined trade offer from user {0}.", OtherSID.ToString()); SendChatMessage("I don't know you. I cannot accept your trade offer."); } }
private void OnNewTradeOffer(TradeOffer offer) { var myItems = offer.Items.GetMyItems(); var theirItems = offer.Items.GetTheirItems(); if (myItems.Count == 0) { offer.Accept(); Bot.SteamFriends.SendChatMessage(ownerID, EChatEntryType.ChatMsg, "I received a donation offer!"); Bot.AcceptAllMobileTradeConfirmations(); Log.Success("Received a donation-offer"); } else { Bot.TradeOfferEscrowDuration CurrentEscrow = Bot.GetEscrowDuration(offer.TradeOfferId); //Check if trader has delayed trades if (CurrentEscrow.DaysTheirEscrow > 2) { Log.Error("Trade offer has been declined due to escrow."); Bot.SteamFriends.SendChatMessage(ownerID, EChatEntryType.ChatMsg, "Incoming trade offer has been declined due to escrow."); offer.Decline(); } else { List <long> contextId = new List <long>(); contextId.Add(2); contextId.Add(6); mySteamInventory.load(440, contextId, Bot.SteamClient.SteamID); OtherSteamInventory.load(440, contextId, offer.PartnerSteamId); int MyRef = 0; int MyKey = 0; int TheirRef = 0; int TheirKey = 0; #region User for (int count = 0; count < theirItems.Count; count++) { if (theirItems[count].AppId == 440) { if (OtherSteamInventory.getDescription((ulong)theirItems[count].AssetId).name == "Scrap Metal") { TheirRef += 1; } else if (OtherSteamInventory.getDescription((ulong)theirItems[count].AssetId).name == "Reclaimed Metal") { TheirRef += 3; } else if (OtherSteamInventory.getDescription((ulong)theirItems[count].AssetId).name == "Refined Metal") { TheirRef += 9; } else if (OtherSteamInventory.getDescription((ulong)theirItems[count].AssetId).name == "Mann Co. Supply Crate Key") { TheirKey++; } } } #endregion #region Bot for (int count = 0; count < myItems.Count; count++) { if (mySteamInventory.getDescription((ulong)myItems[count].AssetId).name == "Scrap Metal") { MyRef += 1; } else if (mySteamInventory.getDescription((ulong)myItems[count].AssetId).name == "Reclaimed Metal") { MyRef += 3; } else if (mySteamInventory.getDescription((ulong)myItems[count].AssetId).name == "Refined Metal") { MyRef += 9; } else if (mySteamInventory.getDescription((ulong)myItems[count].AssetId).name == "Mann Co. Supply Crate Key") { MyRef += 9; } } #endregion #region Calculate Console.Write(" - TheirKey: " + TheirKey); Console.Write(" - Buyprice: " + buyPrice); Console.WriteLine(" - MyRef: " + MyRef); Console.Write(" - MyKey: " + MyKey); Console.Write(" - SellPrice: " + sellPrice); Console.WriteLine(" - TheirRef: " + TheirRef); if (((TheirKey * buyPrice) == MyRef) && ((MyKey * sellPrice) == TheirRef)) { Log.Success("[#" + offer.TradeOfferId + "] Accepted Offer."); offer.Accept(); Bot.AcceptAllMobileTradeConfirmations(); Bot.SteamFriends.SendChatMessage(ownerID, EChatEntryType.ChatMsg, "I've done a succesful offer with " + Bot.SteamFriends.GetFriendPersonaName(offer.PartnerSteamId) + "."); } else if (IsAdmin) { string tradeid; offer.Accept(out tradeid); Log.Success("[ADMINOFFER] Accepted trade offer successfully : Trade ID: " + tradeid); Bot.AcceptAllMobileTradeConfirmations(); } else { Log.Success("[#" + offer.TradeOfferId + "] Declined Offer."); offer.Decline(); Bot.AcceptAllMobileTradeConfirmations(); } #endregion } } }
public override void OnNewTradeOffer(TradeOffer offer) { var escrow = Bot.GetEscrowDuration(offer.TradeOfferId); if (escrow.DaysMyEscrow != 0 || escrow.DaysTheirEscrow != 0) { doWebWithCatch(1, () => { if (offer.Decline()) { Log.Error("User has not been using the Mobile Authenticator for 7 days or has turned off trade confirmations, offer declined."); } }); } else { //Get password from file on desktop string pass = Bot.BotDBPassword; //Get items in the trade, and ID of user sending trade var theirItems = offer.Items.GetTheirItems(); var myItems = offer.Items.GetMyItems(); var userID = offer.PartnerSteamId; bool shouldDecline = false; //Check if they are trying to get items from the bot if (myItems.Count > 0 || theirItems.Count == 0) { //shouldDecline = true; Log.Error("Offer declined because the offer wasn't a gift; the user wanted items instead of giving."); } //Check to make sure all items are for CS: GO. foreach (TradeAsset item in theirItems) { if (item.AppId != 730) { shouldDecline = true; Log.Error("Offer declined because one or more items was not for CS: GO."); } } //Check if there are more than 10 items in the trade if (theirItems.Count > 10) { shouldDecline = true; Log.Error("Offer declined because there were more than 10 items in the deposit."); } if (shouldDecline) { doWebWithCatch(1, () => { if (offer.Decline()) { Log.Error("Offer declined."); } }); return; } Log.Success("Offer approved, accepting."); //Send items to server and check if all items add up to more than $1. //If they do, accept the trade. If they don't, decline the trade. string postData = "password="******"&owner=" + userID; string theirItemsJSON = JsonConvert.SerializeObject(theirItems); postData += "&items=" + theirItemsJSON; string url = Bot.BotWebsiteURL + "/php/check-items.php"; var request = (HttpWebRequest)WebRequest.Create(url); var data = Encoding.ASCII.GetBytes(postData); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = data.Length; using (var stream = request.GetRequestStream()) { stream.Write(data, 0, data.Length); } var response = (HttpWebResponse)request.GetResponse(); var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd(); //Uncomment this line to view the response from check-items.php //Log.Success ("Response received from check-items.php: \n" + responseString); JSONClass responseJsonObj = JsonConvert.DeserializeObject <JSONClass>(responseString); if (responseJsonObj.success == 1) { //Get data array from json var jsonData = responseJsonObj.data; if (jsonData.minDeposit == 1) { doWebWithCatch(10, () => { if (offer.Accept()) { Log.Success("Offer accepted from " + userID); //Put items into the pot string urlPutItemsIn = Bot.BotWebsiteURL + "/php/deposit.php"; var requestUrlPutItemsIn = (HttpWebRequest)WebRequest.Create(urlPutItemsIn); string postDataPutItemsIn = "password="******"&owner=" + userID; postDataPutItemsIn += "&items=" + jsonData.allItems; //Log.Success (jsonData.allItems); var dataPutItemsIn = Encoding.ASCII.GetBytes(postDataPutItemsIn); requestUrlPutItemsIn.Method = "POST"; requestUrlPutItemsIn.ContentType = "application/x-www-form-urlencoded"; requestUrlPutItemsIn.ContentLength = dataPutItemsIn.Length; using (var stream = requestUrlPutItemsIn.GetRequestStream()) { stream.Write(dataPutItemsIn, 0, dataPutItemsIn.Length); } var responsePutItemsIn = (HttpWebResponse)requestUrlPutItemsIn.GetResponse(); string responsePutItemsInString = new StreamReader(responsePutItemsIn.GetResponseStream()).ReadToEnd(); //Uncomment this line to view the response from deposit.php //Log.Success ("Response received from deposit.php: " + responsePutItemsInString); JSONClass responseJsonObjPutItemsIn = JsonConvert.DeserializeObject <JSONClass>(responsePutItemsInString); jsonData = responseJsonObjPutItemsIn.data; } }); //Check if it should start the timer if (jsonData.startTimer == 1) { //Check if the timer is already running. if (!timerRunning) { timer = new System.Timers.Timer(); timer.Elapsed += new ElapsedEventHandler(timerEvent); timer.Interval = 1000; timer.Start(); timerRunning = true; } } //Check if the pot is over if (jsonData.potOver == 1) { //End the timer timerTime = 0; timer.Stop(); //Get items to give and keep, and the winner and their trade token var itemsToGive = jsonData.tradeItems; var itemsToKeep = jsonData.profitItems; string winnerSteamIDString = jsonData.winnerSteamId; SteamID winnerSteamID = new SteamID(winnerSteamIDString); string winnerTradeToken = jsonData.winnerTradeToken; Log.Success("Winner steam id: " + winnerSteamIDString + ", token: " + winnerTradeToken); //Get bot's inventory json string botInvUrl = "http://steamcommunity.com/profiles/" + Bot.SteamUser.SteamID.ConvertToUInt64() + "/inventory/json/730/2"; var botInvRequest = (HttpWebRequest)WebRequest.Create(botInvUrl); var botInvResponse = (HttpWebResponse)botInvRequest.GetResponse(); string botInvString = new StreamReader(botInvResponse.GetResponseStream()).ReadToEnd(); BotInventory botInventory = JsonConvert.DeserializeObject <BotInventory>(botInvString); if (botInventory.success != true) { Log.Error("An error occured while fetching the bot's inventory."); return; } var rgInventory = botInventory.rgInventory; //Create trade offer for the winner var winnerTradeOffer = Bot.NewTradeOffer(winnerSteamID); //Loop through all winner's items and add them to trade List <long> alreadyAddedToWinnerTrade = new List <long>(); foreach (CSGOItemFromWeb item in itemsToGive) { long classId = item.classId, instanceId = item.instanceId; //Loop through all inventory items and find the asset id for the item long assetId = 0; foreach (var inventoryItem in rgInventory) { var value = inventoryItem.Value; long tAssetId = value.id, tClassId = value.classid, tInstanceId = value.instanceid; if (tClassId == classId && tInstanceId == instanceId) { //Check if this assetId has already been added to the trade if (alreadyAddedToWinnerTrade.Contains(tAssetId)) { continue; //This is for when there are 2 of the same weapon, but they have different assetIds } assetId = tAssetId; break; } } //Log.Success ("Adding item to winner trade offer. Asset ID: " + assetId); winnerTradeOffer.Items.AddMyItem(730, 2, assetId, 1); alreadyAddedToWinnerTrade.Add(assetId); } //Send trade offer to winner if (itemsToGive.Count > 0) { string winnerTradeOfferId, winnerMessage = "Congratulations, you have won on " + Bot.BotWebsiteName + "! Here are your items."; doWebWithCatch(-1, () => { if (winnerTradeOffer.SendWithToken(out winnerTradeOfferId, winnerTradeToken, winnerMessage)) { Bot.AcceptAllMobileTradeConfirmations(); Log.Success("Offer sent to winner."); } }); } else { Log.Info("No items to give... strange"); } //Now, send all of the profit items to my own account //Put your own Steam ID here var profitTradeOffer = Bot.NewTradeOffer(new SteamID(Bot.ProfitAdmin)); //Loop through all profit items and add them to trade List <long> alreadyAddedToProfitTrade = new List <long>(); foreach (CSGOItemFromWeb item in itemsToKeep) { long classId = item.classId, instanceId = item.instanceId; //Loop through all inventory items and find the asset id for the item long assetId = 0; foreach (var inventoryItem in rgInventory) { var value = inventoryItem.Value; long tAssetId = value.id, tClassId = value.classid, tInstanceId = value.instanceid; if (tClassId == classId && tInstanceId == instanceId) { //Check if this assetId has already been added to the trade if (alreadyAddedToProfitTrade.Contains(tAssetId)) { continue; //This is for when there are 2 of the same weapon, but they have different assetIds } assetId = tAssetId; break; } } //Log.Success ("Adding item to winner trade offer. Asset ID: " + assetId); profitTradeOffer.Items.AddMyItem(730, 2, assetId, 1); alreadyAddedToProfitTrade.Add(assetId); } //Send trade offer to myself with profit items Log.Success(itemsToKeep.Count + ""); if (itemsToKeep.Count > 0) { string profitTradeOfferId, profitMessage = "Here are the profit items from the round."; doWebWithCatch(10, () => { if (profitTradeOffer.Send(out profitTradeOfferId, profitMessage)) { //Don't need the token because I am friends with the bot. Bot.AcceptAllMobileTradeConfirmations(); Log.Success("Profit trade offer sent."); } }); } } else { //Only try this one time, because even if it gives an error, it still gets declined. doWebWithCatch(1, () => { if (offer.Decline()) { Log.Error("Server deposit request failed, declining trade. Error message:\n" + responseJsonObj.errMsg); } }); } } else { //Only try this one time, because even if it gives an error, it still gets declined. doWebWithCatch(1, () => { if (offer.Decline()) { Log.Error("Minimum deposit not reached, offer declined."); } }); } } } }
public override void OnNewTradeOffer(TradeOffer offer) { //Get password from file on desktop string pass = System.IO.File.ReadAllText(@"C:\Users\Jordan Turley\Desktop\password.txt"); //Get items in the trade, and ID of user sending trade var theirItems = offer.Items.GetTheirItems (); var myItems = offer.Items.GetMyItems (); var userID = offer.PartnerSteamId; bool shouldDecline = false; //Check if they are trying to get items from the bot if (myItems.Count > 0 || theirItems.Count == 0) { shouldDecline = true; Log.Error ("Offer declined because the offer wasn't a gift; the user wanted items instead of giving."); } //Check to make sure all items are for CS: GO. foreach (TradeAsset item in theirItems) { if (item.AppId != 730) { shouldDecline = true; Log.Error ("Offer declined because one or more items was not for CS: GO."); } } //Check if there are more than 10 items in the trade if (theirItems.Count > 10) { shouldDecline = true; Log.Error ("Offer declined because there were more than 10 items in the deposit."); } if (shouldDecline) { if (offer.Decline ()) { Log.Error ("Offer declined."); } return; } Log.Success ("Offer approved, accepting."); //Send items to server and check if all items add up to more than $1. //If they do, accept the trade. If they don't, decline the trade. string postData = "password="******"&owner=" + userID; string theirItemsJSON = JsonConvert.SerializeObject (theirItems); postData += "&items=" + theirItemsJSON; string url = "http://csgowinbig.com/php/check-items.php"; var request = (HttpWebRequest)WebRequest.Create (url); var data = Encoding.ASCII.GetBytes(postData); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = data.Length; using (var stream = request.GetRequestStream()) { stream.Write(data, 0, data.Length); } var response = (HttpWebResponse)request.GetResponse(); var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd(); //Log.Success ("Response received from server: \n" + responseString); JSONClass responseJsonObj = JsonConvert.DeserializeObject<JSONClass> (responseString); if (responseJsonObj.success == 1) { //Get data array from json var jsonData = responseJsonObj.data; if (jsonData.minDeposit == 1) { if (offer.Accept ()) { Log.Success ("Offer accepted from " + userID); //Put items into the pot string urlPutItemsIn = "http://csgowinbig.com/php/deposit.php"; var requestUrlPutItemsIn = (HttpWebRequest)WebRequest.Create (urlPutItemsIn); string postDataPutItemsIn = "password="******"&owner=" + userID; postDataPutItemsIn += "&items=" + jsonData.allItems; //Log.Success (jsonData.allItems); var dataPutItemsIn = Encoding.ASCII.GetBytes (postDataPutItemsIn); requestUrlPutItemsIn.Method = "POST"; requestUrlPutItemsIn.ContentType = "application/x-www-form-urlencoded"; requestUrlPutItemsIn.ContentLength = dataPutItemsIn.Length; using (var stream = requestUrlPutItemsIn.GetRequestStream ()) { stream.Write (dataPutItemsIn, 0, dataPutItemsIn.Length); } var responsePutItemsIn = (HttpWebResponse)requestUrlPutItemsIn.GetResponse (); string responsePutItemsInString = new StreamReader (responsePutItemsIn.GetResponseStream ()).ReadToEnd (); JSONClass responseJsonObjPutItemsIn = JsonConvert.DeserializeObject<JSONClass> (responsePutItemsInString); jsonData = responseJsonObjPutItemsIn.data; } //Check if the pot is over if (jsonData.potOver == 1) { //Get items to give and keep, and the winner and their trade token var itemsToGive = jsonData.tradeItems; var itemsToKeep = jsonData.profitItems; string winnerSteamIDString = jsonData.winnerSteamID; SteamID winnerSteamID = new SteamID (winnerSteamIDString); string winnerTradeToken = jsonData.winnerTradeToken; Log.Success ("Winner steam id: " + winnerSteamIDString + ", token: " + winnerTradeToken); //Get bot's inventory json string botInvUrl = "http://steamcommunity.com/profiles/76561198238743988/inventory/json/730/2"; var botInvRequest = (HttpWebRequest)WebRequest.Create (botInvUrl); var botInvResponse = (HttpWebResponse)botInvRequest.GetResponse (); string botInvString = new StreamReader (botInvResponse.GetResponseStream()).ReadToEnd(); BotInventory botInventory = JsonConvert.DeserializeObject<BotInventory> (botInvString); if (botInventory.success != true) { Log.Error ("An error occured while fetching the bot's inventory."); return; } var rgInventory = botInventory.rgInventory; //Create trade offer for the winner var winnerTradeOffer = Bot.NewTradeOffer (winnerSteamID); //Loop through all winner's items and add them to trade List<long> alreadyAddedToWinnerTrade = new List<long> (); foreach (CSGOItemFromWeb item in itemsToGive) { long classId = item.classId, instanceId = item.instanceId; //Loop through all inventory items and find the asset id for the item long assetId = 0; foreach (var inventoryItem in rgInventory) { var value = inventoryItem.Value; long tAssetId = value.id, tClassId = value.classid, tInstanceId = value.instanceid; if (tClassId == classId && tInstanceId == instanceId) { //Check if this assetId has already been added to the trade if (alreadyAddedToWinnerTrade.Contains (tAssetId)) { continue; //This is for when there are 2 of the same weapon, but they have different assetIds } assetId = tAssetId; break; } } //Log.Success ("Adding item to winner trade offer. Asset ID: " + assetId); winnerTradeOffer.Items.AddMyItem (730, 2, assetId, 1); alreadyAddedToWinnerTrade.Add (assetId); } //Send trade offer to winner if (itemsToGive.Count > 0) { string winnerTradeOfferId, winnerMessage = "Congratulations, you have won on CSGO Win Big! Here are your items."; winnerTradeOffer.SendWithToken (out winnerTradeOfferId, winnerTradeToken, winnerMessage); Log.Success ("Offer sent to winner."); } else { Log.Info ("No items to give... strange"); } } } else { if (offer.Decline ()) { Log.Error ("Minimum deposit not reached, offer declined."); } } } else { Log.Error ("Server deposit request failed, declining trade. Error message:\n" + responseJsonObj.errMsg); offer.Decline (); } }
public override void OnNewTradeOffer( TradeOffer offer ) { var escrow = Bot.GetEscrowDuration( offer.TradeOfferId ); bool decline = false; // check if he / she use steam authentificator if( escrow.DaysMyEscrow != 0 || escrow.DaysTheirEscrow != 0 ) { Log.Error( "User has not been using the Mobile Authenticator for 7 days or has turned off trade confirmations, offer declined." ); decline = true; } // check if he / she try to steal the bot if( offer.Items.GetMyItems ().Count > 0 || offer.Items.GetTheirItems ().Count == 0 ) { Log.Error( "Offer declined because the offer wasn't a gift; the user wanted items instead of giving." ); decline = true; } // check if all items is for h1z1, except if the partner is an admin if (!IsAdmin) { foreach( var item in offer.Items.GetTheirItems()) { if( item.AppId != 295110 && item.AppId != 430850 && item.AppId != 730 ) { Log.Error( "Offer declined because one or more items was not for H1Z1 or CSGO." ); decline = true; } } } /* check if there are more than 10 items in the trade var max = 10; if( offer.Items.GetTheirItems().Count > max ) { Log.Error( String.Format( "Offer declined because there were more than {0} items in the deposit.", max )); decline = true; }*/ // decline the offer if( decline ) { Log.Info( "Try to decline offer" ); doWebWithCatch( 1, () => { if( offer.Decline()) { Log.Success( "Decline offer" ); } else { Log.Error( "Decline offer" ); } }); return; } // On définit la route pour les traitements PHP var url = Util.rewriteUrl (Bot.BotWebsiteURL, String.Format ("/bot/{0}/deposit", Bot.BotID)); //Suivant la classe, l'URL appelée est différente if (Bot.BotClass == "Store") { url = Util.rewriteUrl (Bot.BotWebsiteURL, String.Format ("/bot/{0}/deposit", Bot.BotID)); } else if (Bot.BotClass == "Bingo") { url = Util.rewriteUrl (Bot.BotWebsiteURL, String.Format ("/bot/{0}/deposit_bingo", Bot.BotID)); } Log.Info ("Offer accepted, try treatment Store"); var data = "data={" + String.Format ("\"owner\": {0}, \"items\": {1}", offer.PartnerSteamId, JsonConvert.SerializeObject (offer.Items.GetTheirItems ())) + "}"; var post = Encoding.UTF8.GetBytes (data); var request = WebRequest.Create (url); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = post.Length; using (var stream = request.GetRequestStream ()) { stream.Write (post, 0, post.Length); } doWebWithCatch (1, () => { Console.WriteLine ("Wesh gros, on deserialize"); try{ var response = JsonConvert.DeserializeObject<JSONBasicResponse> (new StreamReader (request.GetResponse().GetResponseStream ()).ReadToEnd()); Console.WriteLine( "On n'arrive jamais ici" ); if (response.success) { Console.WriteLine ("Deposit"); if (offer.Accept ()) { Console.WriteLine ("Offer accepted"); } else { Console.WriteLine ("Offer accepted"); } } else { Console.WriteLine ("Deposit"); if (offer.Decline ()) { Console.WriteLine ("Decline offer, cannot deposit"); } else { Console.WriteLine ("Decline offer, cannot deposit"); } } } catch(JsonReaderException e){ Console.WriteLine (e.ToString()); Console.WriteLine (e.Data); Console.WriteLine (e.GetType()); } Console.WriteLine ("Wesh gros, on a réussi à deserializer"); }); }