mirror of https://gitlab.com/bashrc2/epicyon
Scope of exception
parent
49f9dd9505
commit
da341f92f1
26
speaker.py
26
speaker.py
|
@ -254,11 +254,12 @@ def _add_ssml_emphasis(say_text: str) -> str:
|
||||||
words_list = text.split(' ')
|
words_list = text.split(' ')
|
||||||
replacements = {}
|
replacements = {}
|
||||||
for word in words_list:
|
for word in words_list:
|
||||||
if word.startswith('*'):
|
if not word.startswith('*'):
|
||||||
if word.endswith('*'):
|
continue
|
||||||
|
if not word.endswith('*'):
|
||||||
|
continue
|
||||||
replacements[word] = \
|
replacements[word] = \
|
||||||
'<emphasis level="strong">' + \
|
'<emphasis level="strong">' + word.replace('*', '') + \
|
||||||
word.replace('*', '') + \
|
|
||||||
'</emphasis>'
|
'</emphasis>'
|
||||||
for replace_str, new_str in replacements.items():
|
for replace_str, new_str in replacements.items():
|
||||||
say_text = say_text.replace(replace_str, new_str)
|
say_text = say_text.replace(replace_str, new_str)
|
||||||
|
@ -276,7 +277,8 @@ def _remove_emoji_from_text(say_text: str) -> str:
|
||||||
words_list = text.split(' ')
|
words_list = text.split(' ')
|
||||||
replacements = {}
|
replacements = {}
|
||||||
for word in words_list:
|
for word in words_list:
|
||||||
if word.startswith(':'):
|
if not word.startswith(':'):
|
||||||
|
continue
|
||||||
if word.endswith(':'):
|
if word.endswith(':'):
|
||||||
replacements[word] = ''
|
replacements[word] = ''
|
||||||
for replace_str, new_str in replacements.items():
|
for replace_str, new_str in replacements.items():
|
||||||
|
@ -481,10 +483,10 @@ def _post_to_speaker_json(base_dir: str, http_prefix: str,
|
||||||
for img in post_attachments:
|
for img in post_attachments:
|
||||||
if not isinstance(img, dict):
|
if not isinstance(img, dict):
|
||||||
continue
|
continue
|
||||||
if img.get('name'):
|
if not img.get('name'):
|
||||||
|
continue
|
||||||
if isinstance(img['name'], str):
|
if isinstance(img['name'], str):
|
||||||
image_description += \
|
image_description += remove_html(img['name']) + '. '
|
||||||
remove_html(img['name']) + '. '
|
|
||||||
|
|
||||||
is_direct = is_dm(post_json_object)
|
is_direct = is_dm(post_json_object)
|
||||||
actor = local_actor_url(http_prefix, nickname, domain_full)
|
actor = local_actor_url(http_prefix, nickname, domain_full)
|
||||||
|
@ -534,18 +536,20 @@ def _post_to_speaker_json(base_dir: str, http_prefix: str,
|
||||||
accounts_dir = acct_dir(base_dir, nickname, domain_full)
|
accounts_dir = acct_dir(base_dir, nickname, domain_full)
|
||||||
approve_follows_filename = accounts_dir + '/followrequests.txt'
|
approve_follows_filename = accounts_dir + '/followrequests.txt'
|
||||||
if os.path.isfile(approve_follows_filename):
|
if os.path.isfile(approve_follows_filename):
|
||||||
|
follows = []
|
||||||
try:
|
try:
|
||||||
with open(approve_follows_filename, 'r',
|
with open(approve_follows_filename, 'r',
|
||||||
encoding='utf-8') as fp_foll:
|
encoding='utf-8') as fp_foll:
|
||||||
follows = fp_foll.readlines()
|
follows = fp_foll.readlines()
|
||||||
|
except OSError:
|
||||||
|
print('EX: _post_to_speaker_json unable to read ' +
|
||||||
|
approve_follows_filename)
|
||||||
|
if follows:
|
||||||
if len(follows) > 0:
|
if len(follows) > 0:
|
||||||
follow_requests_exist = True
|
follow_requests_exist = True
|
||||||
for i, _ in enumerate(follows):
|
for i, _ in enumerate(follows):
|
||||||
follows[i] = follows[i].strip()
|
follows[i] = follows[i].strip()
|
||||||
follow_requests_list = follows
|
follow_requests_list = follows
|
||||||
except OSError:
|
|
||||||
print('EX: _post_to_speaker_json unable to read ' +
|
|
||||||
approve_follows_filename)
|
|
||||||
post_dm = False
|
post_dm = False
|
||||||
dm_filename = accounts_dir + '/.newDM'
|
dm_filename = accounts_dir + '/.newDM'
|
||||||
if os.path.isfile(dm_filename):
|
if os.path.isfile(dm_filename):
|
||||||
|
|
Loading…
Reference in New Issue