Commit d4a16bd2 authored by Philipp Hörist's avatar Philipp Hörist
Browse files

[acronyms] Dont expand if acronym euqals nick

Fixes #68
parent 7119f70b
......@@ -22,6 +22,7 @@ from functools import partial
from gi.repository import GLib
from gajim.common import app
from gajim.common import configpaths
from gajim.plugins import GajimPlugin
......@@ -82,7 +83,7 @@ class AcronymsExpanderPlugin(GajimPlugin):
self.acronyms = acronyms
def _on_buffer_changed(self, _textview, buffer_):
def _on_buffer_changed(self, _textview, buffer_, contact, account):
if self._replace_in_progress:
......@@ -108,6 +109,17 @@ class AcronymsExpanderPlugin(GajimPlugin):
# Get last word and cut invoker
last_word = word_start_iter.get_slice(insert_iter).strip()
if contact.is_groupchat():
nick_list = app.contacts.get_nick_list(account, contact.jid)
if last_word in nick_list:'Groupchat participant has same nick as acronym')
if contact.is_pm_contact:
if last_word == contact.get_shown_name():'Contact name equals acronym')
substitute = self.acronyms.get(last_word)
if substitute is None:
log.debug('%s not an acronym', last_word)
......@@ -130,7 +142,10 @@ class AcronymsExpanderPlugin(GajimPlugin):
def _connect(self, chat_control):
textview = chat_control.msg_textview
handler_id = textview.connect('text-changed', self._on_buffer_changed)
handler_id = textview.connect('text-changed',
self._handler_ids[id(textview)] = handler_id
def _disconnect(self, chat_control):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment