2022-09-24 17:56:58 -07:00
|
|
|
import util
|
|
|
|
|
|
2023-08-15 17:32:01 -07:00
|
|
|
holo_en: dict[int, str] = dict()
|
|
|
|
|
holo_id: dict[int, str] = dict()
|
|
|
|
|
niji_en: dict[int, str] = dict()
|
|
|
|
|
niji_exid: dict[int, str] = dict()
|
|
|
|
|
talents: dict[int, str] = dict()
|
|
|
|
|
talents_company: dict[int, str] = dict()
|
2022-09-24 17:56:58 -07:00
|
|
|
|
2022-09-26 14:44:46 -07:00
|
|
|
test_talents = dict()
|
|
|
|
|
|
2023-01-13 02:55:25 -08:00
|
|
|
# TODO: talents(id) -> (name, company)
|
|
|
|
|
def __create_dict(file, _dict, company):
|
2022-09-25 18:31:50 -07:00
|
|
|
print(f'Initializing talents\' account list from {file}...')
|
2022-09-24 17:56:58 -07:00
|
|
|
global talents
|
|
|
|
|
with open(file, 'r') as f:
|
|
|
|
|
for line in f:
|
|
|
|
|
words = line.split()
|
|
|
|
|
if len(words) == 2 and line[0] != '#':
|
2023-05-16 19:18:12 -07:00
|
|
|
id, name = line.split()
|
2023-05-16 18:57:07 -07:00
|
|
|
# name = f'{util.get_username_online(id, default=name)}' # attempt to get updated name
|
2022-09-25 18:31:50 -07:00
|
|
|
talents[int(id)] = name
|
|
|
|
|
_dict[int(id)] = name
|
2023-01-14 01:18:15 -08:00
|
|
|
talents_company[int(id)] = company
|
2022-09-24 17:56:58 -07:00
|
|
|
def init():
|
|
|
|
|
global holo_en
|
2022-09-25 04:24:04 -07:00
|
|
|
global holo_id
|
|
|
|
|
global niji_en
|
|
|
|
|
global niji_exid
|
2022-09-26 14:44:46 -07:00
|
|
|
global test_talents
|
2022-09-24 17:56:58 -07:00
|
|
|
|
|
|
|
|
# holoEN
|
2023-01-13 02:55:25 -08:00
|
|
|
__create_dict(f'{util.get_project_dir()}/lists/holoen.txt', holo_en, 'holoEN')
|
2022-09-25 04:24:04 -07:00
|
|
|
# holoID
|
2023-01-13 02:55:25 -08:00
|
|
|
__create_dict(f'{util.get_project_dir()}/lists/holoid.txt', holo_id, 'holoID')
|
2022-09-24 17:56:58 -07:00
|
|
|
# nijiEN
|
2023-01-13 02:55:25 -08:00
|
|
|
__create_dict(f'{util.get_project_dir()}/lists/nijien.txt', niji_en, 'nijiEN')
|
2022-09-25 04:24:04 -07:00
|
|
|
# nijiexID
|
2023-01-13 02:55:25 -08:00
|
|
|
__create_dict(f'{util.get_project_dir()}/lists/nijiexid.txt', niji_exid, 'nijiex-ID')
|
|
|
|
|
# TODO: nijiex-KR
|
2022-09-25 04:24:04 -07:00
|
|
|
|
2022-09-27 15:09:09 -07:00
|
|
|
test_talents = holo_en
|
2022-09-26 14:44:46 -07:00
|
|
|
|
2023-08-13 16:01:10 -07:00
|
|
|
def is_niji(id: int) -> bool:
|
|
|
|
|
return id in niji_en or id in niji_exid
|
|
|
|
|
|
|
|
|
|
def is_holo(id: int) -> bool:
|
|
|
|
|
return id in holo_en or id in holo_id
|
|
|
|
|
|
2023-08-14 22:39:47 -07:00
|
|
|
def is_cross_company(id1: int, id2: int):
|
2023-08-15 17:32:01 -07:00
|
|
|
return (is_niji(id1) and is_holo(id2)) or (is_holo(id1) and is_niji(id2))
|
2023-08-14 22:39:47 -07:00
|
|
|
|
2023-08-14 02:47:29 -07:00
|
|
|
# For filtered stream
|
|
|
|
|
# DEPRECATED: thx elon
|
2022-09-27 22:04:26 -07:00
|
|
|
def get_twitter_rules():
|
|
|
|
|
global talents
|
|
|
|
|
rules = list()
|
|
|
|
|
|
|
|
|
|
names = list(talents.values())
|
2023-01-14 01:18:15 -08:00
|
|
|
curr_rule = f'from:{names}'
|
2022-09-27 22:04:26 -07:00
|
|
|
for name in list(talents.values())[1:]:
|
2023-01-14 01:18:15 -08:00
|
|
|
test_rule = curr_rule + f' OR from:{name}'
|
2022-09-27 22:04:26 -07:00
|
|
|
if len(test_rule) > 512:
|
|
|
|
|
rules.append(curr_rule)
|
2023-01-14 01:18:15 -08:00
|
|
|
curr_rule = f'from:{name}'
|
2022-09-27 22:04:26 -07:00
|
|
|
else:
|
|
|
|
|
curr_rule = test_rule
|
2023-01-23 22:37:21 -08:00
|
|
|
rules.append(curr_rule)
|
|
|
|
|
return rules
|