Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gajim-plugins
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
56
Issues
56
List
Boards
Labels
Service Desk
Milestones
Merge Requests
8
Merge Requests
8
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gajim
gajim-plugins
Commits
d4a16bd2
Commit
d4a16bd2
authored
Dec 09, 2018
by
Philipp Hörist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[acronyms] Dont expand if acronym euqals nick
Fixes
#68
parent
7119f70b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
2 deletions
+17
-2
acronyms_expander/acronyms_expander.py
acronyms_expander/acronyms_expander.py
+17
-2
No files found.
acronyms_expander/acronyms_expander.py
View file @
d4a16bd2
...
...
@@ -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
self
.
_save_acronyms
(
acronyms
)
def
_on_buffer_changed
(
self
,
_textview
,
buffer_
):
def
_on_buffer_changed
(
self
,
_textview
,
buffer_
,
contact
,
account
):
if
self
.
_replace_in_progress
:
return
...
...
@@ -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
:
log
.
info
(
'Groupchat participant has same nick as acronym'
)
return
if
contact
.
is_pm_contact
:
if
last_word
==
contact
.
get_shown_name
():
log
.
info
(
'Contact name equals acronym'
)
return
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
.
_on_buffer_changed
,
chat_control
.
contact
,
chat_control
.
account
)
self
.
_handler_ids
[
id
(
textview
)]
=
handler_id
def
_disconnect
(
self
,
chat_control
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment