Skip to content

Commit cdcb1df

Browse files
committed
renamed black_keys to player_name_blacklist and removed too customized entries
and some detail tweaks
1 parent bc88b98 commit cdcb1df

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

stats_helper/config.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ class Config(Serializable):
1010
save_world_on_query: bool = False
1111
save_world_on_rank: bool = False
1212
save_world_on_scoreboard: bool = True
13-
black_keys: List[str] = [r'farm', r'bot_', r'cam', r'_b_', r'bot-', r'bot\d', r'^bot', r'A_Pi', r'nw', r'sw', r'SE',
14-
r'ne', r'nf', r'SandWall', r'storage', r'Steve', r'Alex', r'DuperMaster', r'Nya_Vanilla', r'Witch', r'Klio_5']
13+
player_name_blacklist: List[str] = [
14+
'^bot', 'Steve', 'Alex'
15+
]
1516

1617
def get_world_path(self) -> str:
1718
return os.path.join(self.server_path, self.world_folder)

stats_helper/utils.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ def name_to_uuid_fromAPI(name):
1515

1616

1717
def isBot(name: str):
18-
black_keys = Config.get_instance().black_keys
1918
if len(name) < 4 or len(name) > 16:
2019
return True
21-
for black_key in black_keys:
22-
if re.search(black_key, name, re.IGNORECASE):
20+
for bad_pattern in Config.get_instance().player_name_blacklist:
21+
if re.search(bad_pattern, name, re.IGNORECASE):
2322
return True
2423
return False
2524

@@ -37,3 +36,9 @@ def get_rank_color(rank: int) -> str:
3736
rank starts from 0
3837
"""
3938
return constants.rankColor[min(rank, len(constants.rankColor) - 1)]
39+
40+
41+
if __name__ == '__main__':
42+
print(isBot('bot123'))
43+
print(isBot('11bot123'))
44+
print(isBot('Steve'))

0 commit comments

Comments
 (0)