Following port is integer

main
Bob Mottram 2022-12-10 10:34:49 +00:00
parent 9f7fd3293b
commit 6d2dc44c8a
1 changed files with 18 additions and 6 deletions

View File

@ -55,17 +55,21 @@ def _update_import_following(base_dir: str,
main_session = None main_session = None
lines = following_str.split('\n') lines = following_str.split('\n')
random.shuffle(lines) random.shuffle(lines)
print('FOLLOW: ' + handle + ' attempting to follow ' + str(lines))
nickname = handle.split('@')[0] nickname = handle.split('@')[0]
domain = handle.split('@')[1] domain = handle.split('@')[1]
for line in lines: for line in lines:
if '://' not in line and '@' not in line:
continue
if ',' not in line:
continue
orig_line = line orig_line = line
notes = None notes = None
line = line.strip() line = line.strip()
if ',' in line: fields = line.split(',')
fields = line.split(',') line = fields[0].strip()
line = fields[0].strip() if len(fields) >= 5:
if len(fields) >= 5: notes = fields[4]
notes = fields[4]
if line.startswith('#'): if line.startswith('#'):
# comment # comment
continue continue
@ -111,8 +115,16 @@ def _update_import_following(base_dir: str,
curr_http_prefix = httpd.http_prefix curr_http_prefix = httpd.http_prefix
following_actor = following_handle following_actor = following_handle
if ':' in following_domain: if ':' in following_domain:
following_port = following_handle.split(':')[1]
following_domain = following_domain.split(':')[0] following_domain = following_domain.split(':')[0]
following_port = following_handle.split(':')[1]
if following_port.isdigit():
following_port = int(following_port)
else:
if following_domain.endswith('.onion') or \
following_domain.endswith('.i2p'):
following_port = 80
else:
following_port = 443
# get the appropriate session # get the appropriate session
curr_session = main_session curr_session = main_session