Exemple #1
0
        private async Task ParseTrade(SteamTradeOffer tradeOffer)
        {
            if (tradeOffer == null)
            {
                return;
            }

            ulong tradeID;

            if (!ulong.TryParse(tradeOffer.tradeofferid, out tradeID))
            {
                return;
            }

            ulong otherSteamID  = tradeOffer.OtherSteamID64;
            bool  success       = false;
            bool  tradeAccepted = false;

            if (tradeOffer.items_to_give.Count == 0 || otherSteamID == Bot.SteamMasterID)
            {
                tradeAccepted = true;
                success       = await Bot.ArchiWebHandler.AcceptTradeOffer(tradeID).ConfigureAwait(false);
            }
            else
            {
                success = Bot.ArchiWebHandler.DeclineTradeOffer(tradeID);
            }

            if (tradeAccepted && success)
            {
                // Do whatever we want with success
            }
        }
Exemple #2
0
		private async Task ParseTrade(SteamTradeOffer tradeOffer) {
			if (tradeOffer == null) {
				return;
			}

			ulong tradeID;
			if (!ulong.TryParse(tradeOffer.tradeofferid, out tradeID)) {
				return;
			}

			ulong steamID = tradeOffer.OtherSteamID64;
			bool success = false;
			bool tradeAccepted = false;

			if (tradeOffer.items_to_give.Count == 0 || steamID == Bot.SteamMasterID) {
				tradeAccepted = true;
				success = await Bot.ArchiWebHandler.AcceptTradeOffer(tradeID).ConfigureAwait(false);
			} else {
				success = Bot.ArchiWebHandler.DeclineTradeOffer(tradeID);
			}

			if (tradeAccepted && success) {
				// Do whatever we want with success
			}
		}
Exemple #3
0
		private async Task ParseTrade(SteamTradeOffer tradeOffer) {
			if (tradeOffer == null) {
				return;
			}

			ulong tradeID;
			if (!ulong.TryParse(tradeOffer.tradeofferid, out tradeID)) {
				return;
			}

			if (tradeOffer.items_to_give.Count == 0 || tradeOffer.OtherSteamID64 == Bot.SteamMasterID) {
				Logging.LogGenericInfo("Accepting trade: " + tradeID, Bot.BotName);
				await Bot.ArchiWebHandler.AcceptTradeOffer(tradeID).ConfigureAwait(false);
			} else {
				Logging.LogGenericInfo("Ignoring trade: " + tradeID, Bot.BotName);
			}
		}
Exemple #4
0
        private async Task ParseTrade(SteamTradeOffer tradeOffer)
        {
            if (tradeOffer == null)
            {
                return;
            }

            ulong tradeID;

            if (!ulong.TryParse(tradeOffer.tradeofferid, out tradeID))
            {
                return;
            }

            if (tradeOffer.items_to_give.Count == 0 || tradeOffer.OtherSteamID64 == Bot.SteamMasterID)
            {
                Logging.LogGenericInfo("Accepting trade: " + tradeID, Bot.BotName);
                await Bot.ArchiWebHandler.AcceptTradeOffer(tradeID).ConfigureAwait(false);
            }
            else
            {
                Logging.LogGenericInfo("Ignoring trade: " + tradeID, Bot.BotName);
            }
        }
		internal List<SteamTradeOffer> GetTradeOffers() {
			if (ApiKey == null) {
				return null;
			}

			KeyValue response;
			using (dynamic iEconService = WebAPI.GetInterface("IEconService")) {
				// Timeout
				iEconService.Timeout = Timeout;

				try {
					response = iEconService.GetTradeOffers(
						key: ApiKey,
						get_received_offers: 1,
						active_only: 1,
						secure: true
					);
				} catch (Exception e) {
					Logging.LogGenericException(Bot.BotName, e);
					return null;
				}
			}

			if (response == null) {
				return null;
			}

			List<SteamTradeOffer> result = new List<SteamTradeOffer>();
			foreach (KeyValue trade in response["trade_offers_received"].Children) {
				SteamTradeOffer tradeOffer = new SteamTradeOffer {
					tradeofferid = trade["tradeofferid"].AsString(),
					accountid_other = trade["accountid_other"].AsInteger(),
					message = trade["message"].AsString(),
					expiration_time = trade["expiration_time"].AsInteger(),
					trade_offer_state = (SteamTradeOffer.ETradeOfferState) trade["trade_offer_state"].AsInteger(),
					items_to_give = new List<SteamItem>(),
					items_to_receive = new List<SteamItem>(),
					is_our_offer = trade["is_our_offer"].AsBoolean(),
					time_created = trade["time_created"].AsInteger(),
					time_updated = trade["time_updated"].AsInteger(),
					from_real_time_trade = trade["from_real_time_trade"].AsBoolean()
				};
				foreach (KeyValue item in trade["items_to_give"].Children) {
					tradeOffer.items_to_give.Add(new SteamItem {
						appid = item["appid"].AsString(),
						contextid = item["contextid"].AsString(),
						assetid = item["assetid"].AsString(),
						currencyid = item["currencyid"].AsString(),
						classid = item["classid"].AsString(),
						instanceid = item["instanceid"].AsString(),
						amount = item["amount"].AsString(),
						missing = item["missing"].AsBoolean()
					});
				}
				foreach (KeyValue item in trade["items_to_receive"].Children) {
					tradeOffer.items_to_receive.Add(new SteamItem {
						appid = item["appid"].AsString(),
						contextid = item["contextid"].AsString(),
						assetid = item["assetid"].AsString(),
						currencyid = item["currencyid"].AsString(),
						classid = item["classid"].AsString(),
						instanceid = item["instanceid"].AsString(),
						amount = item["amount"].AsString(),
						missing = item["missing"].AsBoolean()
					});
				}
				result.Add(tradeOffer);
			}

			return result;
		}
Exemple #6
0
        internal List <SteamTradeOffer> GetTradeOffers()
        {
            if (ApiKey == null)
            {
                return(null);
            }

            KeyValue response = null;

            using (dynamic iEconService = WebAPI.GetInterface("IEconService", ApiKey)) {
                iEconService.Timeout = Timeout;

                for (byte i = 0; i < WebBrowser.MaxRetries && response == null; i++)
                {
                    try {
                        response = iEconService.GetTradeOffers(
                            get_received_offers: 1,
                            active_only: 1,
                            secure: true
                            );
                    } catch (Exception e) {
                        Logging.LogGenericException(e, Bot.BotName);
                    }
                }
            }

            if (response == null)
            {
                Logging.LogGenericWTF("Request failed even after " + WebBrowser.MaxRetries + " tries", Bot.BotName);
                return(null);
            }

            List <SteamTradeOffer> result = new List <SteamTradeOffer>();

            foreach (KeyValue trade in response["trade_offers_received"].Children)
            {
                SteamTradeOffer tradeOffer = new SteamTradeOffer {
                    tradeofferid      = trade["tradeofferid"].AsString(),
                    accountid_other   = trade["accountid_other"].AsInteger(),
                    trade_offer_state = trade["trade_offer_state"].AsEnum <SteamTradeOffer.ETradeOfferState>()
                };
                foreach (KeyValue item in trade["items_to_give"].Children)
                {
                    tradeOffer.items_to_give.Add(new SteamItem {
                        appid      = item["appid"].AsString(),
                        contextid  = item["contextid"].AsString(),
                        assetid    = item["assetid"].AsString(),
                        classid    = item["classid"].AsString(),
                        instanceid = item["instanceid"].AsString(),
                        amount     = item["amount"].AsString(),
                    });
                }
                foreach (KeyValue item in trade["items_to_receive"].Children)
                {
                    tradeOffer.items_to_receive.Add(new SteamItem {
                        appid      = item["appid"].AsString(),
                        contextid  = item["contextid"].AsString(),
                        assetid    = item["assetid"].AsString(),
                        classid    = item["classid"].AsString(),
                        instanceid = item["instanceid"].AsString(),
                        amount     = item["amount"].AsString(),
                    });
                }
                result.Add(tradeOffer);
            }

            return(result);
        }
		internal List<SteamTradeOffer> GetTradeOffers() {
			if (ApiKey == null) {
				return null;
			}

			KeyValue response = null;
			using (dynamic iEconService = WebAPI.GetInterface("IEconService", ApiKey)) {
				iEconService.Timeout = Timeout;

				for (byte i = 0; i < WebBrowser.MaxRetries && response == null; i++) {
					try {
						response = iEconService.GetTradeOffers(
							get_received_offers: 1,
							active_only: 1,
							secure: true
						);
					} catch (Exception e) {
						Logging.LogGenericException(Bot.BotName, e);
					}
				}
			}

			if (response == null) {
				Logging.LogGenericWTF(Bot.BotName, "Request failed even after " + WebBrowser.MaxRetries + " tries");
				return null;
			}

			List<SteamTradeOffer> result = new List<SteamTradeOffer>();
			foreach (KeyValue trade in response["trade_offers_received"].Children) {
				SteamTradeOffer tradeOffer = new SteamTradeOffer {
					tradeofferid = trade["tradeofferid"].AsString(),
					accountid_other = trade["accountid_other"].AsInteger(),
					message = trade["message"].AsString(),
					expiration_time = trade["expiration_time"].AsInteger(),
					trade_offer_state = trade["trade_offer_state"].AsEnum<SteamTradeOffer.ETradeOfferState>(),
					items_to_give = new List<SteamItem>(),
					items_to_receive = new List<SteamItem>(),
					is_our_offer = trade["is_our_offer"].AsBoolean(),
					time_created = trade["time_created"].AsInteger(),
					time_updated = trade["time_updated"].AsInteger(),
					from_real_time_trade = trade["from_real_time_trade"].AsBoolean(),
					escrow_end_date = trade["escrow_end_date"].AsInteger(),
					confirmation_method = trade["confirmation_method"].AsEnum<SteamTradeOffer.ETradeOfferConfirmationMethod>()
				};
				foreach (KeyValue item in trade["items_to_give"].Children) {
					tradeOffer.items_to_give.Add(new SteamItem {
						appid = item["appid"].AsString(),
						contextid = item["contextid"].AsString(),
						assetid = item["assetid"].AsString(),
						currencyid = item["currencyid"].AsString(),
						classid = item["classid"].AsString(),
						instanceid = item["instanceid"].AsString(),
						amount = item["amount"].AsString(),
						missing = item["missing"].AsBoolean()
					});
				}
				foreach (KeyValue item in trade["items_to_receive"].Children) {
					tradeOffer.items_to_receive.Add(new SteamItem {
						appid = item["appid"].AsString(),
						contextid = item["contextid"].AsString(),
						assetid = item["assetid"].AsString(),
						currencyid = item["currencyid"].AsString(),
						classid = item["classid"].AsString(),
						instanceid = item["instanceid"].AsString(),
						amount = item["amount"].AsString(),
						missing = item["missing"].AsBoolean()
					});
				}
				result.Add(tradeOffer);
			}

			return result;
		}
        internal List <SteamTradeOffer> GetTradeOffers()
        {
            if (ApiKey == null)
            {
                return(null);
            }

            KeyValue response;

            using (dynamic iEconService = WebAPI.GetInterface("IEconService")) {
                // Timeout
                iEconService.Timeout = Timeout;

                try {
                    response = iEconService.GetTradeOffers(
                        key: ApiKey,
                        get_received_offers: 1,
                        active_only: 1,
                        secure: true
                        );
                } catch (Exception e) {
                    Logging.LogGenericException(Bot.BotName, e);
                    return(null);
                }
            }

            if (response == null)
            {
                return(null);
            }

            List <SteamTradeOffer> result = new List <SteamTradeOffer>();

            foreach (KeyValue trade in response["trade_offers_received"].Children)
            {
                SteamTradeOffer tradeOffer = new SteamTradeOffer {
                    tradeofferid         = trade["tradeofferid"].AsString(),
                    accountid_other      = trade["accountid_other"].AsInteger(),
                    message              = trade["message"].AsString(),
                    expiration_time      = trade["expiration_time"].AsInteger(),
                    trade_offer_state    = (SteamTradeOffer.ETradeOfferState)trade["trade_offer_state"].AsInteger(),
                    items_to_give        = new List <SteamItem>(),
                    items_to_receive     = new List <SteamItem>(),
                    is_our_offer         = trade["is_our_offer"].AsBoolean(),
                    time_created         = trade["time_created"].AsInteger(),
                    time_updated         = trade["time_updated"].AsInteger(),
                    from_real_time_trade = trade["from_real_time_trade"].AsBoolean()
                };
                foreach (KeyValue item in trade["items_to_give"].Children)
                {
                    tradeOffer.items_to_give.Add(new SteamItem {
                        appid      = item["appid"].AsString(),
                        contextid  = item["contextid"].AsString(),
                        assetid    = item["assetid"].AsString(),
                        currencyid = item["currencyid"].AsString(),
                        classid    = item["classid"].AsString(),
                        instanceid = item["instanceid"].AsString(),
                        amount     = item["amount"].AsString(),
                        missing    = item["missing"].AsBoolean()
                    });
                }
                foreach (KeyValue item in trade["items_to_receive"].Children)
                {
                    tradeOffer.items_to_receive.Add(new SteamItem {
                        appid      = item["appid"].AsString(),
                        contextid  = item["contextid"].AsString(),
                        assetid    = item["assetid"].AsString(),
                        currencyid = item["currencyid"].AsString(),
                        classid    = item["classid"].AsString(),
                        instanceid = item["instanceid"].AsString(),
                        amount     = item["amount"].AsString(),
                        missing    = item["missing"].AsBoolean()
                    });
                }
                result.Add(tradeOffer);
            }

            return(result);
        }