From c3c553e70dcc0ebdf38f11ef56429fbc1e8edd40 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 30 Dec 2022 21:39:25 +0000 Subject: [PATCH] Case insensitive --- notifyOnPost.py | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/notifyOnPost.py b/notifyOnPost.py index 8f47e701e..30c67d30d 100644 --- a/notifyOnPost.py +++ b/notifyOnPost.py @@ -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,24 +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', '') - with open(notify_on_post_filename, 'w+', - encoding='utf-8') as fp_notify: - fp_notify.write(following_handles) - elif 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.lower() + '\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)