Kaynağa Gözat

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

tags/1.0.1
Rocketsoup 4 yıl önce
ebeveyn
işleme
df488a0d4e
2 değiştirilmiş dosya ile 7 ekleme ve 0 silme
  1. 1
    0
      config.py.sample
  2. 6
    0
      rocketbot.py

+ 1
- 0
config.py.sample Dosyayı Görüntüle

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

+ 6
- 0
rocketbot.py Dosyayı Görüntüle

@@ -14,6 +14,12 @@ from cogs.crosspostcog import CrossPostCog
14 14
 from cogs.generalcog import GeneralCog
15 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 23
 class Rocketbot(commands.Bot):
18 24
 	def __init__(self, command_prefix, **kwargs):
19 25
 		super().__init__(command_prefix, **kwargs)

Loading…
İptal
Kaydet