Skip to content

Commit

Permalink
emojize.py 1.0.1: Fix to work with modern versions of emoji package
Browse files Browse the repository at this point in the history
  • Loading branch information
msva authored and flashcode committed Oct 6, 2023
1 parent 22c29b3 commit e331e7c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions python/emojize.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,20 @@
This plugin supports python 3 and requires the 'emoji' python package.
Requires at least weechat 1.3
Changelog:
1.0.1 - 2023-08-06: mva
Adaptation to modern version of `emoji` package
(use_aliases => language="alias")
"""


def register():
weechat.register(
"emojize",
"Thom Wiggers",
"1.0.0",
"1.0.1",
"CC0",
"Convert emoji shortcodes to unicode emoji",
"", # shutdown function
Expand Down Expand Up @@ -60,12 +66,12 @@ def convert_emoji(_data, modifier, _modifier_data, string):
if msg["text"] != "" and pos_text > 0:
return (
string[:pos_text]
+ emoji.emojize(msg["text"], use_aliases=True)
+ string[(pos_text + len(msg["text"])) :]
+ emoji.emojize(msg["text"], language="alias")
+ string[(pos_text + len(msg["text"])):]
)

if modifier == "input_text_for_buffer":
return emoji.emojize(string, use_aliases=True)
return emoji.emojize(string, language="alias")

return string

Expand Down

0 comments on commit e331e7c

Please sign in to comment.