Skip to content

Commit

Permalink
Merge pull request 8go#131 from jonathandmoore/emojize
Browse files Browse the repository at this point in the history
Add emojize message option
  • Loading branch information
8go authored Apr 12, 2023
2 parents 923db4d + d71b70b commit 22d244a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions matrix_commander/matrix_commander.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import ast
import asyncio
import datetime
import emoji
import errno
import getpass
import json
Expand Down Expand Up @@ -2912,6 +2913,11 @@ async def send_message(client, rooms, message): # noqa: C901
formatted_message = message # the same for the time being
content["format"] = "org.matrix.custom.html" # add to dict
content["formatted_body"] = formatted_message
elif gs.pa.emojize:
gs.log.debug('Sending message in format "emojized".')
formatted_message = emoji.emojize(message) # convert emoji shortcodes if present
content["format"] = "org.matrix.custom.html" # add to dict
content["formatted_body"] = formatted_message
else:
gs.log.debug('Sending message in format "text".')
content["body"] = message
Expand Down Expand Up @@ -7391,6 +7397,19 @@ def main_inner(
"like tables as a fixed-sized font will be used "
"for display.",
)
# -j for emoJize
ap.add_argument(
"-j",
"--emojize",
required=False,
action="store_true",
help='Send message after emojizing. '
"Details:: If not specified, message will be sent "
'as format "TEXT". If both --code and --emojize are '
"specified then --code takes priority. This is "
"useful for sending emojis in shortcode form :collision:.",
)

# -s is already used for --store, -i for sPlit
ap.add_argument(
"-p",
Expand Down Expand Up @@ -8531,6 +8550,8 @@ def main_inner(
Send message as format "MARKDOWN".
<-k>, <--code>
Send message as format "CODE".
<-j>, <--emojize>
Emojize message (Convert shortcodes to Unicode).
<-p> SEPARATOR, <--split> SEPARATOR
Split message text into multiple Matrix messages.
<--config> CONFIG_FILE
Expand Down

0 comments on commit 22d244a

Please sign in to comment.