Skip to content

Commit a61e026

Browse files
committed
Add empty key check for every key (in some way)
1 parent 6d80862 commit a61e026

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

.github/actions/validate-manifest/validate.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def main():
9090
for key in USERNAME_SOCIAL_KEYS:
9191
if key in social and (social[key].startswith('http') or 'www' in social[key]):
9292
error += f'- Please use a **username**, not a link (`social.{key}`)\n'
93-
if key in social and social[key] == '':
93+
if key in social and social[key] in ('', '-'):
9494
error += f'- Please remove the empty key **{key}** or fill in information.\n'
9595

9696
# Check facebook, because it works :)
@@ -110,8 +110,6 @@ def main():
110110
if 'rename_to_minecraft_name' in data['discord'] and data['discord']['rename_to_minecraft_name'] == True:
111111
comment += f'- `discord.rename_to_minecraft_name` is reserved for LabyMod Partners. Change it to `false`. If you are a partner, please ignore this message.\n'
112112

113-
if 'user_stats' in data and ('{userName}' not in data['user_stats'] and '{uuid}' not in data['user_stats']):
114-
error += '- Please use {userName} or {uuid} in your stats url (`user_stats`)\n'
115113

116114
if 'location' in data and 'country_code' in data['location']:
117115
country_code = data['location']['country_code']
@@ -131,10 +129,34 @@ def main():
131129
stats_url = data['user_stats']
132130
if not stats_url.startswith('https://'):
133131
error += f'- Invalid url. URL has to start with **https://** (`user_stats`)\n'
132+
if '{userName}' not in data['user_stats'] and '{uuid}' not in data['user_stats']:
133+
error += '- Please use {userName} or {uuid} in your stats url (`user_stats`)\n'
134134

135135
if '://laby.net/' in stats_url:
136136
error += f'- Please use **your own page**, not LABY.net (`user_stats`)\n'
137137

138+
if 'message_formats' in data['chat']:
139+
message_format = data['chat']['message_formats']
140+
if message_format == '^§[a-f0-9](?<level>\\d+)( \\||§8 \\|) §[a-f0-9](?<sender>[a-zA-Z0-9_]{2,16})§r§7: §f(?<message>.*)$':
141+
comment += f'- It seems you\'re using the **template regex** for chat message! Please make sure it is the right regex for **your server**!'
142+
if message_format in ('', '-'):
143+
error += f'- Please remove the empty key **message_formats** or fill in information.\n'
144+
145+
146+
if 'gamemodes' in data:
147+
gamemodes = data['gamemodes']
148+
for key, gamemode in gamemodes.items():
149+
if 'name' not in gamemode or 'color' not in gamemode or gamemode['name'] in ('', '-') or '#' not in gamemode['color']:
150+
error += f"- Please add a name or a color to the gamemode {key}\n"
151+
if 'url' in gamemode and gamemode['url'] in ('', '-'):
152+
error += f"- Please remove the empty url key in gamemode **{key}** or fill in information.\n"
153+
if 'versions' in gamemode and gamemode['versions'] in ('', '-'):
154+
error += f"- Please remove the empty version key in gamemode **{key}** or fill in information.\n"
155+
if 'command' in gamemode and gamemode['command'] in ('', '-'):
156+
error += f"- Please remove the empty command key in gamemode **{key}** or fill in information.\n"
157+
158+
159+
138160
if create_comment:
139161
post_comment(error)
140162
post_comment(comment)

0 commit comments

Comments
 (0)