2024-01-25 16:29:01 -08:00
|
|
|
from util import project_root
|
2022-09-24 17:56:58 -07:00
|
|
|
|
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()
|
2023-08-18 01:34:25 -07:00
|
|
|
privated_accounts: dict[int, str] = dict()
|
2022-09-24 17:56:58 -07:00
|
|
|
|
2022-09-26 14:44:46 -07:00
|
|
|
test_talents = dict()
|
|
|
|
|
|
2024-01-25 16:29:01 -08:00
|
|
|
|
2023-01-13 02:55:25 -08:00
|
|
|
# TODO: talents(id) -> (name, company)
|
|
|
|
|
def __create_dict(file, _dict, company):
|
2024-01-25 16:29:01 -08:00
|
|
|
print(f"Initializing talents' account list from {file}...")
|
2022-09-24 17:56:58 -07:00
|
|
|
global talents
|
2024-01-25 16:29:01 -08:00
|
|
|
with open(file, "r") as f:
|
2022-09-24 17:56:58 -07:00
|
|
|
for line in f:
|
|
|
|
|
words = line.split()
|
2024-01-25 16:29:01 -08:00
|
|
|
if len(words) >= 2 and line[0] != "#":
|
2023-08-18 01:34:25 -07:00
|
|
|
t = line.split()
|
|
|
|
|
id, name = int(t[0]), t[1]
|
2023-05-16 18:57:07 -07:00
|
|
|
# name = f'{util.get_username_online(id, default=name)}' # attempt to get updated name
|
2023-08-18 01:34:25 -07:00
|
|
|
talents[id] = name
|
|
|
|
|
_dict[id] = name
|
|
|
|
|
talents_company[id] = company
|
2024-01-25 16:29:01 -08:00
|
|
|
if len(words) > 2 and words[2] == "p":
|
2023-08-18 01:34:25 -07:00
|
|
|
privated_accounts[id] = name
|
2024-01-25 16:29:01 -08:00
|
|
|
|
|
|
|
|
|
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
|
2024-01-25 16:29:01 -08:00
|
|
|
__create_dict(project_root(("lists",), "holoen.txt"), holo_en, "holoEN")
|
2022-09-25 04:24:04 -07:00
|
|
|
# holoID
|
2024-01-25 16:29:01 -08:00
|
|
|
__create_dict(project_root(("lists",), "holoid.txt"), holo_id, "holoID")
|
2022-09-24 17:56:58 -07:00
|
|
|
# nijiEN
|
2024-01-25 16:29:01 -08:00
|
|
|
__create_dict(project_root(("lists",), "nijien.txt"), niji_en, "nijiEN")
|
2022-09-25 04:24:04 -07:00
|
|
|
# nijiexID
|
2024-01-25 16:29:01 -08:00
|
|
|
__create_dict(project_root(("lists",), "nijiexid.txt"), niji_exid, "nijiex'ID")
|
2023-01-13 02:55:25 -08:00
|
|
|
# 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
|
|
|
|
2024-01-25 16:29:01 -08: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
|
|
|
|
|
|
2024-01-25 16:29:01 -08:00
|
|
|
|
2023-08-13 16:01:10 -07:00
|
|
|
def is_holo(id: int) -> bool:
|
|
|
|
|
return id in holo_en or id in holo_id
|
|
|
|
|
|
2024-01-25 16:29:01 -08:00
|
|
|
|
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
|
|
|
|
2024-01-25 16:29:01 -08: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())
|
2024-01-25 16:29:01 -08:00
|
|
|
curr_rule = f"from:{names}"
|
2022-09-27 22:04:26 -07:00
|
|
|
for name in list(talents.values())[1:]:
|
2024-01-25 16:29:01 -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)
|
2024-01-25 16:29:01 -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
|