简体   繁体   中英

Node.js Steam Chat Bot

I want to make a Steam Bot using Node, and I have succesfully set it up and works swell.

Thing is, if I want to log commands, only one (so far) works, that's the /test command.

My code for checking the message(s) aka commands:

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);
}});

So, if I send the /test command to the bot using another account, it works, displaying "It works!", but if I send any other message, it doesn't display "Use /help". It shuts down the application, followed by these errors:

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)

Thanks.

You have a typo: EChatEntryType in the first sendMessage , EchatEntryType in the second. Notice the lowercase c . Which one is it?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM