mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-21 18:27:59 -05:00
[V3 Config] Record custom group information using cog_add event (#2550)
* Do things differently * Uncomment critical lines * Reduce, reuse, recycle * Check groups on all new config objects after a cog loads * I don't know why this is failing now or why we need the global keyword * gotta fix this too
This commit is contained in:
@@ -12,11 +12,22 @@ from .drivers import get_driver, IdentifierData
|
||||
if TYPE_CHECKING:
|
||||
from .drivers.red_base import BaseDriver
|
||||
|
||||
__all__ = ["Config", "get_latest_confs"]
|
||||
|
||||
log = logging.getLogger("red.config")
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
_config_cache = weakref.WeakValueDictionary()
|
||||
_retrieved = weakref.WeakSet()
|
||||
|
||||
|
||||
def get_latest_confs() -> Tuple["Config"]:
|
||||
global _retrieved
|
||||
ret = set(_config_cache.values()) - set(_retrieved)
|
||||
_retrieved |= ret
|
||||
# noinspection PyTypeChecker
|
||||
return tuple(ret)
|
||||
|
||||
|
||||
class _ValueCtxManager(Awaitable[_T], AsyncContextManager[_T]):
|
||||
|
||||
Reference in New Issue
Block a user