Пример #1
0
 public static int MaxAutoBuyPrice(string class_instance, string lang, string apikey, SteamTrade.SteamWeb steamWeb)
 {
     //https://csgo.tm/api/ItemInfo/520025252_0/en/?key=dzrux9i3SpWyQS5eXZcoBSrN5P5BSvy  //in json properties get autoBuyOffers
     string requestLink = string.Format("https://csgo.tm/api/ItemInfo/{0}/{1}/?key={2}", class_instance, lang, apikey);
     dynamic jsonItemInfo = steamWeb.Fetch(requestLink, "GET", null, false, null);
     var price = jsonItemInfo.buy_offers[0].o_price;
     return 0;
 }
Пример #2
0
 public static string GetItemInfo(string class_instance, string lang, string apikey, SteamTrade.SteamWeb steamWeb)
 {
     string requestLink = string.Format("https://csgo.tm/api/ItemInfo/{0}/{1}/?key={2}", class_instance, lang, apikey);
     string response = steamWeb.Fetch(requestLink, "GET", null, false, null);
     if (response.Contains("error"))
     {
         throw new CsgotmException(response);
     }
     return response;
 }
Пример #3
0
 public Bot()
 {
     GameMiner      = new GameMiner();
     SteamGifts     = new SteamGifts();
     SteamCompanion = new SteamCompanion();
     SteamPortal    = new SteamPortal();
     SteamTrade     = new SteamTrade();
     PlayBlink      = new PlayBlink();
     Steam          = new Steam();
     GameAways      = new GameAways();
     InventoryGifts = new InventoryGifts();
     Blacklist      = new Blacklist();
 }
Пример #4
0
        public static Boolean SetAutoBuy(Item item, string apiKey, SteamTrade.SteamWeb steamWeb)
        {
            string lang = "en"; //needed for some requests
            string class_instance = item.ClassInstance;
            int price = 99;
            string hash = "147d375acdcae0645152b224d34d66ee";
            //TODO check the current maxAutoBuyPrice on csgo.tm
            MaxAutoBuyPrice(class_instance, lang, apiKey, steamWeb);

            //https://csgo.tm/api/InsertOrder/[class]/[instance]/[price]/[hash]/?key=[your_secret_key] //setAutoBuyPrice
            //string requestLink = string.Format("https://csgo.tm/api/InsertOrder/{0}/{1}/{2}/{3}/?key={4}",
            //    item.GetItemClass(), item.GetItemInstance(),
            //    price, hash, apikey);
            return true;
        }
Пример #5
0
 public override void OnTradeRemoveItem(SteamTrade.Schema.Item schemaItem, SteamTrade.Inventory.Item inventoryItem)
 {
     Trade.SendMessage(":(");
 }
Пример #6
0
        string GetItemName(SteamTrade.Schema.Item schemaItem, SteamTrade.Inventory.Item inventoryItem, bool id = false)
        {
            var currentItem = SteamTrade.Trade.CurrentSchema.GetItem(schemaItem.Defindex);
            string name = "";
            var type = Convert.ToInt32(inventoryItem.Quality.ToString());
            if (QualityToName(type) != "Unique")
                name += QualityToName(type) + " ";
            name += currentItem.ItemName;

            if (currentItem.CraftMaterialType == "supply_crate")
            {
                for (int count = 0; count < inventoryItem.Attributes.Length; count++)
                {
                    name += " #" + (inventoryItem.Attributes[count].FloatValue);
                }
            }
            name += " (Level " + inventoryItem.Level + ")";
            try
            {
                int size = inventoryItem.Attributes.Length;
                for (int count = 0; count < size; count++)
                {
                    if (inventoryItem.Attributes[count].Defindex == 186)
                    {
                        name += " (Gifted)";
                    }
                }
            }
            catch
            {
                // Item has no attributes... or something.
            }
            if (inventoryItem.IsNotCraftable)
                name += " (Uncraftable)";
            if (currentItem.Name == "Wrapped Gift")
            {
                // Untested!
                try
                {
                    int size = inventoryItem.Attributes.Length;
                    for (int count = 0; count < size; count++)
                    {
                        var containedItem = SteamTrade.Trade.CurrentSchema.GetItem(inventoryItem.ContainedItem.Defindex);
                        name += " (Contains: " + containedItem.ItemName + ")";
                    }
                }
                catch
                {
                    // Item has no attributes... or something.
                }
            }
            if (id)
                name += " :" + inventoryItem.Id;
            return name;
        }
Пример #7
0
        public static string GetPrice(int defindex, int quality, SteamTrade.Inventory.Item inventoryItem, bool gifted = false, int attribute = 0)
        {
            try
            {
                double value = BackpackTF.CurrentSchema.Response.Prices[defindex][quality][attribute].Value;
                double keyValue = BackpackTF.CurrentSchema.Response.Prices[5021][6][0].Value;
                double billsValue = BackpackTF.CurrentSchema.Response.Prices[126][6][0].Value;
                double budValue = BackpackTF.CurrentSchema.Response.Prices[143][6][0].Value;

                var item = SteamTrade.Trade.CurrentSchema.GetItem(defindex);
                string result = "";

                if (inventoryItem.IsNotCraftable)
                {
                    value = value / 2.0;
                }
                if (inventoryItem.IsNotTradeable)
                {
                    value = value / 2.0;
                }
                if (gifted)
                {
                    value = value * 0.75;
                }
                if (quality == 3)
                {
                    if (item.CraftMaterialType == "weapon")
                    {
                        int level = inventoryItem.Level;
                        switch (level)
                        {
                            case 0:
                                value = billsValue + 5.11;
                                break;
                            case 1:
                                value = billsValue;
                                break;
                            case 42:
                                value = value * 10.0;
                                break;
                            case 69:
                                value = billsValue;
                                break;
                            case 99:
                                value = billsValue;
                                break;
                            case 100:
                                value = billsValue;
                                break;
                            default:
                                break;
                        }
                    }
                    else if (item.CraftMaterialType == "hat")
                    {
                        int level = inventoryItem.Level;
                        switch (level)
                        {
                            case 0:
                                value = value * 10.0;
                                break;
                            case 1:
                                value = value * 5.0;
                                break;
                            case 42:
                                value = value * 3.0;
                                break;
                            case 69:
                                value = value * 4.0;
                                break;
                            case 99:
                                value = value * 4.0;
                                break;
                            case 100:
                                value = value * 6.0;
                                break;
                            default:
                                break;
                        }
                    }
                }

                if (value >= budValue * 1.33)
                {
                    value = value / budValue;
                    result = value.ToString("0.00") + " buds";
                }
                else if (value >= keyValue && !item.ItemName.EndsWith("Key"))
                {
                    value = value / keyValue;
                    result = value.ToString("0.00") + " keys";
                }
                else
                {
                    result = value.ToString("0.00") + " ref";
                }

                return result;
            }
            catch
            {
                return "Unknown";
            }
        }
Пример #8
0
        public static Boolean SetAutoBuy(ItemInSQL itemInSql, string apiKey, SteamTrade.SteamWeb steamWeb)
        {
            if (itemInSql.CanBuy == 1)
            {
                String deserializedResponse;
                string lang = "en"; //needed for some requests
                //TODO I'm inserting a new AutoBuyPrice, but can't change.
                //calculating new price for ItemInSQL
                int currentMaxAutoBuyPrice = GetMaxAutoBuyPriceForItem(itemInSql, lang, apiKey, steamWeb); //100
                int newPrice;
                if (currentMaxAutoBuyPrice < itemInSql.MinPriceBuy)
                {
                    newPrice = itemInSql.MinPriceBuy;
                }
                else if (currentMaxAutoBuyPrice < itemInSql.MaxPriceBuy)
                {
                    newPrice = currentMaxAutoBuyPrice + 1;
                }
                else
                {
                    newPrice = itemInSql.MaxPriceBuy;
                }
                //trying to update price for ItemInSQL
                string updateLink = string.Format("https://csgo.tm/api/UpdateOrder/{0}/{1}/{2}/?key={3}",
                    itemInSql.GetItemClass(), itemInSql.GetItemInstance(), newPrice, apiKey);

                string updateJsonResponse = steamWeb.Fetch(updateLink, "GET", null, false, null);
                deserializedResponse = JsonConvert.DeserializeObject(updateJsonResponse).ToString();
                //if couldn't find the order in base - create a new one.
                if (deserializedResponse.ToString().Contains("Данная заявка на покупку не найдена"))
                {
                    string insertLink = string.Format("https://csgo.tm/api/InsertOrder/{0}/{1}/{2}/{3}/?key={4}",
                        itemInSql.GetItemClass(), itemInSql.GetItemInstance(), newPrice, itemInSql.Hash, apiKey);
                    string insertJsonResponse = steamWeb.Fetch(insertLink, "GET", null, false, null);
                    deserializedResponse = JsonConvert.DeserializeObject(insertJsonResponse).ToString();
                    if (deserializedResponse.Contains("true"))
                    {
                        Console.WriteLine("A new autobuy order for ItemInSQL " + itemInSql.ItemName +
                                          " was created successfully!" +
                                          " Price: " + (double) newPrice/100 + " руб.");
                        return true;
                    }
                    else if (deserializedResponse.Contains("Неверно задана цена покупки"))
                    {
                        Console.WriteLine("Wrong price for " +itemInSql.ItemName + "! Check the prices for buying in database!");
                        return false;
                    }
                    Console.WriteLine("For item: " + itemInSql.ItemName);
                    Console.WriteLine(deserializedResponse);
                }
                else if (deserializedResponse.ToString().Contains("недостаточно средств на счету"))
                {
                    Console.WriteLine("Autobuy false. For " + itemInSql.ItemName +
                                      " - not enough funds in wallet! Пополните кошелек!");
                    return false;
                }
                else if (deserializedResponse.ToString().Contains("true"))
                {
                    Console.WriteLine("Autobuy price for " + itemInSql.ItemName + " was updated successfully! New price: " +
                                      (double) newPrice/100 + " руб.");
                    return true;
                }
                //TODO
                Console.WriteLine("We should never reach here." +
                                  " A new error ");
            }
            return false;
        }
Пример #9
0
 public static int GetMaxAutoBuyPriceForItem(ItemInSQL itemInSql, string lang, string apikey, SteamTrade.SteamWeb steamWeb)
 {
     //https://csgo.tm/api/ItemInfo/520025252_0/en/?key=  //in json properties get autoBuyOffers
     string requestLink = string.Format("https://csgo.tm/api/ItemInfo/{0}/{1}/?key={2}", itemInSql.ClassInstance, lang, apikey);
     string jsonItemInfo = steamWeb.Fetch(requestLink, "GET", null, false, null);
     dynamic deserializedResponse = JsonConvert.DeserializeObject(jsonItemInfo);
     int price = deserializedResponse.buy_offers[0].o_price;
     return price;
 }
Пример #10
0
        public Boolean LoginToCsgotm(SteamTrade.SteamWeb steamWeb)
        {
            try
            {
                String response = steamWeb.Fetch("https://csgo.tm/login/", "GET", null, false, "https://csgo.tm/");

                /*csgo.tm redirects us to Openid-Steam-login page, where we must imitate pression of "sign in" button. For it, on
            Openid-Steam-login page Steam gives us special data - nonce, which is a one-time-used key for login. And openidparams -
            seems as public RSA-key, but not sure. We need to retreive it from response and post it to the link below.
            */

                NameValueCollection postData = new NameValueCollection();
                String nonce = GetAttributeFromResponse(response, "nonce");
                String openidparams = GetAttributeFromResponse(response, "openidparams");
                postData.Add("action", "steam_openid_login");
                postData.Add("openid.mode", "checkid_setup");
                postData.Add("openidparams", openidparams);
                postData.Add("nonce", nonce);
                steamWeb.Fetch("https://steamcommunity.com/openid/login", "POST", postData, false, null);
                Log.Success("Logged in successfully");
                return true;
                //here we're loggining
            }
            catch (Exception e)
            {
                Log.Error(e.Message);
                return false;
            }
        }