seishun / node-steam

Interface directly with Steam servers from Node.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for new Steam chat

kraxarn opened this issue · comments

Steam recently released a beta for a new chat. This requires users to use the new beta in order to join group chats, and bots (using this library) are now unable to join those group chats.

+1,

I guess SteamKit supports the new client now? SteamRE/SteamKit@aecb61a
Looks like a lot of work though

The new chat is entirely based on unified messages. That means it can be relatively easily implemented using the UnifiedMessages handler, and I believe any convenience wrappers around it belong in a separate module.

I've just tried this and it seems work:

const friendMessages = new Steam.SteamUnifiedMessages(steamClient, 'FriendMessages');
friendMessages.send('SendMessage', {
  steamid: friend_id,
  chat_entry_type: 1,
  message: 'hello'
}, (eresult, resp) => { console.log(eresult, resp); });

You can use NetHook2 coupled with NetHookAnalyzer2 (get both here) to find out the relevant service names and methods for things you want to do. For example, NetHookAnalyzer2 will say "FriendMessages.SendMessage#1" for the above example.

To receive notifications, you need to opt in by sending a message for which there is currently no method in node-steam (feel free to submit a separate issue if you would like it added):

steamClient.send({
  msg: Steam.EMsg.ClientCurrentUIMode,
  proto: {}
}, new Steam.Internal.CMsgClientCurrentUIMode({ chat_mode: 2 }).toBuffer());

const friendMessagesClient = new Steam.SteamUnifiedMessages(steamClient, 'FriendMessagesClient');
friendMessagesClient.on('message', (methodName, body) => {
  if (methodName == 'IncomingMessage')
    console.log(body);
});

I haven't tried it with chat rooms, but it should be similar. Feel free to ask if anything is unclear or doesn't seem to work (but I can't help you with Steam's chat room or friend API itself).