【问题标题】:Get a Steam key from a txt file then move it to another从 txt 文件中获取 Steam 密钥,然后将其移动到另一个
【发布时间】:2018-11-28 15:38:53
【问题描述】:

我目前正在开发一个 Steam 机器人项目,该项目用 Steam 物品交换游戏密钥。我已经完成了所有交易部分,现在唯一缺少的部分是脚本实际在我的 txt 文件中查找密钥的部分。 (每行一个键)

我有一个名为 totalKeyWeGive 的变量,根据用户购买的钥匙数量输出 1 、 2 、 3 等。

所以现在我想 1. 从我的文件中获取 1 、 2 、 3 等键,然后将这些使用过的键移动到另一个文件。 我该怎么做?

这是我需要修改的部分(一切正常):

offer.accept(offer);
console.log("OFFER ACCEPTED");

//loop on how much we give the key

    //get steamkey from file here ------

}

var textMsg = "Hello ! You bought "+totalKeyWeGive+ " Game keys. Your keys are: "
}

client.chatMessage(offer.partner.getSteamID64(), textMsg);

感谢所有愿意花时间阅读这篇文章的人。有点乱,抱歉:/

【问题讨论】:

    标签: node.js steam


    【解决方案1】:

    不确定 txt 文件中的密钥是如何组织的,但假设它们每行一个,您可以执行以下操作:https://stackoverflow.com/a/38843461/4686055

    即在删除该行之前,将其保存在内存中并写入目标文件。

    向 slice() 发送一个间隔以删除多行。查看它的工作原理示例:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice

    希望这会有所帮助!

    更新:另一种方法是使用 readlines 模块而不是将整个文件读入内存:https://nodejs.org/api/readline.html#readline_example_read_file_stream_line_by_line

    【讨论】:

      猜你喜欢
      • 2022-01-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-18
      相关资源
      最近更新 更多