Skip to content

Commit

Permalink
🐛 fixed UserConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
AirportR committed Apr 25, 2024
1 parent 071f14e commit 06eabfb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
5 changes: 3 additions & 2 deletions botmodule/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def born(app: "Client"):
logger.warning("您尚未配置管理员,请在bot启动成功后私聊bot发送任意消息,bot会自动将您注册为管理员。")
lock = asyncio.Lock()

async def waiting_born(_: "Client", message: "Message"):
async def waiting_born(client: "Client", message: "Message"):
async with lock:
admin_id = message.from_user.id
await message.reply(f"✅初始化成功,您已被确定成管理员,已将您的身份写入到配置文件~\n"
Expand All @@ -109,7 +109,8 @@ async def waiting_born(_: "Client", message: "Message"):
break
if self_h is not None:
app.remove_handler(self_h, -100)
logger.info(f"✅已初始化管理员, UID: {admin_id}Username:{message.from_user.username}")
logger.info(f"✅已初始化管理员, UID: {admin_id}Username:{message.from_user.username},正在重启bot...")
await botmodule.restart_or_killme(client, message)
hl = MessageHandler(waiting_born, filters.private)
app.add_handler(hl, -100)
else:
Expand Down
12 changes: 7 additions & 5 deletions utils/cleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -817,10 +817,12 @@ def getMasterconfig(self):
return self.config.get('masterconfig', {})

def getUserconfig(self):
userconfig = self.config.get('userconfig', {})
if not isinstance(userconfig, dict):
logger.warning("userconfig的类型应为字典")
return {}
try:
userconfig = self.config['userconfig']
except KeyError:
logger.info("未存在userconfig,初始化userconfig配置")
config.yaml['userconfig'] = {}
userconfig = {}
return userconfig

def getSlavecomment(self, slaveid: str) -> str:
Expand Down Expand Up @@ -853,7 +855,7 @@ def getBuildToken(self):
def getBotconfig(self):
botconfig = self.config.get('bot', {})
if botconfig is None:
print("bot_config为None")
logger.warning("bot配置项为None")
return {}
if not botconfig:
return botconfig
Expand Down

0 comments on commit 06eabfb

Please sign in to comment.