s3rvac / weechat-notify-send

A WeeChat script that sends highlight and message notifications through notify-send.
MIT License
176 stars 19 forks source link

Notifications for Matrix chats #3

Closed tobanw closed 8 years ago

tobanw commented 8 years ago

This plugin works great for IRC, nice work! I'm using the Matrix plugin (Matrix is a different chat protocol than IRC), but my Matrix chats don't generate notifications. This could be because Matrix uses chat rooms, so there's no notion of private messages.

Any ideas on how to get notifications from Matrix chat rooms?

s3rvac commented 8 years ago

Hi Toban,

I don't use the Matrix protocol myself, but let me show you what I have found. My plugin relies on WeeChat to correctly recognize private messages or highlights. Based on your description of the protocol, there seems to be no concept of private messages in Matrix (more on that later). This leaves us with highlights. On the weechat-matrix-protocol-script repo, there seems to be an opened issue to improve the plugin by adding support for highlighting in WeeChat. Such added support could enable my plugin to send notifications on highlights. However, I may be wrong (I don't know the Matrix protocol).

As a side note, there is the BitlBee project, which provides an IM-to-IRC gateway. It supports many different chat protocols. For example, I use it as a Jabber/XMPP-to-IRC gateway so I can use WeeChat for both IRC and Jabber/XMPP messaging. Since it is an IM-to-IRC gateway, my plugin is able to show Jabber/XMPP notifications, just like IRC notifications. However, BitlBee does not support the Matrix protocol. There is an opened issue for that, though.

Now, lets talk about "private-message notifications" for Matrix. You said that there are only chat rooms, which I think may be considered as channels on IRC. About which messages you would like to be notified? About all messages that happen in a chat room? There may be a lot of them. Only for some of them? Which ones?

tobanw commented 8 years ago

In Matrix, everything is a chatroom -- public rooms are equivalent to IRC channels, while private rooms are used for one-to-one or group chats. Ideally, it would be nice if this plugin could set notifications per-buffer, which would be agnostic about which protocol is being used. This way, I could just pick which Matrix chats should trigger notifications.

It might be easier to implement highlights, as the Matrix plugin already highlights messages that mention my name (i.e., it colors the sender name and shows the count of highlighted messages in the status bar) -- I'm not sure what that issue you referenced is about. However, the Matrix highlights don't trigger notifications as IRC highlights do -- any idea why that is?

I'm not interested in using an IRC gateway, as the Matrix protocol supports end-to-end encryption and I ultimately want to be using it.

s3rvac commented 8 years ago

I'm not interested in using an IRC gateway, as the Matrix protocol supports end-to-end encryption and I ultimately want to be using it.

Fair enough.

However, the Matrix highlights don't trigger notifications as IRC highlights do -- any idea why that is?

I will have to take a look into that.

Ideally, it would be nice if this plugin could set notifications per-buffer, which would be agnostic about which protocol is being used.

OK, that sounds reasonable. I will add support for this, probably during the next weekend.

s3rvac commented 8 years ago

However, the Matrix highlights don't trigger notifications as IRC highlights do -- any idea why that is?

In commit 38507a28eb, I have added interception of all messages by the plugin, not only those tagged with irc_privmsg. I believe this was the reason why Matrix highlights did not trigger notifications.

Ideally, it would be nice if this plugin could set notifications per-buffer, which would be agnostic about which protocol is being used.

In commit 7532c7fb8c, I have added a new option to the plugin: notify_on_all_messages_in_buffers. It is a comma-separated list of buffers for which you want to receive notifications on all messages that appear in them. You can use either short names (#buffer) or full names (network.#buffer). This list is empty by default.

Would you be so kind as to check whether the plugin in its current form in the master branch works for you?

tobanw commented 8 years ago

Thanks, it's working now!! In Matrix rooms, I now get notifications for each message in a one-on-one room and not for group chat rooms (and I can get those by enabling per-buffer notifications). Highlights trigger notifications in all rooms.

However, my Matrix messages trigger notifications too (whenever notifications are enabled). I guess the function i_am_author_of_message() isn't catching the Matrix nick. I'd be happy to help out with testing.

s3rvac commented 8 years ago

In commit 0ce4ff93e4, I have improved the removal of modes from the beginning of nicks. Originally, only @ (op on IRC) and + (voice on IRC) were removed. Now, any character from the following list is removed: ~&@%+-. This should hopefully fix the detection in i_am_author_of_message(). I found out that Matrix uses the modes to reflect power level.

Could you please verify whether this indeed fixes the problem for you?

tobanw commented 8 years ago

Now I'm really confused: in one buffer (a one-on-one chat room) my messages don't trigger notifications, but in all the others (including both one-on-one and group chat rooms), they do. I even rebooted to be sure. I can't figure out what's special about that one buffer...

s3rvac commented 8 years ago

In commits b4b20594e and a778e56e0, I have tried to improve detection of nicks and authorship of messages. Could I ask you to check whether you still get notifications for your messages? If the problem persists, I will keep digging :).

tobanw commented 8 years ago

Excellent! It's working perfectly now. Thanks so much for solving this issue!!