From ff4b5198d808e08a3650b671c5b2a03b3c60356d Mon Sep 17 00:00:00 2001 From: James Booth Date: Sun, 6 Nov 2016 23:12:48 +0000 Subject: [PATCH] sounds.py: don't play sounds on messages from self --- sounds.py | 7 +++++++ tests/python-test.py | 4 ++++ tests/test-c-plugin/test-c-plugin.c | 9 +++++++++ 3 files changed, 20 insertions(+) diff --git a/sounds.py b/sounds.py index d5c22ce..d24cb83 100644 --- a/sounds.py +++ b/sounds.py @@ -175,6 +175,13 @@ def prof_post_chat_message_display(barejid, resource, message): def prof_post_room_message_display(barejid, nick, message): + my_nick = prof.get_room_nick(barejid) + if not my_nick: + return + + if my_nick == nick: + return; + enabled = prof.settings_boolean_get("sounds", "enabled", False) if not enabled: return diff --git a/tests/python-test.py b/tests/python-test.py index 72e03ef..29c16ad 100644 --- a/tests/python-test.py +++ b/tests/python-test.py @@ -128,6 +128,10 @@ def _get(subject): if room: prof.win_focus(plugin_win) prof.win_show(plugin_win, "called -> prof_get_current_muc: " + room) + nick = prof.get_room_nick(room) + if nick: + prof.win_focus(plugin_win) + prof.win_show(plugin_win, "called -> prof_get_room_nick('" + room + "'): " + nick) else: prof.win_focus(plugin_win) prof.win_show(plugin_win, "called -> prof_get_current_muc: ") diff --git a/tests/test-c-plugin/test-c-plugin.c b/tests/test-c-plugin/test-c-plugin.c index 5d4116b..23fb6ad 100644 --- a/tests/test-c-plugin/test-c-plugin.c +++ b/tests/test-c-plugin/test-c-plugin.c @@ -185,6 +185,15 @@ getsubject(char *subject) char buf[strlen(str) + strlen(room)]; sprintf(buf, "%s%s", str, room); prof_win_show(plugin_win, buf); + char *nick = prof_get_room_nick(room); + if (nick) { + prof_win_focus(plugin_win); + char *str1 = "called -> prof_get_room_nick('"; + char *str2 = "'): "; + char buf1[strlen(str1) + strlen(room) + strlen(str2) + strlen(nick)]; + sprintf(buf1, "%s%s%s%s", str1, room, str2, nick); + prof_win_show(plugin_win, buf1); + } } else { prof_win_focus(plugin_win); prof_win_show(plugin_win, "called -> prof_get_current_muc: ");