Smarter parsing of emoticons (closes #954) and added a few common emoticons as well.

This commit is contained in:
Travis Shirk 2005-11-13 20:47:15 +00:00
parent dc27356721
commit b816a7a46b
2 changed files with 10 additions and 4 deletions

View File

@ -5,6 +5,7 @@
## - Vincent Hanquez <tab@snarc.org>
## - Nikos Kouremenos <nkour@jabber.org>
## - Dimitur Kirov <dkirov@gmail.com>
## - Travis Shirk <travis@pobox.com>
##
## Copyright (C) 2003-2005 Gajim Team
##
@ -280,12 +281,17 @@ class Config:
'(N)': '../data/emoticons/no.png',
'(P)': '../data/emoticons/photo.png',
'(K)': '../data/emoticons/kiss.png',
':-*': '../data/emoticons/kiss.png',
':*': '../data/emoticons/kiss.png',
'(R)': '../data/emoticons/rainbow.png',
':-|': '../data/emoticons/stare.png',
';-)': '../data/emoticons/wink.png',
';-(': '../data/emoticons/cry.png',
'(6)': '../data/emoticons/devil.png',
'>:)': '../data/emoticons/devil.png',
'>:-)': '../data/emoticons/devil.png',
'(L)': '../data/emoticons/heart.png',
'<3': '../data/emoticons/heart.png',
'(W)': '../data/emoticons/brflower.png',
':|': '../data/emoticons/stare.png',
':O': '../data/emoticons/oh.png',

View File

@ -1062,17 +1062,17 @@ class Interface:
basic_pattern = links + mail + formatting
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
keys = self.emoticons.keys()
keys.sort(self.on_emoticon_sort)
for emoticon in keys: # travel thru emoticons list
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
self.emot_and_basic_re = sre.compile(emot_and_basic_pattern,
sre.IGNORECASE)
self.emot_and_basic_re = sre.compile(emot_and_basic_pattern, sre.IGNORECASE)
# at least one character in 3 parts (before @, after @, after .)
self.sth_at_sth_dot_sth_re = sre.compile(r'\S+@\S+\.\S*[^\s)?]')