Update
This commit is contained in:
parent
faa672fa7c
commit
cfc84471fd
3 changed files with 13 additions and 2 deletions
|
@ -1,6 +1,8 @@
|
|||
from configparser import ConfigParser
|
||||
from os.path import abspath
|
||||
|
||||
from core.exceptions import ConfigFileNotFound
|
||||
|
||||
config_filename = 'config.cfg'
|
||||
config_path = abspath('./config/' + config_filename)
|
||||
|
||||
|
@ -10,7 +12,10 @@ class CFG:
|
|||
cp = ConfigParser()
|
||||
cp.read(config_path)
|
||||
try:
|
||||
section = cp.sections()[0]
|
||||
section = cp.sections()
|
||||
if len(section) == 0:
|
||||
raise ConfigFileNotFound(config_path) from None
|
||||
section = section[0]
|
||||
value = cp.get(section, q)
|
||||
except Exception:
|
||||
return False
|
||||
|
|
|
@ -5,6 +5,8 @@ import traceback
|
|||
|
||||
import requests
|
||||
|
||||
from core.exceptions import ConfigFileNotFound
|
||||
|
||||
confirm_command = ["是", "对", '确定', '是吧', '大概是',
|
||||
'也许', '可能', '对的', '是呢', '对呢', '嗯', '嗯呢',
|
||||
'吼啊', '资瓷', '是呗', '也许吧', '对呗', '应该',
|
||||
|
@ -55,7 +57,7 @@ def load_secret():
|
|||
cp.read(config_path)
|
||||
section = cp.sections()
|
||||
if len(section) == 0:
|
||||
raise Error('Config file not found') from None
|
||||
raise ConfigFileNotFound(config_path) from None
|
||||
section = section[0]
|
||||
options = cp.options(section)
|
||||
for option in options:
|
||||
|
|
|
@ -1,2 +1,6 @@
|
|||
class AbuseWarning(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class ConfigFileNotFound(Exception):
|
||||
pass
|
||||
|
|
Reference in a new issue