1

我一直在为我的 CS:GO 赌博网站开发 NodeJS Steam 机器人,我只有一个问题。我希望机器人只接受 CS:GO 项目/皮肤(CS:GO appID 是730)。我知道这与appID有关。

我正在使用node-steam-tradeoffer-manager进行交易报价。

我当前接受交易的代码:

manager.on('newOffer', (offer) => {
 var userID = offer.partner.getSteamID64();
 var offerID = offer.id;

 var prefix = time + " || " + 'Trade: #' + offerID + ' || ';

 console.log(prefix + "from " + userID);

 offer.getUserDetails((err, me, them) => {
  if (err) {
   console.log(err);
   return;
  }

  if (them.escrowDays > 0) {
   console.log(prefix + 'User has escrow! Declining!');

   offer.decline((err) => {
    if (err) {
     console.log(prefix + 'Error declining offer!');
     return;
    }
   });
  } else {
   if (offer.itemsToGive.length == 0) {
    var userAmount = priceItemsInOffer(offer.itemsToReceive) * 1000;

        if(userAmount < config['minDeposit']){
            console.log(prefix + "User deposit skin that costs less than 100 Credits!");

      offer.decline((err) => {
       if (err) {
        console.log(prefix + 'Error declining offer!');
        return;
       }
      });

        }
        else{
    console.log(prefix + 'User deposited ' + userAmount);

    var insertDeposit0  = {
                  user: userID,
                  amount: userAmount,
                  offerID: offerID,
                  status: 0,
                  time: time
                };
    var query = connection.query('INSERT INTO deposits SET ?', insertDeposit0, function(err, result) {
      // Neat!
    });

    offer.accept((err, status) => {
     if (err) {
      console.log(prefix + 'Error accepting offer!' + err.message);

      connection.query('UPDATE deposits SET ? WHERE ?', [{ status: 1 }, { offerID: offerID }]) // 1 ERROR ACCEPTING

      return;
     } else {
      community.checkConfirmations();

      console.log(prefix + "Accepted!");

          connection.query('UPDATE deposits SET ? WHERE ?', [{ status: 2 }, { offerID: offerID }]) // 2 ACCEPTED
     }
    });
    }
   } else if (offer.itemsToGive.length > 0) {
    console.log(prefix + "User asked skins from us! Declining offer.");

    offer.decline((err) => {
     if (err) {
      log(prefix + 'Error declining offer!');
      return;
     }
    });
   }
  }
 });
});
4

1 回答 1

1

由于您使用的是 node-steam-tradeoffer-manager,因此您通常与以下内容进行交互CEconItem

https://github.com/DoctorMcKay/node-steam-tradeoffer-manager/wiki/EconItem https://github.com/DoctorMcKay/node-steamcommunity/wiki/CEconItem

每个CEconItem包含appid属性:

https://github.com/DoctorMcKay/node-steamcommunity/wiki/CEconItem#appid

所以让我们把它放在一起:

  • offer.itemsToGive- 是一个数组CEconItem(你的)
  • offer.itemsToReceive- 相同(但他们的)

要检查所有项目是否来自 CS:GO,您只需执行以下操作:

const allItemsAreFromCSGO = offer.itemsToReceive.every(item => item.appid === 730);
于 2017-01-31T12:29:23.217 回答