import json
from cpl_core.application import ApplicationABC
from cpl_core.configuration import ConfigurationABC
from cpl_core.console import Console
from cpl_core.dependency_injection import ServiceProviderABC
class Application(ApplicationABC):
def __init__(self, config: ConfigurationABC, services: ServiceProviderABC):
ApplicationABC.__init__(self, config, services)
def configure(self):
pass
def main(self):
f = open("./Levels.txt", "r", encoding='utf-8')
i = 0
lines = f.readlines()
json_list = []
for line in lines:
if i > 0:
line = line.split('\n')[0]
words = line.split(' ')
use_words = []
for word in words:
if word != '':
use_words.append(word)
if len(use_words) == 6:
string = use_words[2]
use_words.remove(use_words[2])
use_words[1] += f' {string}'
loc_json = {
"id": int(use_words[0]),
"alias": use_words[1],
"min_ontime": int(use_words[2]),
"min_message_count": int(use_words[3]),
"color": use_words[4],
"hoist": "False",
"mentionable": "True",
"PermissionBagId": 0
}
json_list.append(loc_json)
i += 1
f.close()
Console.write_line(json_list)
json_format = json.dumps(json_list, ensure_ascii=False)
with open("../src/sh_dobby_bot/assets/Level.json", "w", encoding='utf-8') as outfile:
outfile.write(json_format)