public override String run(CommandInfo cmdInfo, Bot bot) { String output = "Here are the items you have duplicates of:"; dynamic json = Util.CreateSteamRequest(String.Format("http://api.steampowered.com/ITFItems_440/GetPlayerItems/v0001/?key=" + bot.apiKey + "&SteamID={0}&format=json",cmdInfo.getSteamid().ConvertToUInt64()),"GET"); int limit = cmdInfo.getArg(0, 2); Dictionary<int, MutableInt> freq = new Dictionary<int, MutableInt>(); foreach (dynamic i in json.result.items.item) { int defindex = i.defindex; if (freq.ContainsKey(defindex)) { freq[defindex].increment(); } else { freq.Add(defindex, new MutableInt()); } } List<KeyValuePair<int, MutableInt>> myList = freq.ToList(); myList.Sort((firstPair,nextPair) => { return firstPair.Value.CompareTo(nextPair.Value); } ); foreach (KeyValuePair<int, MutableInt> entry in myList) { if (entry.Value.get() < limit) { break; } ItemInfo itemInfo = Util.getItemInfo(entry.Key); output += "\n" + itemInfo.getName() + " x" + entry.Value.get(); } return output; }
public override String run(CommandInfo cmdInfo, Bot bot) { List<int> weapons = new List<int>(); String include = cmdInfo.getArg(0, "e"); foreach (string key in lists.Keys) { if (include.Contains(key)) { foreach (int i in lists[key]) { weapons.Add(i); } } } dynamic json = Util.CreateSteamRequest(String.Format("http://api.steampowered.com/ITFItems_440/GetPlayerItems/v0001/?key=" + bot.apiKey + "&SteamID={0}&format=json",cmdInfo.getSteamid().ConvertToUInt64()),"GET"); foreach (dynamic item in json.result.items.item) { weapons.Remove((int) item.defindex); } string output = "Woah, you sir are a god among gigs\nYou have all essential items :D"; if (weapons.Count > 0) { output = "You are missing these items:"; foreach (int it in weapons) { output += "\n" + Util.getItemInfo(it).getName(); } } return output; }