Nodejs steam tradebot

1.8k views Asked by At

I have nodejs steambot built with steam user, steam trade, steamcommunity and steam-tradeoffer-manager etc...

var username = "bot";
var password = "123456";
var steamguard = "";

var Steam = require('steam');

var SteamUser = require("steam-user");
var user = new SteamUser();

var SteamTrade = require("steam-trade");
var steamTrade = new SteamTrade();

user.logOn({
    accountName: username,
    password: password,
})


user.on("loggedOn", function(){
    console.log(username + " is succesfully logged in");
    user.setPersona(1);
})

user.on("webSession", function(sessionID, cookies){
    console.log("Web session created with id " + sessionID);
    steamTrade.setCookie(cookies);

});

I know how to manage trade offers but what I need to know is how do I interact between my website and my bot.

How do I send command from my website to my bot to make a tradeoffer?

Example:
website.php

$("button").click(function{
    //MAKE TRADE
})
2

There are 2 answers

5
David Espino On

Just check that you have a button in your php as the following:

<button id="btnTrade" value="Trade" /> <!--Html Markup-->

Include jquery (either download or use a cdn repository)

<script
  src="https://code.jquery.com/jquery-2.2.4.min.js"
  integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
  crossorigin="anonymous"></script>

And then implement document ready at the end of your page

<script>
$(document).ready(function () {
  $("#btnTrade").on("click", function buttonClick(){
    //MAKE TRADE
  });
});
</script>
0
rator On

Edit Just realized a might be a few years late.

You'd need a webserver connected to your bot. I suggest using Express as it is easy to get started with and has plenty of documentation.

When you want to interact somehow with your bot, your PHP code should include an HTTP request to your webserver, which then triggers an action in the bot.

I do not know PHP, but I can give you an overview of what would be happening.

Client
Webpage features a button or similar. When pressed it sends a request to your webserver i.e. localhost:3000/trade/. Now the rest is up to the server

Node.js Server
This server can be in the same file as your main file (bot).

const express = require('express');
express.get('/trade', (req, res) => {
    // make trade
}

Hope this helps.