Node.js Steam聊天机器人

Node.js Steam Chat Bot

本文关键字:机器人 聊天 Steam js Node      更新时间:2023-09-26

我想使用Node制作一个Steam Bot,我已经成功地设置了它,并且运行良好。

问题是,如果我想记录命令,只有一个(到目前为止)有效,那就是/test命令。

我检查消息的代码,也称为命令:

steamBot.on('message', function(source, message, type, chatter) {
console.log('Received message: ' + message);
if (message == '/test') {
    steamBot.sendMessage(source, 'It works!', Steam.EChatEntryType.ChatMsg);
} else {
    steamBot.sendMessage(source, 'Use /help.', Steam.EchatEntryType.ChatMsg);
}});

因此,如果我使用另一个帐户向机器人发送/test命令,它会工作,显示"它工作!",但如果我发送任何其他消息,它不会显示"使用/help"。它关闭了应用程序,然后出现以下错误:

TypeError: Cannot read property 'ChatMsg' of undefined
at SteamClient.<anonymous> (/home/juniper/Downloads/Please/please3.js:32:105)
at emitThree (events.js:97:13)
at SteamClient.emit (events.js:175:7)
at SteamClient.handlers.(anonymous function) (/home/juniper/node_modules/steam/lib/handlers/friends.js:250:8)
at SteamClient._netMsgReceived (/home/juniper/node_modules/steam/lib/steam_client.js:106:26)
at SteamClient.handlers.(anonymous function) (/home/juniper/node_modules/steam/lib/steam_client.js:192:10)
at SteamClient._netMsgReceived (/home/juniper/node_modules/steam/lib/steam_client.js:106:26)
at emitOne (events.js:77:13)
at Connection.emit (events.js:169:7)
at Connection._readPacket (/home/juniper/node_modules/steam/lib/connection.js:50:8)

谢谢。

您有一个拼写错误:第一个sendMessage中有EChatEntryType,第二个EchatEntryType。请注意小写c。是哪一个?