jessecar96 / steambot Goto Github PK
View Code? Open in Web Editor NEWAutomated bot software for interacting with Steam Trade
Home Page: http://scrap.tf
License: MIT License
Automated bot software for interacting with Steam Trade
Home Page: http://scrap.tf
License: MIT License
What do you guys think, should we add versioning to the SteamBot?
I am trying to follow the directions in the readme and have made it to
You mainly only need to edit the file TradeEnterTradeListener.cs, as it contains events for everything you need.
This file doesn't exist. Could the readme get updated to reflect what I should be doing?
Is the usage
section accurate or has that changed as well? Unless my search-fu has broken, I can't seem to find the indicated functions in the code.
When a trade is cancelled due to a timeout, it keeps getting polled. Therefore, the OnTimeout() function executes every 800 ms, causing the user who was trading with the bot to be spammed with "Sorry, but you were AFK and the trade was canceled." until the bot is shut down.
Can anyone duplicate this problem? I'm kind of new to C# (as in I started using it today), but I think that CurrentTrade should be set to null in the CancelTrade() function.
Thank you.
I am admin of the bot but when I try to use any of the help, add or remove commands it doesn't work.
Either by steam chat or trade chat.
Any help ?
We need to improve the documentation readily available for people who want to use the SteamBot, especially for the TradeEnterTradeListener
class.
I was interested in using the bot for Dota 2 item trading. But, I assume the item details are different between the two games, and it is causing the bot to crash when a non-TF2 item is added to the trade window.
The errors given are:
ERROR: Error Polling Trade: System.NullReferenceException: Object reference not set to an instance of an object.
at .......\Trade.cs:line 541
at SteamBot.Bot.<.ctor>b__2() in c:\..........\Bot.cs:line 132
Opened up steambot.sln and ran the build, when I try to debug it however I get:
Launching bot 0
Connection Callback: OK
Logged on callback: invalidPassword
Login Failure: invalidPassword
to which the last 3 lines continue to repeat ad infinitum. And this is before I enter in any details or get any prompts. It seems to be coming from SteamKit2.SteamClient
When canceling a trade, CancelTradeWebCmd
returns false.
This leads to an infinite loop with this stack trace appearing in the console:
[Man in a Yellow Hat 06/11/2012 01:00:32] ERROR: Error Polling Trade: SteamTrade.Exceptions.TradeException: The Web command to cancel the trade failed
at SteamTrade.Trade.CancelTrade() in C:\Users\George\SteamBot\SteamTrade\Trade.cs:line 271
at SteamTrade.Trade.Poll() in C:\Users\George\SteamBot\SteamTrade\Trade.cs:line 468
at SteamBot.Bot.<.ctor>b__1() in C:\Users\George\SteamBot\SteamBot\Bot.cs:line 133
When a player trading with the bot cancels the trade on their own, the bot doesn't seem to know this. It will send them a message when the AFK timer would have run out informing them that the trade was cancelled because they were AFK.
All methods in the Trade
class that do something on the net should return boolean variables indicating success or failure.
See this comment in #64.
Currently when the bot is in a trade and another user wants to trade with the bot, the current trade is overriden and the new one is used.
This has also to do with trade end detection as the bot is currently unable to stop polling a timed out or finished trade.
In order to get item names that are what you normally see when playing the game the http://api.steampowered.com/IEconItems_440/GetSchema/v0001/ needs to have &language=en added (for english items).
Im not good enough at this to figure it out myself, but maybe an option in the settings file to set the language would be nice?
I don't know what we need Main.cs for now.
Is it possible to determine if a user is free to play in team fortress 2?
hello,
I'm having a little problem to cause the bot to add a friend.
I did a routine in Program.cs to consult the database, and if there vefificar a field with value '0 '.
find the value, adds the friend by your steam id or by e-mail.
I tried several ways but could not make it work.
perhaps erring on the class in which I am doing Bot.SteamFriend.addFreind ();
I'm adding in SimpleUserHandler.cs
Thanks, and sorry for anything
Trying to compile the ExampleBot, I get the following error.
Error 5 'SteamKit2.WebHelpers' is inaccessible due to its protection level C:\Users\rannmann\Documents\GitHub\SteamBot\SteamBot\Bot.cs 351 25 ExampleBot
The line:
sessionId = WebHelpers.EncodeBase64(callback.UniqueID.ToString());
I live in the web developer world and haven't really touched compiled languages since my college days, so it could be PEBKAC. Any information would be appreciated!
Hello. Few weeks ago I add method to SteamKit (SteamFriends.cs) in order to remove all friends when bot log in.
public void RemoveAllFriends()
{
var removeFriend = new ClientMsgProtobuf<CMsgClientRemoveFriend>( EMsg.ClientRemoveFriend );
foreach (SteamID id in friendList)
{
removeFriend.Body.friendid = id;
this.Client.Send( removeFriend );
}
}
Then I called at the end of Authenticate() in Bot.cs. It worked. Since then, there were made some changes and it is not working anymore. Anyone have an idea where I could put it in order to purge friend list?
The bot should have better logging:
Bot crashes if trade with bot is initiated and canceled before the bot can send welcome message.
The error log:
Unhandled Exception: SteamTrade.Exceptions.TradeException: The web command to send the trade message failed.
at SteamTrade.Trade.SendMessage(String msg) in D:\dev\sb\SteamBot\SteamTrade\Trade.cs:line 426
at SteamBot.AdminUserHandler.OnTradeInit() in D:\dev\sb\SteamBot\SteamBot\AdminUserHandler.cs:line 85
at SteamBot.Bot.OpenTrade(SteamID other) in D:\dev\sb\SteamBot\SteamBot\Bot.cs:line 170
at SteamBot.Bot.<HandleSteamMessage>b__b(SessionStartCallback callback) in D:\dev\sb\SteamBot\SteamBot\Bot.cs:line 305
at SteamKit2.CallbackMsg.Handle[T](Action`1 handler) in D:\dev\sb\SteamBot\Lib\SteamKit2\SteamKit2\Steam3\SteamClient\CallbackMgr\CallbackMsg.cs:line 72
at SteamBot.Bot.HandleSteamMessage(CallbackMsg msg) in D:\dev\sb\SteamBot\SteamBot\Bot.cs:line 303
at SteamBot.Bot.<.ctor>b__1() in D:\dev\sb\SteamBot\SteamBot\Bot.cs:line 119
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
If you try and add multiple items of the same defindex to the trade, it simply adds one and moves it around to subsequently requested slots instead of actually adding more than one item.
For example (5000 = scrap metal):
trade.AddItemByDefindex(5000, 0);
trade.AddItemByDefindex(5000, 1);
This code would result in a single scrap metal being added in slot 0, and then being moved to slot 1.
Thank you.
I see that the bot does a check to see if the user it is trading with has a private backpack. Is this needed? Can my custom class skip that step? I'm curious why it needs to see it when the items are presented to it in the trade.
This is probably a stupid question, but I can't manage to get the bot's inventory. How would I do this?
Is crafting a planned feature? I'm pretty sure it's possible, and it would make a great feature to make bots able to craft. Maybe start off with combining/smelting metal, since that's a pretty basic and predictable recipe.
I can't be of much help myself in this situation, as I have no experience with SteamKit.
I have applied the latest Commit for the Bot.cs to save the SteamGuard Machine Code in Visual Studio 2010 and after compiling it, it's working just fine (creates a sentryfile and doesn't prompt again for the Auth-Code).
However, trying to port it onto Debian Squeez (with Mono 2.10.8.1 compiled from Sources) fails, as it's prompting again for the Auth Code everytime I start the Program.
Oddly enough, the sentryfile is getting created, but somehow everytime when I lauch the Program, a new Auth Code is generated and the existing one ignored.
Is this a known Issue on Linux and was somebody able to get it working there? (without prompting for the Code everytime)
MySteamId is null when FetchInventories() is called.
// Trade.cs line 88
public readonly SteamID MySteamId;
// constructor:
public Trade (SteamID me, SteamID other, string sessionId, string token, string apiKey, int maxTradeTime, int maxGapTime)
{
mySteamId = me;
what is the deal here?
Assigning MySteamId (note case) solves this for me, though. I'd post a patch or whatsit, but i'm not familiar with all those sort of tools yet.
When you input this:
trade.AddItemByDefindex(4100,0);
// here optional pause for ~1 sec eg. with Thread
trade.AddItemByDefindex(4100,1);
To any event, it will move the same item from slot 0 to slot 1, instead of adding new item of same type to slot 1.
When starting a new Trade, it almost times out for me because the bot is busy fetching the other player's inventories. This should be made async somehow.
Found this out the hard way by copy-pasting configuration items in settings.json
where logFile
was the same value for each bot.
Also steam guard was on for the bot accounts and it was prompting for the code when this happened but I'm not sure if that's related.
I've received reports that the SteamBot times out when traded (everything up until then works perfectly fine). When you trade it, it gives the OnAfterInit
message, but after that (no matter what you do as a client), it times out. I think it might have to do with it not polling correctly, but I haven't been able to test that.
This issue is in the source code up until c5bd85b, and I'm sure after that commit, as well.
All the trading and SteamWeb stuff shouldn't be in the Bot repository. Trading should be a dedicated library (or maybe commit to SteamKit?).
It would be much easier to read and maintain if a Trade was completely seperated from the "TradeSystem", so that you would have a Trade that you can interact with and a TradeSystem that handles all those events.
In order to effectively use AddItem
, AddItemByDefindex
, RemoveItem
, and RemoveItemByDefindex
, we should add a list of the slots items are occupying in the trade.
instead of using settings.json.. is it possible to start the exe with parameters such as login name and password and classname.. so you can set batch file for different logins/ behaviour?
Hi guys, nice work with bot, i making it for dota 2 trades, but i got some errors:
ERROR: Error Polling Trade: System.NullReferenceException - SteamBot.Bot.<.ctor>b__1() in SteamBot\SteamBot\Bot.cs:line 135
ERROR: Error Polling Trade: SteamTrade.Exceptions.TradeException: The web command to set trade ready state failed.
SteamTrade.Trade.SetReady(Boolean ready) - SteamBot\SteamTrade\Trade.cs:line 374
SteamBot.SimpleUserHandler.OnTradeReady(Boolean ready) - SteamBot\SteamBot\SimpleUserHandler.cs:line 69
SteamTrade.Trade.Poll() - SteamBot\SteamTrade\Trade.cs:line 496
I cannot fix it, haven't looked all your code yet. Sometimes trades goes succesfully without any errors, but sometimes i got this errors.
I use this method to add all the bot's weapons to a trade.
public int DumpWeapons()
{
int count = 0;
foreach (Inventory.Item invItem in Trade.MyInventory.Items)
{
Schema.Item schemaItem = Trade.CurrentSchema.GetItem(invItem.Defindex);
if (schemaItem.CraftMaterialType == "weapon")
{
Trade.AddItem(invItem.Id);
count++;
}
}
return count;
}
Whenever this is executed, the bot throws this error (in Visual Studio's debug mode):
[SteamBot 2012-11-10 14:02:54] ERROR: Error Polling Trade: System.Exception: Error validating local copy of items in the trade!
at SteamTrade.Trade.ValidateLocalTradeItems() in [redacted]\SteamBot\SteamTrade\Trade.cs:line 661
at SteamTrade.Trade.Poll() in [redacted]\SteamBot\SteamTrade\Trade.cs:line 467
at SteamBot.Bot.<>c__DisplayClass4.<.ctor>b__1() in [redacted]\SteamBot\SteamBot\Bot.cs:line 135
This also seems to happen when a user adds items the the trade quickly.
I think this may be caused when items are added faster than the trade polling interval, but I'm not sure.
As the title says, if the target inventory is empty, it will return an empty error and success: false.
I fixed it by giving my bot an item.
I know the error is not on your side, but it might be helpful not to crash when fetching an inventory failed.
When idle time reaches the limit, the bot sends the appropriate message
Sorry, but you were AFK and the trade was canceled.
However, the trade is never actually cancelled. Because of this, the message is sent repeatedly until the user closes his/her trade session.
The bot might eventually end up with too many friends on its friend list; we should probably prevent that from happening by removing friends.
Everytime I download the tf2 item schema it seems to take quite a while. We should cache what is downloaded to a file and reuse that on next launch. When the schema gets updated, only then download it again. Rinse and repeat.
Are you going to fix the raffle bot to working status like the current bot? I could write the front end for you in ajax + j query with steam log in and user dashboard if your willing to fix it.
Keep an eye on this issue for more information: https://bitbucket.org/VoiDeD/steamre/issue/28/memory-leak-in-steamfriends
If someone on the bot's friend's list is connected from a mobile device, an infinite number of SteamFriends+PersonaStateCallback objects are created, leading to massive memory leaks (I clocked it around 25MB/minute).
It's really awful to get intendation right with these mixed intendations.
I am using an array to grab chosen item ids by the other user from my backpack and then using the array to represent the "itemid" variable in Trade.AddItem. I noticed it was a bool so I also tested it in a if statement with it sending a message over trade when the bool returns true.
Please excuse my noobyness to C# in general and GitHub Markdown, but this is an example of my code:
if (message == "1")
{
//I have some other stuff in here cant remember at the moment, i'm at school.
if (Trade.AddItem(hatidchoices[1]))
{
Trade.SendMessage("I shouldve added my item.");
}
}
And at first I had:
if (message == "1")
{
//I have some other stuff in here cant remember at the moment, i'm at school.
Trade.AddItem(hatidchoices[1]);
Trade.SendMessage("I shouldve added my item.");
ItemsIHaveAdded++;
}
I logs nothing pertaining to the adding of the item, but does send the string "i shouldve added my..." in trade chat. Before this if statement is a foreach statement that helps my grab my inventory and add the craft hat ids to this array "hatidchoices". It also lists the items to the other user with a number associated to it(the location of the id in the array) so the user can choose the hat they want.
So, it gives no error, adds no item, but runs through the command anyways. Is there something i'm doing wrong? Thanks.
Make AddItem
and RemoveItem
only modify the local copy, and when Poll
gets called, update steam with the local copy of data. Can we do it?
Since 12/12/2012 Steam Trade system will not work on accounts with disabled SteamGuard. Is any possibility to store once entered and linked SteamGuard confirmation code?
On line 170 - GetUserHandler (other).OnTradeInit ();
This line should be removed because sometimes it runs before trade is actually setup and may add some errors (for example message from SimpleUserHandler throws error). Also at previous line there are already subscription for this event.
Btw Bot.OpenTrade() don't works for me at all even after this fix, just doing nothing and throwing AFK error after 2-3 minutes. An second issue caused by such fail:
Bot try to send "Cancel Trade" request because of "AFK", but the trade wasn't actually started and this throws error. You should add some checks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.