mirror of https://gitlab.com/bashrc2/epicyon
merge-requests/30/head
commit
c45bb10782
22
blocking.py
22
blocking.py
|
@ -693,22 +693,22 @@ def allowed_announce(base_dir: str, nickname: str, domain: str,
|
|||
base_dir + '/accounts/noannounce.txt'
|
||||
if os.path.isfile(global_announce_blocks_filename):
|
||||
if text_in_file('*@' + block_domain,
|
||||
global_announce_blocks_filename):
|
||||
global_announce_blocks_filename, False):
|
||||
return False
|
||||
if block_handle:
|
||||
block_str = block_handle + '\n'
|
||||
if text_in_file(block_str,
|
||||
global_announce_blocks_filename):
|
||||
global_announce_blocks_filename, False):
|
||||
return False
|
||||
|
||||
# non-cached account level announce blocks
|
||||
account_dir = acct_dir(base_dir, nickname, domain)
|
||||
blocking_filename = account_dir + '/noannounce.txt'
|
||||
if os.path.isfile(blocking_filename):
|
||||
if text_in_file('*@' + block_domain + '\n', blocking_filename):
|
||||
if text_in_file('*@' + block_domain + '\n', blocking_filename, False):
|
||||
return False
|
||||
if block_handle:
|
||||
if text_in_file(block_handle + '\n', blocking_filename):
|
||||
if text_in_file(block_handle + '\n', blocking_filename, False):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
@ -721,16 +721,24 @@ def allowed_announce_add(base_dir: str, nickname: str, domain: str,
|
|||
account_dir = acct_dir(base_dir, nickname, domain)
|
||||
blocking_filename = account_dir + '/noannounce.txt'
|
||||
handle = following_nickname + '@' + following_domain
|
||||
if text_in_file(handle + '\n', blocking_filename):
|
||||
if text_in_file(handle + '\n', blocking_filename, False):
|
||||
file_text = ''
|
||||
try:
|
||||
with open(blocking_filename, 'r',
|
||||
encoding='utf-8') as fp_noannounce:
|
||||
file_text = fp_noannounce.read()
|
||||
file_text = file_text.replace(handle + '\n', '')
|
||||
except OSError:
|
||||
print('EX: unable to read noannounce: ' +
|
||||
blocking_filename + ' ' + handle)
|
||||
|
||||
new_file_text = ''
|
||||
file_text_list = file_text.split('\n')
|
||||
handle_lower = handle.lower()
|
||||
for allowed in file_text_list:
|
||||
if allowed.lower() != handle_lower:
|
||||
new_file_text += allowed + '\n'
|
||||
file_text = new_file_text
|
||||
|
||||
try:
|
||||
with open(blocking_filename, 'w+',
|
||||
encoding='utf-8') as fp_noannounce:
|
||||
|
@ -749,7 +757,7 @@ def allowed_announce_remove(base_dir: str, nickname: str, domain: str,
|
|||
blocking_filename = account_dir + '/noannounce.txt'
|
||||
handle = following_nickname + '@' + following_domain
|
||||
file_text = ''
|
||||
if not text_in_file(handle + '\n', blocking_filename):
|
||||
if not text_in_file(handle + '\n', blocking_filename, False):
|
||||
try:
|
||||
with open(blocking_filename, 'r',
|
||||
encoding='utf-8') as fp_noannounce:
|
||||
|
|
|
@ -79,7 +79,7 @@ def receiving_calendar_events(base_dir: str, nickname: str, domain: str,
|
|||
fp_cal.write(following_handles)
|
||||
except OSError:
|
||||
print('EX: receiving_calendar_events 2 ' + calendar_filename)
|
||||
return _text_in_file2(handle + '\n', calendar_filename)
|
||||
return _text_in_file2(handle + '\n', calendar_filename, False)
|
||||
|
||||
|
||||
def _receive_calendar_events(base_dir: str, nickname: str, domain: str,
|
||||
|
@ -100,7 +100,7 @@ def _receive_calendar_events(base_dir: str, nickname: str, domain: str,
|
|||
handle = following_nickname + '@' + following_domain
|
||||
|
||||
# check that you are following this handle
|
||||
if not _text_in_file2(handle + '\n', following_filename):
|
||||
if not _text_in_file2(handle + '\n', following_filename, False):
|
||||
print('WARN: ' + handle + ' is not in ' + following_filename)
|
||||
return
|
||||
|
||||
|
@ -137,13 +137,21 @@ def _receive_calendar_events(base_dir: str, nickname: str, domain: str,
|
|||
print('EX: unable to write ' + calendar_filename)
|
||||
|
||||
# already in the calendar file?
|
||||
if handle + '\n' in following_handles:
|
||||
if handle + '\n' in following_handles or \
|
||||
handle + '\n' in following_handles.lower():
|
||||
print(handle + ' exists in followingCalendar.txt')
|
||||
if add:
|
||||
# already added
|
||||
return
|
||||
# remove from calendar file
|
||||
following_handles = following_handles.replace(handle + '\n', '')
|
||||
new_following_handles = ''
|
||||
following_handles_list = following_handles.split('\n')
|
||||
handle_lower = handle.lower()
|
||||
for followed in following_handles_list:
|
||||
if followed.lower() != handle_lower:
|
||||
new_following_handles += followed + '\n'
|
||||
following_handles = new_following_handles
|
||||
# save the result
|
||||
try:
|
||||
with open(calendar_filename, 'w+',
|
||||
encoding='utf-8') as fp_cal:
|
||||
|
|
|
@ -31,7 +31,7 @@ def _notify_on_post_arrival(base_dir: str, nickname: str, domain: str,
|
|||
handle = following_nickname + '@' + following_domain
|
||||
|
||||
# check that you are following this handle
|
||||
if not text_in_file(handle + '\n', following_filename):
|
||||
if not text_in_file(handle + '\n', following_filename, False):
|
||||
print('WARN: ' + handle + ' is not in ' + following_filename)
|
||||
return
|
||||
|
||||
|
@ -59,13 +59,21 @@ def _notify_on_post_arrival(base_dir: str, nickname: str, domain: str,
|
|||
fp_notify.write(following_handles + handle + '\n')
|
||||
|
||||
# already in the notifyOnPost file?
|
||||
if handle + '\n' in following_handles:
|
||||
if handle + '\n' in following_handles or \
|
||||
handle + '\n' in following_handles.lower():
|
||||
print(handle + ' exists in notifyOnPost.txt')
|
||||
if add:
|
||||
# already added
|
||||
return
|
||||
# remove from calendar file
|
||||
following_handles = following_handles.replace(handle + '\n', '')
|
||||
new_following_handles = ''
|
||||
following_handles_list = following_handles.split('\n')
|
||||
handle_lower = handle.lower()
|
||||
for followed in following_handles_list:
|
||||
if followed.lower() != handle_lower:
|
||||
new_following_handles += followed + '\n'
|
||||
following_handles = new_following_handles
|
||||
|
||||
with open(notify_on_post_filename, 'w+',
|
||||
encoding='utf-8') as fp_notify:
|
||||
fp_notify.write(following_handles)
|
||||
|
@ -113,4 +121,4 @@ def notify_when_person_posts(base_dir: str, nickname: str, domain: str,
|
|||
with open(notify_on_post_filename, 'w+',
|
||||
encoding='utf-8') as fp_notify:
|
||||
fp_notify.write('')
|
||||
return text_in_file(handle + '\n', notify_on_post_filename)
|
||||
return text_in_file(handle + '\n', notify_on_post_filename, False)
|
||||
|
|
|
@ -54,8 +54,8 @@ def _minimize_attached_images(base_dir: str, nickname: str, domain: str,
|
|||
return
|
||||
handle = following_nickname + '@' + following_domain
|
||||
|
||||
# check that you are following this handle
|
||||
if not text_in_file(handle + '\n', following_filename):
|
||||
# check that you are following this handle (not case sensitive)
|
||||
if not text_in_file(handle + '\n', following_filename, False):
|
||||
print('WARN: ' + handle + ' is not in ' + following_filename)
|
||||
return
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ def minimizing_attached_images(base_dir: str, nickname: str, domain: str,
|
|||
fp_min.write('')
|
||||
except OSError:
|
||||
print('EX: minimizing_attached_images 2 ' + minimize_filename)
|
||||
return text_in_file(handle + '\n', minimize_filename)
|
||||
return text_in_file(handle + '\n', minimize_filename, False)
|
||||
|
||||
|
||||
def get_broken_link_substitute() -> str:
|
||||
|
|
Loading…
Reference in New Issue