Smarter parsing of emoticons (closes #954) and added a few common emoticons as well.
This commit is contained in:
parent
dc27356721
commit
b816a7a46b
|
@ -5,6 +5,7 @@
|
||||||
## - Vincent Hanquez <tab@snarc.org>
|
## - Vincent Hanquez <tab@snarc.org>
|
||||||
## - Nikos Kouremenos <nkour@jabber.org>
|
## - Nikos Kouremenos <nkour@jabber.org>
|
||||||
## - Dimitur Kirov <dkirov@gmail.com>
|
## - Dimitur Kirov <dkirov@gmail.com>
|
||||||
|
## - Travis Shirk <travis@pobox.com>
|
||||||
##
|
##
|
||||||
## Copyright (C) 2003-2005 Gajim Team
|
## Copyright (C) 2003-2005 Gajim Team
|
||||||
##
|
##
|
||||||
|
@ -280,12 +281,17 @@ class Config:
|
||||||
'(N)': '../data/emoticons/no.png',
|
'(N)': '../data/emoticons/no.png',
|
||||||
'(P)': '../data/emoticons/photo.png',
|
'(P)': '../data/emoticons/photo.png',
|
||||||
'(K)': '../data/emoticons/kiss.png',
|
'(K)': '../data/emoticons/kiss.png',
|
||||||
|
':-*': '../data/emoticons/kiss.png',
|
||||||
|
':*': '../data/emoticons/kiss.png',
|
||||||
'(R)': '../data/emoticons/rainbow.png',
|
'(R)': '../data/emoticons/rainbow.png',
|
||||||
':-|': '../data/emoticons/stare.png',
|
':-|': '../data/emoticons/stare.png',
|
||||||
';-)': '../data/emoticons/wink.png',
|
';-)': '../data/emoticons/wink.png',
|
||||||
';-(': '../data/emoticons/cry.png',
|
';-(': '../data/emoticons/cry.png',
|
||||||
'(6)': '../data/emoticons/devil.png',
|
'(6)': '../data/emoticons/devil.png',
|
||||||
|
'>:)': '../data/emoticons/devil.png',
|
||||||
|
'>:-)': '../data/emoticons/devil.png',
|
||||||
'(L)': '../data/emoticons/heart.png',
|
'(L)': '../data/emoticons/heart.png',
|
||||||
|
'<3': '../data/emoticons/heart.png',
|
||||||
'(W)': '../data/emoticons/brflower.png',
|
'(W)': '../data/emoticons/brflower.png',
|
||||||
':|': '../data/emoticons/stare.png',
|
':|': '../data/emoticons/stare.png',
|
||||||
':O': '../data/emoticons/oh.png',
|
':O': '../data/emoticons/oh.png',
|
||||||
|
|
|
@ -1062,17 +1062,17 @@ class Interface:
|
||||||
basic_pattern = links + mail + formatting
|
basic_pattern = links + mail + formatting
|
||||||
self.basic_pattern_re = sre.compile(basic_pattern, sre.IGNORECASE)
|
self.basic_pattern_re = sre.compile(basic_pattern, sre.IGNORECASE)
|
||||||
|
|
||||||
emoticons_pattern = ''
|
emoticons_pattern = '(?<!\S)(?:'
|
||||||
# sort keys by length so :qwe emot is checked before :q
|
# sort keys by length so :qwe emot is checked before :q
|
||||||
keys = self.emoticons.keys()
|
keys = self.emoticons.keys()
|
||||||
keys.sort(self.on_emoticon_sort)
|
keys.sort(self.on_emoticon_sort)
|
||||||
for emoticon in keys: # travel thru emoticons list
|
for emoticon in keys: # travel thru emoticons list
|
||||||
emoticon_escaped = sre.escape(emoticon) # espace regexp metachars
|
emoticon_escaped = sre.escape(emoticon) # espace regexp metachars
|
||||||
emoticons_pattern += emoticon_escaped + '|'# | means or in regexp
|
emoticons_pattern += emoticon_escaped + '|' # | means or in regexp
|
||||||
|
emoticons_pattern += ')(?!\S)|'
|
||||||
|
|
||||||
emot_and_basic_pattern = emoticons_pattern + basic_pattern
|
emot_and_basic_pattern = emoticons_pattern + basic_pattern
|
||||||
self.emot_and_basic_re = sre.compile(emot_and_basic_pattern,
|
self.emot_and_basic_re = sre.compile(emot_and_basic_pattern, sre.IGNORECASE)
|
||||||
sre.IGNORECASE)
|
|
||||||
|
|
||||||
# at least one character in 3 parts (before @, after @, after .)
|
# at least one character in 3 parts (before @, after @, after .)
|
||||||
self.sth_at_sth_dot_sth_re = sre.compile(r'\S+@\S+\.\S*[^\s)?]')
|
self.sth_at_sth_dot_sth_re = sre.compile(r'\S+@\S+\.\S*[^\s)?]')
|
||||||
|
|
Loading…
Reference in New Issue