private void SendTradeMessageImpl(string message) { if (Trade != null && !Trade.HasTradeEnded) { Trade.SendMessage(message); Log.Info("Sent trade message to user {0}: {1}", OtherSID.ToString(), message); } }
public override void OnTradeAwaitingEmailConfirmation(long tradeOfferID) { Log.Success("Trade ended awaiting email confirmation"); SendChatMessage("Please complete the email confirmation to finish the trade"); SendChatToAdmins("Completed real-time trade with user {0}: {1}. Awaiting email confirmation.", OtherSID.ToString(), ActiveOrder.ToString(Trade.CurrentSchema, true)); Console.Beep(); }
public override bool OnFriendAdd() { Bot.log.Success(Bot.SteamFriends.GetFriendPersonaName(OtherSID) + " (" + OtherSID.ToString() + ") added me!"); // Using a timer here because the message will fail to send if you do it too quickly inviteMsgTimer.Interval = InviteTimerInterval; inviteMsgTimer.Elapsed += (sender, e) => OnInviteTimerElapsed(sender, e, EChatEntryType.ChatMsg); inviteMsgTimer.Enabled = true; return(true); }
public override bool OnFriendAdd() { Bot.log.Success(Bot.SteamFriends.GetFriendPersonaName(OtherSID) + " (" + OtherSID.ToString() + ") added me!"); inviteMsgTimer = new System.Timers.Timer(); inviteMsgTimer.Interval = InviteTimerInterval; inviteMsgTimer.Elapsed += (sender, e) => OnInviteTimerElapsed(sender, e, EChatEntryType.ChatMsg); inviteMsgTimer.Enabled = true; return(true); }
public override bool OnFriendAdd() { Log.Info("{0} has added me to their friends list.", OtherSID.ToString()); Bot.ResetFriendsList(); SendChatMessage("Hi. I am Sealed Steam Bot. Type 'trade' to start trading, or 'help'" + " to get a list of commands. Please note I am currently in beta, so my functions" + " may be glitchy at times."); return(true); }
}//OnClanAdd() public override bool OnFriendAdd() { Bot.log.Success(Bot.SteamFriends.GetFriendPersonaName(OtherSID) + " (" + OtherSID.ConvertToUInt64() + ") added me!");//show someone added the bot FriendAddedHandler.Start(); if (!IsAdmin) { FriendRemoveHandler.Start(); } return(true); }
/// <summary> /// Grabs the inventories of both users over both Trading and /// SteamAPI. /// </summary> protected void FetchInventories() { try { // [cmw] OtherItems and MyItems don't appear to be used... the should be removed. // fetch the other player's inventory othersItems = Inventory.GetInventory(OtherSID); if (othersItems == null || othersItems.success != "true") { throw new Exception("Could not fetch other player's inventory via Trading!"); } // fetch our inventory myItems = Inventory.GetInventory(MySteamId); if (myItems == null || myItems.success != "true") { throw new Exception("Could not fetch own inventory via Trading!"); } // fetch other player's inventory from the Steam API. OtherInventory = Inventory.FetchInventory(OtherSID.ConvertToUInt64(), apiKey); if (OtherInventory == null) { throw new Exception("Could not fetch other player's inventory via Steam API!"); } // fetch our inventory from the Steam API. myInventory = Inventory.FetchInventory(MySteamId.ConvertToUInt64(), apiKey); if (myInventory == null) { throw new Exception("Could not fetch own inventory via Steam API!"); } // check that the schema was already successfully fetched if (CurrentSchema == null) { throw new Exception("It seems the item schema was not fetched correctly!"); } if (OnAfterInit != null) { OnAfterInit(); } } catch (Exception e) { if (OnError != null) { OnError("I'm having a problem getting one of our backpacks. The Steam Community might be down. Ensure your backpack isn't private."); } else { throw new TradeException("I'm having a problem getting one of our backpacks. The Steam Community might be down. Ensure your backpack isn't private.", e); } } }
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."); } }
void Init() { sessionIdEsc = Uri.UnescapeDataString(sessionId); Version = 1; cookies = new CookieContainer(); cookies.Add(new Cookie("sessionid", sessionId, String.Empty, SteamCommunityDomain)); cookies.Add(new Cookie("steamLogin", steamLogin, String.Empty, SteamCommunityDomain)); baseTradeURL = String.Format(SteamTradeUrl, 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; } } } } }
private void RegistreTradeOfferInDatabase(long tradeOfferID) { Bot.listIDTradeOffer.Add(tradeOfferID); string[] rowsTO = new string[3]; rowsTO[0] = "SteamID"; rowsTO[1] = "TradeOfferID"; rowsTO[2] = "tradeValue"; string[] valuesTO = new string[3]; valuesTO[0] = OtherSID.ToString(); valuesTO[1] = tradeOfferID.ToString(); valuesTO[2] = cent.ToString(); Bot.DB.INSERT("tradeoffers", rowsTO, valuesTO); foreach (TradeUserAssets asset in Trade.OtherOfferedItems) { SteamTrade.GenericInventory.ItemDescription description = Bot.otherSteamInventory.getDescription(asset.assetid); string[] rowsI = new string[3]; rowsI[0] = "itemName"; rowsI[1] = "tradeoffersid"; rowsI[2] = "togive"; string[] valuesI = new string[3]; valuesI[0] = description.name; valuesI[1] = tradeOfferID.ToString(); valuesI[2] = "0"; Bot.DB.INSERT("items", rowsI, valuesI); } foreach (TradeUserAssets asset in Trade.MyOfferedItems) { SteamTrade.GenericInventory.ItemDescription description = Bot.mySteamInventory.getDescription(asset.assetid); string[] rowsI = new string[3]; rowsI[0] = "itemName"; rowsI[1] = "tradeoffersid"; rowsI[2] = "togive"; string[] valuesI = new string[3]; valuesI[0] = description.name; valuesI[1] = tradeOfferID.ToString(); valuesI[2] = "1"; Bot.DB.INSERT("items", rowsI, valuesI); } }
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."); } }
public override void OnTradeMessage(string message) { if (message == "ALL" && Bot.MySteamID.Contains(OtherSID.ToString())) { List <long> contextId = new List <long>(); contextId.Add(2); Bot.mySteamInventory.load(Bot.BotGameUsage, contextId, Bot.SteamClient.SteamID); Trade.SendMessage("Welcome " + Bot.MySteamID + " ! This is what I have."); foreach (GenericInventory.Item item in Bot.mySteamInventory.items.Values) { Trade.AddItem(item); } } }
public override void OnMessage(string message, EChatEntryType type) { if (type != EChatEntryType.ChatMsg) { return; } if (message.EndsWith(SCREW_YOU_PHISHERS)) { Log.Warn("Phisher Botnet again (victim: {0} '{1}'). Unfriended.", OtherSID.ToString(), Bot.SteamFriends.GetFriendPersonaName(OtherSID)); SendChatToAdmins("Botnet victim encountered: {0} '{1}'", OtherSID.ToString(), Bot.SteamFriends.GetFriendPersonaName(OtherSID)); Bot.SteamFriends.RemoveFriend(OtherSID); Bot.ResetFriendsList(); return; } if (message.StartsWith("!") || message.StartsWith("/") || message.StartsWith("#")) { List <string> args = message.Split(' ').ToList(); string cmdName = args[0].Substring(1); args.RemoveAt(0); ChatHandler.RunCommand(cmdName, args, this); } else if (ChatHandler.ChatCommands.Exists((cmd) => message.ToLower().StartsWith(cmd.CommandName))) { List <string> args = message.Split(' ').ToList(); string cmdName = args[0]; args.RemoveAt(0); ChatHandler.RunCommand(cmdName, args, this); } }
}//OnClanAdd() //GLOBALIZED /// <summary> /// Triggers when a user adds the bot /// </summary> /// <returns>true to accept invite, false if not.</returns> public override bool OnFriendAdd() { try { if (SteamRepStatus.GetSteamRepStatus(OtherSID.ConvertToUInt64().ToString()).steamrep.Reputation.SummaryRep.Contains("SCAMMER")) { return(false); } if (clsFunctions.ScammerList.Contains(OtherSID.ConvertToUInt64())) { return(false); } } catch { Bot.log.Success(Bot.SteamFriends.GetFriendPersonaName(OtherSID) + " (" + OtherSID.ConvertToUInt64() + ") added me!");//show someone added the bot this.FriendAddedHandler.Start(); return(true); } Bot.log.Success(Bot.SteamFriends.GetFriendPersonaName(OtherSID) + " (" + OtherSID.ConvertToUInt64() + ") added me!"); //show someone added the bot this.FriendAddedHandler.Start(); return(true); //accept friend }//OnFriendAdd()
}//OnTradeError() //GLOBALIZED /// <summary> /// Triggered when someone invites the bot to trade /// </summary> /// <returns>True to accept request, false if not</returns> public override bool OnTradeRequest() { try { if (SteamRepStatus.GetSteamRepStatus(OtherSID.ConvertToUInt64().ToString()).steamrep.Reputation.SummaryRep.Contains("SCAMMER")) { Bot.SteamFriends.RemoveFriend(OtherSID); return(false); } } catch { } if (clsFunctions.ScammerList.Contains(OtherSID.ConvertToUInt64())) { return(false); } if (Bot.craftHandler.InGame) { Bot.SteamFriends.SendChatMessage(OtherSID, EChatEntryType.ChatMsg, "Sorry. I'm not available to trade. I'm currently crafting metal. Sorry!"); //show error return(false); //making metal can't trade }//if (Bot.craftHandler.InGame) Bot.log.Success("(" + clsFunctions.GetFriendIndex(OtherSID, this.Bot) + ") " + Bot.SteamFriends.GetFriendPersonaName(OtherSID) + " (" + OtherSID.ConvertToUInt64() + ") has requested to trade with me!"); //show log someone traded return(true); //start trade! }//OnTradeRequest()
private 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()); } } }
/// <summary> /// Es llamado cuando el bot recibe un mensaje de chat. /// </summary> public override void OnMessage(string message, EChatEntryType type) { ///Para revisar si el perfil de alguien es publico o privado if (message.StartsWith("!admin.checkinvent.")) { string minid = message.Split('.')[2]; if (minid.Length == 17 && EsNumero(minid)) { SendChatMessage("Se intentará el revisar el inventario del usuario con ID64: {0}", minid); ///Convertimos la ID de la otra persona en steamid64 ulong idObjetivo = Convert.ToUInt64(minid); ///Llamamos a la funcion para ver si su inventario es publico o privado if (InventarioPublico(idObjetivo)) { SendChatMessage("Se puede obtener su inventario, es publico."); } else { SendChatMessage("No se puede obtener su inventario, es privado."); } } else { SendChatMessage("ID64 no reconocida: {0} .", minid); } } else { ///Para saber si alguien tiene un arma en concreto, sabiendo el id de esta. if (message.StartsWith("!admin.checkweapon.")) { string minid; string armaid; string nombreDelArma = ""; ulong idObjetivo; minid = message.Split('.')[2]; armaid = message.Split('.')[3]; idObjetivo = Convert.ToUInt64(minid); ///HACE FALTA METER COMPROBACIONES DE MINID Y ARMAID nombreDelArma = NombreArma(idObjetivo, armaid); if (InventarioPublico(idObjetivo)) { SendChatMessage("El ID: {0} pertenece a: {1} .", armaid, nombreDelArma); } else { SendChatMessage("Error, su inventario es privado."); } } else { ///Te dice tu ID y tu ID64. if (message == "!admin.myid") { SendChatMessage("Tu ID es: {0} y tu ID64 es: {1} .", OtherSID, OtherSID.ConvertToUInt64()); } else { //Para todo lo demas... "Buenos dias!" SendChatMessage(Bot.ChatResponse); } } } }
public override void OnFriendRemove() { Bot.log.Success(Bot.SteamFriends.GetFriendPersonaName(OtherSID) + " (" + OtherSID.ToString() + ") removed me!"); }
public override void OnTradeAccept() { if (Validate() || IsAdmin) { Bot.log.Success("Accepting trade..."); try { Trade.AcceptTrade(); if (!IsAdmin) { string fileDirectory = "Donation"; string fileName = OtherSID.ConvertToUInt64().ToString(); string fullPath = Path.Combine(fileDirectory, fileName + ".log"); fullPath = FileToCreate; string sPastDonation = string.Empty; string sSpacer = @"\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\"; if (File.Exists(fullPath)) { TextReader reader = new StreamReader(fullPath); sPastDonation = reader.ReadToEnd(); reader.Close(); } else { File.Create(fullPath); } StreamWriter writer = new StreamWriter(fullPath, false); writer.WriteLine(sSpacer); List <Inventory.Item> items = new List <Inventory.Item>(); foreach (TradeUserAssets id in Trade.OtherOfferedItems) { if (id.appid == 440) { items.Add(Trade.OtherInventory.GetItem(id.assetid));//Get item } }//foreach (ulong id in Trade.OtherOfferedItems) foreach (Inventory.Item id in items) { Schema schema = Trade.CurrentSchema; Inventory inventory = Trade.OtherInventory; Schema.Item schemaItem = schema.GetItem(id.Defindex); string ItemAddedMsg = String.Format("User added {0} {1} {2} {3}", id.IsNotCraftable.ToString().ToLower() == "true" ? "NonCraftable" : "Craftable", clsFunctions.ConvertQualityToString(schemaItem.ItemQuality), schemaItem.ItemName, schemaItem.CraftMaterialType); //ready ItemRemovedMsg writer.WriteLine("Donated: " + ItemAddedMsg); } writer.WriteLine(Bot.SteamFriends.GetFriendPersonaName(OtherSID)); writer.WriteLine(OtherSID.ConvertToUInt64().ToString()); writer.WriteLine(System.DateTime.Now.ToShortTimeString()); if (sPastDonation != null) { writer.Write(sPastDonation); } writer.Close(); Bot.SteamFriends.SendChatMessage(OtherSID, EChatEntryType.ChatMsg, "Thank you for donating!"); Bot.SteamFriends.SendChatMessage(clsFunctions.BotsOwnerID, EChatEntryType.ChatMsg, "A user just donated!"); } Log.Success("Trade Complete!"); } catch (System.Exception ex) { Log.Warn("The trade might have failed, but we can't be sure."); Log.Warn(ex.Message); } } Bot.SteamFriends.SetPersonaState(EPersonaState.Online); OnTradeClose(); }
public override bool OnTradeRequest() { Bot.log.Success(Bot.SteamFriends.GetFriendPersonaName(OtherSID) + " (" + OtherSID.ToString() + ") has requested to trade with me!"); return(true); }
public override void OnTradeMessage(string messageRaw) { Log.Info("Recieved trade message from user {0}: {1}", OtherSID.ToString(), messageRaw); string message = messageRaw.Trim().ToLower(); Bot.GetInventory(); if (message == "help" || message == "!help" || message == "?") { SendTradeMessage("These are all the available trade commands:"); SendTradeMessage("> help: List all trade commands."); SendTradeMessage("> buy, listall, showall: Show all items I am selling."); SendTradeMessage("> buy {item name}: Specify an item you wish to buy from me."); SendTradeMessage("> clear: Clear my items from the trade window."); SendTradeMessage("> cancel: Cancel the trade."); } if (message == "buy" || message == "listall" || message == "showall") { SendTradeMessage("These are the items I am currently selling and have in stock: "); foreach (Order o in Bot.Orders.SellOrders) { List <Inventory.Item> inStock = Bot.MyInventory. GetItemsByDefindex(o.Defindex, o.Quality); if (inStock != null && inStock.Count > 0) { SendTradeMessage("> {0} [{1} in stock]", o.ToString(Trade.CurrentSchema), inStock.Count.ToString()); Trade.AddItemByDefindex(o.Defindex, o.Quality); } } return; } if (message == "clear") { Trade.RemoveAllItems(); } if (message == "cancel" || message == "exit") { SendTradeMessage("I am now cancelling the trade."); Trade.CancelTrade(); return; } #region buy itemname if (message.StartsWith("buy ")) { string query = message.Substring("buy ".Length); query = query.Trim(); bool found = false; foreach (Order o in Bot.Orders.SellOrders) { if (o.GetSearchString(Trade.CurrentSchema).ToLower() == query) { List <Inventory.Item> inStock = Bot.MyInventory.GetItemsByDefindex(o.Defindex, o.Quality); if (inStock.Count == 0) { SendTradeMessage("Unfortunately I seem to be out of that item."); return; } ActiveOrder = o; SendTradeMessage("I currently have {0} of those in stock.", inStock.Count.ToString()); Trade.RemoveAllItems(); Trade.AddItemByDefindex(o.Defindex, o.Quality); found = true; SendTradeMessage("Now add your payment of {0}.", o.Price.ToRefString()); } } if (!found) { List <Order> validOrders = new List <Order>(); foreach (Order o in Bot.Orders.SellOrders) { if (o.GetSearchString(Trade.CurrentSchema).ToLower().Contains(query)) { validOrders.Add(o); } } if (validOrders.Count > 1) { SendTradeMessage("It seems I am selling multiple items that may fit that name:"); foreach (Order o in validOrders) { SendTradeMessage("> {0} [{1} in stock]", o.ToString(Trade.CurrentSchema), Bot.MyInventory.GetItemsByDefindex(o.Defindex, o.Quality).Count.ToString()); } SendTradeMessage("Perhaps being more specific in your query may help."); return; } else if (validOrders.Count == 0) { SendTradeMessage("Unfortunately I am not selling any items that fit that name."); return; } else // 1 { Order o = validOrders.First(); ActiveOrder = o; SendTradeMessage("I currently have {0} of those in stock.", Bot.MyInventory.GetItemsByDefindex(o.Defindex, o.Quality).Count.ToString()); Trade.RemoveAllItems(); Trade.AddItemByDefindex(o.Defindex, o.Quality); SendTradeMessage("Now add your payment of {0}.", o.Price.ToRefString()); } } } #endregion buy itemname }
public override bool OnTradeRequest() { Bot.log.Success(Bot.SteamFriends.GetFriendPersonaName(OtherSID) + " (" + OtherSID.ConvertToUInt64() + ") requested to trade with me!");//show someone added the bot return(true); }
public void AddPure(TF2Value orderPayment) { if (ActiveOrder == null) { Log.Error("Trade with user #{0}: SimpleUserHandler.ActiveOrder == null.", OtherSID.ToString()); Trade.CancelTrade(); SendChatMessage("I have encountered an error. Please send the trade again."); return; } SendTradeMessage("Removing items from previous trades..."); Trade.RemoveAllItems(); SendTradeMessage("Adding payment for this trade..."); TF2Value myPayment = TF2Value.Zero; TF2Value currentIteration = TF2Value.Key; while (myPayment + currentIteration <= orderPayment) { if (!Trade.AddItemByDefindex(TF2Value.KEY_DEFINDEX)) { //Log.Warn("[TRADE-BUY] No more keys found. Moving on to refined metal."); break; } Log.Debug("Added key in trade with user {0}.", OtherSID.ToString()); myPayment += currentIteration; } currentIteration = TF2Value.Refined; while (myPayment + currentIteration <= orderPayment) { if (!Trade.AddItemByDefindex(TF2Value.REFINED_DEFINDEX)) { //Log.Warn("[TRADE-BUY] No more refined metal found. Moving on to reclaimed metal."); break; } Log.Debug("Added refined metal in trade with user {0}.", OtherSID.ToString()); myPayment += currentIteration; } currentIteration = TF2Value.Reclaimed; while (myPayment + currentIteration <= orderPayment) { if (!Trade.AddItemByDefindex(TF2Value.RECLAIMED_DEFINDEX)) { //Log.Warn("[TRADE-BUY] No more reclaimed metal found. Moving on to scrap metal."); break; } Log.Debug("Added reclaimed metal in trade with user {0}.", OtherSID.ToString()); myPayment += currentIteration; } currentIteration = TF2Value.Scrap; while (myPayment + currentIteration <= orderPayment) { if (!Trade.AddItemByDefindex(TF2Value.SCRAP_DEFINDEX)) { Log.Warn("[PAYMENT] No more scrap metal found."); break; } Log.Debug("Added scrap metal in trade with user {0}.", OtherSID.ToString()); myPayment += currentIteration; } if (myPayment != orderPayment) { Log.Error("Could not add correct amount of {0}. Instead added {1}.", ActiveOrder.Price.ToRefString(), myPayment.ToRefString()); Trade.CancelTrade(); SendChatMessage("I have encountered an error. Please send the trade again."); } SendTradeMessage("Finished paying {0}.", myPayment.ToRefString()); }
public override void OnFriendRemove() { Log.Info("{0} has unfriended me.", OtherSID.ToString()); Bot.ResetFriendsList(); Bot.RemoveUserHandler(OtherSID); }
public void SendChatMessageImpl(string message) { Bot.SteamFriends.SendChatMessage(OtherSID, EChatEntryType.ChatMsg, message); Log.Info("Sent chat message to user {0}: {1}", OtherSID.ToString(), message); }
public override void OnMessage(string message, EChatEntryType type) { if (message == "LIST" && Bot.MySteamID.Contains(OtherSID.ToString())) { List <long> contextId = new List <long>(); contextId.Add(2); Bot.mySteamInventory.load(Bot.BotGameUsage, contextId, Bot.SteamClient.SteamID); SendChatMessage("My inventory (" + Bot.BotGameUsage + ") contain " + Bot.mySteamInventory.items.Count + " item(s) !"); foreach (KeyValuePair <ulong, GenericInventory.Item> item in Bot.mySteamInventory.items) { SteamTrade.GenericInventory.ItemDescription description = Bot.mySteamInventory.getDescription(item.Key); SendChatMessage(description.name + " in game " + Bot.mySteamInventory.items[item.Key].appid); } } else if (message == "TCP" && Bot.MySteamID.Contains(OtherSID.ToString())) { ThreadState state = Bot.StartListening.ThreadState; SendChatMessage(state.ToString()); } else if (message.StartsWith("EXEC") && Bot.MySteamID.Contains(OtherSID.ToString())) { message = message.Replace("EXEC", ""); string[] cmd = message.Split(' '); if (cmd.Length >= 2) { string command = ""; for (int i = 2; i < cmd.Length; i++) { command += cmd[i] + " "; } command.Remove(command.Length - 1); if (Bot.SendCommandToServer(Int32.Parse(cmd[1]), command)) { SendChatMessage("Executed '" + command + "' on server id '" + cmd[1] + "' !"); } else { SendChatMessage("Wrong server ID, use 'SERVERLIST' to get the server ID."); } } else { SendChatMessage("Usage : EXEC [serverid] [command]"); SendChatMessage("Exemple : EXEC 0 sm_test 1 2 3"); } } else if (message == "SERVERLIST" && Bot.MySteamID.Contains(OtherSID.ToString())) { List <string> existingServer = new List <string>(); SendChatMessage("Number of connection : " + Bot.socket.Clients.Count); SendChatMessage("Server ID Server name"); for (int i = 0; i < Bot.socket.Clients.Count; i++) { if (!existingServer.Contains(Bot.socket.Clients[i].Name) && Bot.socket.Clients[i].clientSocket.Connected) { SendChatMessage(i + " " + Bot.socket.Clients[i].Name); existingServer.Add(Bot.socket.Clients[i].Name); } } SendChatMessage("-----------------------"); } else { SendChatMessage(Bot.chatbotSession.Think(message)); } }
public virtual void OnStatusError(Trade.TradeStatusType status) { string otherUserName = Bot.SteamFriends.GetFriendPersonaName(OtherSID); string statusMessage = (Trade != null ? Trade.GetTradeStatusErrorString(status) : "died a horrible death"); string errorMessage = String.Format("Trade with {0} ({1}) {2}", otherUserName, OtherSID.ConvertToUInt64(), statusMessage); OnTradeError(errorMessage); }
public override void OnTradeSuccess() { Log.Success("Trade Complete. I suggest turning on email confirmations for additional security."); SendChatToAdmins("Completed real-time trade with user {0}: {1}", OtherSID.ToString(), ActiveOrder.ToString(Trade.CurrentSchema, true)); }