fix(config): improve reply loading and handle missing file
This commit is contained in:
@@ -16,17 +16,19 @@ class Config:
|
|||||||
try:
|
try:
|
||||||
reply_lines = []
|
reply_lines = []
|
||||||
with open(file_path, "r", encoding="utf-8") as replies:
|
with open(file_path, "r", encoding="utf-8") as replies:
|
||||||
lines = replies.readlines()
|
for line in replies:
|
||||||
|
line = line.rstrip("\n")
|
||||||
for line_index, line in enumerate(lines):
|
if not line:
|
||||||
|
continue
|
||||||
if " || " in line:
|
if " || " in line:
|
||||||
options = line.split(" || ")
|
options = [o.strip() for o in line.split(" || ")]
|
||||||
else:
|
else:
|
||||||
options = [line]
|
options = [line]
|
||||||
|
reply_lines.append(options)
|
||||||
|
|
||||||
reply_lines[line_index] = options
|
return reply_lines if reply_lines else [["✓"]]
|
||||||
|
|
||||||
except:
|
except FileNotFoundError:
|
||||||
return [["✓"]]
|
return [["✓"]]
|
||||||
|
|
||||||
def _load(self):
|
def _load(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user