Jessecar96 / SteamBot

Automated bot software for interacting with Steam Trade
http://scrap.tf
MIT License
1.33k stars 911 forks source link

Auto trading between idle accounts #133

Closed dspaan closed 11 years ago

dspaan commented 11 years ago

Hi,

I've manged to get the bot with default config running.

I have a bunch of idle accounts which i use with TF2Idle. I'd like to configure all my idle accounts so they can run as bots and trade their items to one main account. Has anyone done this before? If not, what would be the steps to configure this?

The readme file says to edit the SimpleUserHandler.cs and UserHandler but when i skim through them i seem to be missing basic knowledge/reference how to make sense of these files. Where do i begin?

I noticed that when you say hi to the bot it responds with 'Hi there bro'. Where is it getting that response from? I didn't see it in aforementioned files.

StormReaper commented 11 years ago

The response is in the settings.json and its a bit deeper down, for your purposes if you want to just trade between idlers and your main account you can use the AdminUserHandler class have a look through it, there are some methods for adding metal/weapons in there. This would still require you to be at the receiving end and command the bots through the chat, if you want something more complex than that such as trading between bots you'll have to write your own versions of the UserHandler implementation. I think a few might have done this before but I haven't seen any code posted.

geel9 commented 11 years ago

You would need to code two user handlers; one that accepts the items and one that sends the items over.

DrProfAxesome commented 11 years ago

I tried to have two bots trade between each other. They kept getting stuck because one would have to ready up first, and the other would automatically follow, but the bot would crash the trade with Trade.SetReady(true); and so the trade wouldn't be complete. The weirdest part was that sometimes it would ready up, and other times it would crash the trade

tkphoto commented 11 years ago

Ive done trading between 2 bots, it works most of the time.. but there is certainly a glitch that stops it working all the time.. doesnt crash though.

The simple way to do the trades, is making the bots send text messages in trades and responding to those..

ie. One will say !giveitems.. and it will add items.. followed by !imdone.. then having response for !imdone.. to readyup etc..

tkphoto commented 11 years ago

the Trade.SetReady(true) crashes if its part of the adding items.. which is why you need Trade.SetReady(true) to be done as a seperate response to text as i said above:)

dspaan commented 11 years ago

tkphoto can you share your code? Seems i have to learn how to interpret those cs files first.... Currently i'm using autohotkey to trade between accounts which requires me to launch a script for each pair of main and idle account. I wonder if there is a way to just push a button, walk away and let 30 accounts trade with eachother succesfully. Does it work like that for you?

tkphoto commented 11 years ago

Im not going to share the code.. as i have not had the time to impliment moving on to the next account in sequence yet.

Unless you have a basic understanding of c#, its really going to be a headache to have a custom bot doing precisely what you want to achieve. I know alot of idlers who use autohotkey for trading between accounts,there must be an easier way with the program.. as i know someone with 800+ accounts with autohotkey.. i cant see them doing one at a time

dspaan commented 11 years ago

Alright well thanks for sharing the info, i can undertand that it's not very useful to sharing the code when it can't do multiple trades. Seems i'm going back to improving my Autohotkey script then or find someone who has made one and is willing to share it. Maybe you can ask your friend for me, that would be awesome.

tkphoto commented 11 years ago

Yes, its not worth sharing when its not coded for multiple trades at the moment, and until i can work out why 1 in 10 fail still.. it seems little point progressing to the next step.. Hopefully someone else will have an idea, as i would also be interested in the coding .

Payme commented 11 years ago

Yeah im working on this at the moment also, im willing to share my code for adding all items if you need help with that. Only thing stopping me is #127 .

Also with the trading multiple accounts, what i was thinking was to have an array of all the bots with their steamID then trade one id, set up the auto trading, after OnTradeAccepted(), trade the next id remove from array, rinse repeat. hope that makes sense.

dspaan commented 11 years ago

I worked for 8 hours on an autohotkey script last night and it's working! It starts up my sandboxes and trades to my main account. It also handles trading errors buy terminating sandboxes and retrying. Still working on perfecting the interface of the app so you can select which accounts you want to trade with, using a txt file now.

jamlord commented 11 years ago

@dspaan I'd be very interested in seeing your results when your done.

@tkphoto I've had a good amount of success getting the bot to try and trade several accounts by adding a queue into the callback from getting the friends list by adding anyone considered an admin to it and then setting up a thread to monitor if the user is in trade and automatically trade the next user in queue once one trade is done.

ghost commented 11 years ago

Sort of bumping an old thread here but @dspaan I would be very interested in your code for autohotkey. Is it possible for you to share it? I can give you my steam username if you want?

@Payme I am very interested in your coding behind this, I am completely new to this and C# however.

dspaan commented 11 years ago

Well i'm still trying to perfect it and make it so it can be used by others. Currently it has my account info in the script so i need to make variables for that. Once i release it i will post it here. Expect it to be a couple of weeks.

ghost commented 11 years ago

@dspaan thanks for the quick reply, I'll be trying to get my head around this SteamBot for the time being. Good luck with the ahk script, cant wait to see the finished project! :D

teliosdev commented 11 years ago

In order to have two bots trade each other, you'd have to have them first determine which is the master and which is slave. I'd assume the one that received the command would be the master (or the slave, if you're into that sort of thing :P), and thus would initialize the trade and telll the other bot (through the chat, assuming that both bots have authenticated with each other before hand) what items to put up, and then ready up (and tell the other too, as well), and finish the trade. I could implement something like this along with my idea for an API provided with the bot so that source file modification is not required.

ghost commented 11 years ago

How would I go about telling the bot to add all of its inventory to the trade window? A working example of this would be when I load up my bots (idle accounts) and they finish logging in, a basic form of auto trading would be to initiate a trade with each one, once we get into trade I would pass some kind of command in the chat window and it would add its entire inventory into the trade window, then ready up once ive readied up?

luckydonald commented 11 years ago

I tried this too, got the communication part so far. But now I don't get any trade request from the bot. Neither as other bot nor as Admin. The command got executed, I got the according Log. Any idea how to fix this or were the error might be? .

if (message.Contains("!goandtrademe_goddammit_thisdoesnotwork")&&(IsOperatorBot|IsAdmin)){
                this.Bot.OpenTrade(OtherSID.AccountID);
                Log.Info("Triggered Comand: "+Messages.CollectorRequestMsg);

as seen in MyLittleCustomHandler : UserHandler ~> OnMessage()

and maybe I can help you out with the adding problem:

public uint AddAllItems (int defindex, uint numToAdd = 0)
{
    List<Inventory.Item> items = MyInventory.GetItemsByDefindex (defindex);
    uint added = 0;
    foreach (Inventory.Item item in items)
    {
        if (item != null)
        {
            bool success = AddItem (item.Id);
            if (success)
                added++;

            if (numToAdd > 0 && added >= numToAdd)
                return added;
        }
    }
    return added;
}

as seen in MyLittleCustomHandler : UserHandler

teliosdev commented 11 years ago

The | operator is the bitwise OR operator, I think you're meaning to look for ||...

luckydonald commented 11 years ago

thanks for the help, it accually was the OtherSID.AccountID because the SID was needed not the ID of it.

this.Bot.OpenTrade(OtherSID);

also the addAll function above was wrong and couldn't work.

public uint AddAllItems (uint numToAdd = 0)
{
    uint added = 0;
    foreach (Inventory.Item item in Trade.MyInventory.Items)
    {
        if (item != null)
        {
            bool success = Trade.AddItem(item.Id);
            if (success)
                added++;
            if (numToAdd > 0 && added >= numToAdd)
                return added;
        }
    }
    return added;
}

Yeah. this might work better. At least no syntax Errors or such thing. Sadly the Bot times out, not sure if thats my fault because of changes in some original classes. At the moment even Bot.CurrentTrade.SetReady(true); will cause my bot to time out, without any errors...

luckydonald commented 11 years ago

What the heck did I do there? Rewrote that function and gave it a fancy new name. Now it doesn't time out any longer. Also

private void AddItemsByAll(uint amount) //fancy huh?
{
    Trade.SendMessage ("Adding all items with ALL"); //everybody needs a bit ALL sometimes...
    var items = Trade.CurrentSchema.Items;

    uint added = 0;

    foreach (var item in items)
    {
        added += Trade.AddAllItemsByDefindex(item.Defindex, amount); //hey, this is working!
        if (amount > 0 && added >= amount)
            return;
    }
    Trade.SendMessage ("Done."); //This makes the User happy.

} //silly comments are silly...
luckydonald commented 11 years ago

@dspaan Any Progress?

luckydonald commented 11 years ago

Phew! @FunkyLoveCow I guess so. I can't find any time for this at the moment (and the last month too). So i lost track of this. Can't even figure out the issue ...

dspaan commented 11 years ago

I have released my autotrading Autohotkey script. You can find it here: http://www.pulpfortress.com/?page_id=191&did=13

And instructions can be found here: http://forum.pulpfortress.com/viewtopic.php?f=84&t=4022

waylaidwanderer commented 11 years ago

Is this issue resolved?

dspaan commented 11 years ago

I don't think anyone has a good way to trade between your alts with bots but the autohotkey script i made works fine. Closing this now.