Просмотр исходного кода

Adding version check to config.py as reminder for format changes

tags/1.0.1
Rocketsoup 4 лет назад
Родитель
Сommit
df488a0d4e
2 измененных файлов: 7 добавлений и 0 удалений
  1. 1
    0
      config.py.sample
  2. 6
    0
      rocketbot.py

+ 1
- 0
config.py.sample Просмотреть файл

1
 # Copy this file to config.py and fill in necessary values
1
 # Copy this file to config.py and fill in necessary values
2
 CONFIG = {
2
 CONFIG = {
3
+	'__config_version': 1,
3
 	'client_token': 'token',
4
 	'client_token': 'token',
4
 	'command_prefix': '$rb_',
5
 	'command_prefix': '$rb_',
5
 	'kick_emoji': '👢',
6
 	'kick_emoji': '👢',

+ 6
- 0
rocketbot.py Просмотреть файл

14
 from cogs.generalcog import GeneralCog
14
 from cogs.generalcog import GeneralCog
15
 from cogs.joinraidcog import JoinRaidCog
15
 from cogs.joinraidcog import JoinRaidCog
16
 
16
 
17
+CURRENT_CONFIG_VERSION = 1
18
+if (CONFIG.get('__config_version') or 0) < CURRENT_CONFIG_VERSION:
19
+    raise RuntimeError('config.py format may be outdated. Review ' +
20
+        'config.py.sample, update the "__config_version" field to ' +
21
+        f'{CURRENT_CONFIG_VERSION}, and try again.')
22
+
17
 class Rocketbot(commands.Bot):
23
 class Rocketbot(commands.Bot):
18
 	def __init__(self, command_prefix, **kwargs):
24
 	def __init__(self, command_prefix, **kwargs):
19
 		super().__init__(command_prefix, **kwargs)
25
 		super().__init__(command_prefix, **kwargs)

Загрузка…
Отмена
Сохранить