0

I'm currently looking to build a bot for my Twitch Channel, I have the bot with some standard commands for changing the game based on shorter commands.

I read and looked into it and apparently using the SteamAPI it's possible to figure out what game you're account is currently playing using:

http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=STEAM_API_KEY&steamids=STEAM_ID/

When I navigate to the above URL I get the following information:

{
    "response": {
        "players": [
            {
                "steamid": "76561198071832682",
                "communityvisibilitystate": 3,
                "profilestate": 1,
                "personaname": "LocKe",
                "lastlogoff": 1494465131,
                "commentpermission": 1,
                "profileurl": "http://steamcommunity.com/id/Locke33/",
                "avatar": "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/f5/f5939ea84ede9a4a92c81581d86356c11f85cc09.jpg",
                "avatarmedium": "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/f5/f5939ea84ede9a4a92c81581d86356c11f85cc09_medium.jpg",
                "avatarfull": "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/f5/f5939ea84ede9a4a92c81581d86356c11f85cc09_full.jpg",
                "personastate": 1,
                "realname": "Conor",
                "primaryclanid": "103582791454321553",
                "timecreated": 1347915898,
                "personastateflags": 0,
                "gameextrainfo": "Counter-Strike: Global Offensive",
                "gameid": "730",
                "loccountrycode": "IE"
            }
        ]

    }
}

I can see "gameid": "730" which is Counter-Strike because I currently have it open, my only query I need is to return something like.

If gameID = 730 then which will then call my TwitchBot to change what game im playing, that way when I change from say CSGO to H1Z1 my bot will notice the change and automatically change my current game accordingly.

I'm currently using NodeJS and Notepad++ for this if that's any help.

Any help appreciated!

CMagee33
  • 23
  • 7

1 Answers1

1

I found by installing

npm install --save machinepack-steam

var Steam = require('machinepack-steam');
var mySteamID = "INSERT STEAM ID HERE";
var STEAM_API_KEY = "INSERT API KEY HERE";
var s2;
var lastgame;
var current;

Steam.getPlayerSummaries({
    steamids: [mySteamID],
    key: STEAM_API_KEY,
}).exec({
    error: function(err) {

    },

    success: function(result) {
        var s = result;
        var s1 = s.players[0];

        s2 = s1.gameid;
        console.log(s2);
    }
});

This assigned s2 the value of the game ID I was after. I just thought I'd answer my own question as I figured it out late last night and it may or may not help other people.

CMagee33
  • 23
  • 7