Files
NijiHolo_EN_ID_Bot/src/talent_lists.py
T

59 lines
1.7 KiB
Python
Raw Normal View History

2022-09-24 17:56:58 -07:00
import util
holo_en = dict()
2022-09-25 04:24:04 -07:00
holo_id = dict()
niji_en = dict()
niji_exid = dict()
2022-09-24 17:56:58 -07:00
talents = dict()
2023-01-14 01:18:15 -08:00
talents_company = dict()
2022-09-24 17:56:58 -07:00
2022-09-26 14:44:46 -07:00
test_talents = dict()
# 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] != '#':
name, id = 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
__create_dict(f'{util.get_project_dir()}/lists/holoen.txt', holo_en, 'holoEN')
2022-09-25 04:24:04 -07:00
# holoID
__create_dict(f'{util.get_project_dir()}/lists/holoid.txt', holo_id, 'holoID')
2022-09-24 17:56:58 -07:00
# nijiEN
__create_dict(f'{util.get_project_dir()}/lists/nijien.txt', niji_en, 'nijiEN')
2022-09-25 04:24:04 -07:00
# nijiexID
__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
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