From 4ee54ea4e6d25af6e6b56177d3c46b5a827c3572 Mon Sep 17 00:00:00 2001 From: Alex Root Junior Date: Sun, 3 Dec 2017 00:48:01 +0200 Subject: [PATCH] Wut? Class with item assignments for context. --- aiogram/utils/context.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/aiogram/utils/context.py b/aiogram/utils/context.py index 2a846b23..77861eaa 100644 --- a/aiogram/utils/context.py +++ b/aiogram/utils/context.py @@ -114,3 +114,25 @@ def check_configured(): :return: """ return get_value(CONFIGURED) + + +class _Context: + """ + Other things for interactions with the execution context. + """ + + def __getitem__(self, item): + return get_value(item) + + def __setitem__(self, key, value): + set_value(key, value) + + def __delitem__(self, key): + del_value(key) + + @staticmethod + def get_context(): + return get_current_state() + + +context = _Context()