Skip to content

Commit

Permalink
Apprise Emoji Support Added (#1011)
Browse files Browse the repository at this point in the history
  • Loading branch information
caronc authored Dec 16, 2023
1 parent eb4e47c commit 76831f9
Show file tree
Hide file tree
Showing 10 changed files with 2,649 additions and 5 deletions.
18 changes: 17 additions & 1 deletion apprise/Apprise.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from .utils import parse_list
from .utils import parse_urls
from .utils import cwe312_url
from .emojis import apply_emojis
from .logger import logger
from .AppriseAsset import AppriseAsset
from .AppriseConfig import AppriseConfig
Expand Down Expand Up @@ -376,7 +377,7 @@ def notify(self, body, title='', notify_type=common.NotifyType.INFO,
body, title,
notify_type=notify_type, body_format=body_format,
tag=tag, match_always=match_always, attach=attach,
interpret_escapes=interpret_escapes
interpret_escapes=interpret_escapes,
)

except TypeError:
Expand Down Expand Up @@ -501,6 +502,11 @@ def _create_notify_gen(self, body, title='',
key = server.notify_format if server.title_maxlen > 0\
else f'_{server.notify_format}'

if server.interpret_emojis:
# alter our key slightly to handle emojis since their value is
# pulled out of the notification
key += "-emojis"

if key not in conversion_title_map:

# Prepare our title
Expand Down Expand Up @@ -542,6 +548,16 @@ def _create_notify_gen(self, body, title='',
logger.error(msg)
raise TypeError(msg)

if server.interpret_emojis:
#
# Convert our :emoji: definitions
#

conversion_body_map[key] = \
apply_emojis(conversion_body_map[key])
conversion_title_map[key] = \
apply_emojis(conversion_title_map[key])

kwargs = dict(
body=conversion_body_map[key],
title=conversion_title_map[key],
Expand Down
6 changes: 6 additions & 0 deletions apprise/AppriseAsset.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ class AppriseAsset:
# notifications are sent sequentially (one after another)
async_mode = True

# Support :smile:, and other alike keywords swapping them for their
# unicode value. A value of None leaves the interpretation up to the
# end user to control (allowing them to specify emojis=yes on the
# URL)
interpret_emojis = None

# Whether or not to interpret escapes found within the input text prior
# to passing it upstream. Such as converting \t to an actual tab and \n
# to a new line.
Expand Down
8 changes: 7 additions & 1 deletion apprise/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,17 @@ def print_version_msg():
'increase the verbosity. I.e.: -vvvv')
@click.option('--interpret-escapes', '-e', is_flag=True,
help='Enable interpretation of backslash escapes')
@click.option('--interpret-emojis', '-j', is_flag=True,
help='Enable interpretation of :emoji: definitions')
@click.option('--debug', '-D', is_flag=True, help='Debug mode')
@click.option('--version', '-V', is_flag=True,
help='Display the apprise version and exit.')
@click.argument('urls', nargs=-1,
metavar='SERVER_URL [SERVER_URL2 [SERVER_URL3]]',)
def main(body, title, config, attach, urls, notification_type, theme, tag,
input_format, dry_run, recursion_depth, verbose, disable_async,
details, interpret_escapes, plugin_path, debug, version):
details, interpret_escapes, interpret_emojis, plugin_path, debug,
version):
"""
Send a notification to all of the specified servers identified by their
URLs the content provided within the title, body and notification-type.
Expand Down Expand Up @@ -308,6 +311,9 @@ def main(body, title, config, attach, urls, notification_type, theme, tag,
# Interpret Escapes
interpret_escapes=interpret_escapes,

# Interpret Emojis
interpret_emojis=None if not interpret_emojis else True,

# Set the theme
theme=theme,

Expand Down
Loading

0 comments on commit 76831f9

Please sign in to comment.