mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-09-02 22:12:25 +08:00
Merge branch 'dev'
This commit is contained in:
commit
e106de94a5
@ -4,6 +4,7 @@ import os
|
|||||||
from typing import DefaultDict, Mapping
|
from typing import DefaultDict, Mapping
|
||||||
|
|
||||||
import nonebot
|
import nonebot
|
||||||
|
from nonebot import logger
|
||||||
from tinydb import Query, TinyDB
|
from tinydb import Query, TinyDB
|
||||||
|
|
||||||
from .platform import platform_manager
|
from .platform import platform_manager
|
||||||
@ -110,9 +111,11 @@ class Config(metaclass=Singleton):
|
|||||||
cat_res = {target_type: defaultdict(lambda: defaultdict(list)) for target_type in supported_target_type}
|
cat_res = {target_type: defaultdict(lambda: defaultdict(list)) for target_type in supported_target_type}
|
||||||
tag_res = {target_type: defaultdict(lambda: defaultdict(list)) for target_type in supported_target_type}
|
tag_res = {target_type: defaultdict(lambda: defaultdict(list)) for target_type in supported_target_type}
|
||||||
# res = {target_type: defaultdict(lambda: defaultdict(list)) for target_type in supported_target_type}
|
# res = {target_type: defaultdict(lambda: defaultdict(list)) for target_type in supported_target_type}
|
||||||
|
to_del = []
|
||||||
for user in self.user_target.all():
|
for user in self.user_target.all():
|
||||||
for sub in user.get('subs', []):
|
for sub in user.get('subs', []):
|
||||||
if not sub.get('target_type') in supported_target_type:
|
if not sub.get('target_type') in supported_target_type:
|
||||||
|
to_del.append({'user': user['user'], 'user_type': user['user_type'], 'target': sub['target'], 'target_type': sub['target_type']})
|
||||||
continue
|
continue
|
||||||
res[sub['target_type']][sub['target']].append(User(user['user'], user['user_type']))
|
res[sub['target_type']][sub['target']].append(User(user['user'], user['user_type']))
|
||||||
cat_res[sub['target_type']][sub['target']]['{}-{}'.format(user['user_type'], user['user'])] = sub['cats']
|
cat_res[sub['target_type']][sub['target']]['{}-{}'.format(user['user_type'], user['user'])] = sub['cats']
|
||||||
@ -122,6 +125,10 @@ class Config(metaclass=Singleton):
|
|||||||
self.target_user_tag_cache = tag_res
|
self.target_user_tag_cache = tag_res
|
||||||
for target_type in self.target_user_cache:
|
for target_type in self.target_user_cache:
|
||||||
self.target_list[target_type] = list(self.target_user_cache[target_type].keys())
|
self.target_list[target_type] = list(self.target_user_cache[target_type].keys())
|
||||||
|
|
||||||
|
logger.info(f'Deleting {to_del}')
|
||||||
|
for d in to_del:
|
||||||
|
self.del_subscribe(**d)
|
||||||
|
|
||||||
def get_sub_category(self, target_type, target, user_type, user):
|
def get_sub_category(self, target_type, target, user_type, user):
|
||||||
return self.target_user_cat_cache[target_type][target]['{}-{}'.format(user_type, user)]
|
return self.target_user_cat_cache[target_type][target]['{}-{}'.format(user_type, user)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user