From 5f7fd7a957e4f840378c955bf86a8e67f36f8794 Mon Sep 17 00:00:00 2001 From: David A Roberts Date: Sun, 12 Feb 2017 05:44:42 +0000 Subject: [PATCH] only send read receipts if bot is mentioned, or is unable to respond --- src/matrix.coffee | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/matrix.coffee b/src/matrix.coffee index fb22ef0..c1c2f82 100644 --- a/src/matrix.coffee +++ b/src/matrix.coffee @@ -81,15 +81,15 @@ class Matrix extends Adapter @robot.logger.info "Synced #{@client.getRooms().length} rooms" @emit 'connected' @client.on 'Room.timeline', (event, room, toStartOfTimeline) => - @client.sendReadReceipt(event) - if event.getType() == 'm.room.message' and event.getContent().msgtype != "m.notice" and toStartOfTimeline == false - message = event.getContent().body + if event.getType() == 'm.room.message' and toStartOfTimeline == false + message = event.getContent() name = event.getSender() user = @robot.brain.userForId name user.room = room.roomId if user.name != @user_id - @robot.logger.info "Received message: '#{message}' in room: #{user.room}, from: #{user.name}." - @receive new TextMessage user, message + @robot.logger.info "Received message: #{JSON.stringify message} in room: #{user.room}, from: #{user.name}." + @receive new TextMessage user, message.body if message.msgtype == "m.text" + @client.sendReadReceipt(event) if message.msgtype != "m.text" or message.body.indexOf(@robot.name) != -1 @client.on 'RoomMember.membership', (event, member) => if member.membership == 'invite' and member.userId == @user_id @client.joinRoom(member.roomId).done =>