daniel-sc / rocketchat-modern-client

Client SDK for https://rocket.chat employing reactive style.
MIT License
11 stars 11 forks source link

Missing bot user id #17

Closed pjagielski closed 3 years ago

pjagielski commented 3 years ago

Hi, I don't know if the library is still maintained, but wanted to use it in my simple bot. Really great design and API! One issue I think blocks me for now is missing bot user id in API.

Official Rocket JS SDK filters own bot messages send to a channel:

const processMessages = async(err, message, messageOptions) => {
  if (!err) {
    // filter our own message
    if (message.u._id === myuserid) return;
    // can filter further based on message.rid
    const roomname = await driver.getRoomName(message.rid);
    if (message.msg.toLowerCase().startsWith(BOTNAME)) {
      const response = message.u.username + 
            ', how can ' + BOTNAME + ' help you with ' +
            message.msg.substr(BOTNAME.length + 1);
      const sentmsg = await driver.sendToRoom(response, roomname);
    }
  }
}

Correct me if I'm wrong but I can't figure myuserid using current API?

daniel-sc commented 3 years ago

This is maintained on a best effort basis. I'll try to have a look tomorrow. PRs are very welcome 😊