Jessecar96 / SteamBot

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

Adding friends from txt file. #269

Closed Soni96pl closed 11 years ago

Soni96pl commented 11 years ago

This has been solved. Scroll to the bottom for answer.

oojava commented 11 years ago

You would have to start by adding:

private const string AddPlayerCmd = "addplayer";

and then edit:

private void ProcessTradeMessage(string message) { if (message.Equals(HelpCmd)) { PrintHelpMessage(); return; }

        if (message.StartsWith(AddCmd))
            HandleAddCommand(message);
        else if (message.StartsWith(RemoveCmd))
            HandleRemoveCommand(message);
    }

to something that includes:

if (message.StartsWith(AddPlayerCmd)) HandleAddPlayerCommand(message);

Then you would have to make HandleAddPlayerCommand(message) and have it parse message (like the add command does) to find a steam id.

Then have the function add the player and your good to go.

To run this command you would simply type addplayer steamid into trade chat.

It doesn't seem to keep my formatting oops so it may be a hard read. sorry put this together in a few minutes.

On Mon, May 6, 2013 at 1:17 PM, Susanne Fischer notifications@github.comwrote:

Hi, I want to add adding friend to botmgr through command from shell. Is it even possible to do that? I tried to do that on my own, but I failed at using Bot.SteamFriends there.

Can somebody help or at least point me in that direction? Thanks.

— Reply to this email directly or view it on GitHubhttps://github.com/Jessecar96/SteamBot/issues/269 .

Soni96pl commented 11 years ago

I'm talking about adding friend by typing command to the console :) But thanks for your answer :+1:

oojava commented 11 years ago

I think that this could be easy using a message or a group chat with your bots. sorry I can't be of help sending commands through the cmd line I haven't looked into this at all (looking now). Right now looking at private static void BotManagerMode() line 87 of program.cs this looks like its headed in the right direction.

oojava commented 11 years ago

You might find success updating an sql database with the source mod plugin (this allowed for a que and may be better long run). Having the bots check when they are not busy. (separate thread loop I would imagine) this would also do wonders to the expandability of your code.

Soni96pl commented 11 years ago

It looks okayish, but I think that loop like that can affect performance, but maybe I'm just exaggerating.

gamemaster1494 commented 11 years ago

All depends on how many friends you want to add and how. Adding them directly via SteamId64? From a list?

Soni96pl commented 11 years ago

It won't be more than few a day. I sorted out how I will do that. I made sourcemod plugin which appends SteamID64 to the steamid.txt after player typye !donate or /donate on chat. Now I will make infinite loop in a seperate thread which will check last line from that file every second and invite friend if this line isn't empty. After inviting friend it will delete last line from the file.

Soni96pl commented 11 years ago

This is how I did that: Added this in bot.cs after logging bot:

log.Success ("Steam Bot Logged In Completely!");
IsLoggedIn = true;
Thread infiniteThread = new Thread(DoLoop);
infiniteThread.Start();

And this near the end of bot.cs

public void DoLoop()
        {
            System.Console.WriteLine("InfiniteLoop started");
            while (0 < 1)
            {
                    log.Debug("File Exists.");
                    foreach (string line in File.ReadLines(@"/srcds/apps/TDM/tf/addons/sourcemod/steamid.txt"))
                    {
                        log.Info("Added friend: " + line);
                        SteamID friendtoadd = new SteamID(Convert.ToUInt64(line));
                        SteamFriends.AddFriend(friendtoadd);
                    }
                    File.Delete(@"/srcds/apps/TDM/tf/addons/sourcemod/steamid.txt");
                }
                Thread.Sleep(1000);
            }
        }