Add type hints for config items

This commit is contained in:
Richard Chien
2018-10-14 20:32:00 +08:00
parent e59a81858d
commit bc0d7aaa64
4 changed files with 24 additions and 18 deletions

View File

@ -86,11 +86,10 @@ async def handle_natural_language(bot: NoneBot, ctx: Dict[str, Any]) -> bool:
msg = str(ctx['message'])
if bot.config.NICKNAME:
# check if the user is calling me with my nickname
if not isinstance(bot.config.NICKNAME, Iterable):
# noinspection PyUnusedLocal
if isinstance(bot.config.NICKNAME, str) or \
not isinstance(bot.config.NICKNAME, Iterable):
nicknames = (bot.config.NICKNAME,)
else:
# noinspection PyUnusedLocal
nicknames = filter(lambda n: n, bot.config.NICKNAME)
m = re.search(rf'^({"|".join(nicknames)})[\s,]+', msg, re.IGNORECASE)
if m: