1

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
})
Tonza
  • 650
  • 8
  • 17

2 Answers2

1

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>
David Espino
  • 2,177
  • 14
  • 21
  • 2
    I am thinking the question is about the `//MAKE TRADE` part and not the surrounding code. – Gabriele Petrioli Dec 17 '16 at 01:15
  • 1
    oh... from this : 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? I understood that the question was about how to attach a behavior to an object that could fire his events... if that is not the case, then @GabyakaG.Petrioli, you're right, the answer will not be related to the problem :(... I'll just wait for Tonza comments – David Espino Dec 17 '16 at 01:19
  • 1
    I am guessing here, but i the "interact with bot" part i read as how to submit to the backend (the node app) something that the backend would understand as a command to make the trade. I believe it is a "too broad" question as it is. – Gabriele Petrioli Dec 17 '16 at 01:34
  • Thank you for yoy answer. I'll try that – Tonza Dec 17 '16 at 10:41
  • my `bot.js` and my `website.php` are different files. They aren't connected together at all. I tried add `` to my `website.php` but it didn't work – Tonza Dec 17 '16 at 11:47
0

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.

troffaholic
  • 185
  • 1
  • 10