Node.js Steam Chat Bot

时间:2016-05-07 16:40:02

标签: javascript node.js

我想使用Node创建一个Steam Bot,并且我已成功设置它并且工作正常。

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

我检查消息的代码a.k.a命令:

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命令发送到机器人,它会工作,显示“它工作!”,但如果我发送任何其他消息,它不会显示“使用/帮助”。它关闭了应用程序,然后是这些错误:

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)

感谢。

1 个答案:

答案 0 :(得分:2)

您在第一个EChatEntryType中有sendMessage,第二个是EchatEntryType。请注意小写c。它是哪一个?