Skip to content

Commit

Permalink
Merge pull request #357 from q-user/fix/typo-on-intent-entity
Browse files Browse the repository at this point in the history
Fix typo on `intent` entity
  • Loading branch information
Tishka17 authored Feb 1, 2024
2 parents ac11122 + 2bd81eb commit 00fa375
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/aiogram_dialog/api/protocols/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ def find_dialog(self, state: Union[State, str]) -> DialogProtocol:
raise NotImplementedError

@abstractmethod
def state_groups(self) -> Dict[str, Type[StatesGroup]]:
def states_groups(self) -> Dict[str, Type[StatesGroup]]:
raise NotImplementedError
10 changes: 5 additions & 5 deletions src/aiogram_dialog/context/intent_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
ReplyCallbackQuery, STACK_KEY, STORAGE_KEY,
)
from aiogram_dialog.api.protocols import DialogRegistryProtocol
from aiogram_dialog.utils import remove_indent_id, split_reply_callback
from aiogram_dialog.utils import remove_intent_id, split_reply_callback
from .storage import StorageProxy

logger = getLogger(__name__)
Expand All @@ -37,7 +37,7 @@ def storage_proxy(self, data: dict):
storage=data["fsm_storage"],
user_id=data["event_from_user"].id,
chat_id=data["event_chat"].id,
state_groups=self.registry.state_groups(),
state_groups=self.registry.states_groups(),
)
return proxy

Expand Down Expand Up @@ -103,7 +103,7 @@ def _intent_id_from_reply(
for row in event.reply_to_message.reply_markup.inline_keyboard:
for button in row:
if button.callback_data:
intent_id, _ = remove_indent_id(button.callback_data)
intent_id, _ = remove_intent_id(button.callback_data)
return intent_id
return None

Expand Down Expand Up @@ -178,7 +178,7 @@ async def process_callback_query(

original_data = event.data
if event.data:
intent_id, callback_data = remove_indent_id(event.data)
intent_id, callback_data = remove_intent_id(event.data)
await self._load_context(event, intent_id, DEFAULT_STACK_ID, data)
data[CALLBACK_DATA_KEY] = original_data
else:
Expand Down Expand Up @@ -266,7 +266,7 @@ async def __call__(
storage=data["fsm_storage"],
user_id=user.id,
chat_id=chat.id,
state_groups=self.registry.state_groups(),
state_groups=self.registry.states_groups(),
)
data[STORAGE_KEY] = proxy
if isinstance(error, OutdatedIntent):
Expand Down
4 changes: 2 additions & 2 deletions src/aiogram_dialog/dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
DialogManager, DialogProtocol,
)
from .context.intent_filter import IntentFilter
from .utils import remove_indent_id
from .utils import remove_intent_id
from .widgets.data import PreviewAwareGetter
from .widgets.utils import ensure_data_getter, GetterVariant

Expand Down Expand Up @@ -139,7 +139,7 @@ async def _callback_handler(
dialog_manager: DialogManager,
):
old_context = dialog_manager.current_context()
intent_id, callback_data = remove_indent_id(callback.data)
intent_id, callback_data = remove_intent_id(callback.data)
cleaned_callback = callback.model_copy(update={"data": callback_data})
window = await self._current_window(dialog_manager)
await window.process_callback(cleaned_callback, self, dialog_manager)
Expand Down
8 changes: 4 additions & 4 deletions src/aiogram_dialog/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self, router: Router):
self.router = router
self._loaded = False
self._dialogs = {}
self._state_groups = {}
self._states_groups = {}

def _ensure_loaded(self):
if not self._loaded:
Expand All @@ -59,14 +59,14 @@ def find_dialog(self, state: Union[State, str]) -> DialogProtocol:
f" (looking by state `{state}`)",
) from e

def state_groups(self) -> Dict[str, Type[StatesGroup]]:
def states_groups(self) -> Dict[str, Type[StatesGroup]]:
self._ensure_loaded()
return self._state_groups
return self._states_groups

def refresh(self):
dialogs = collect_dialogs(self.router)
self._dialogs = {d.states_group(): d for d in dialogs}
self._state_groups = {
self._states_groups = {
d.states_group_name(): d.states_group()
for d in self._dialogs.values()
}
Expand Down
4 changes: 2 additions & 2 deletions src/aiogram_dialog/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def intent_callback_data(
return prefix + callback_data


def add_indent_id(keyboard: RawKeyboard, intent_id: str):
def add_intent_id(keyboard: RawKeyboard, intent_id: str):
for row in keyboard:
for button in row:
if isinstance(button, InlineKeyboardButton):
Expand All @@ -174,7 +174,7 @@ def add_indent_id(keyboard: RawKeyboard, intent_id: str):
)


def remove_indent_id(callback_data: str) -> Tuple[Optional[str], str]:
def remove_intent_id(callback_data: str) -> Tuple[Optional[str], str]:
if CB_SEP in callback_data:
intent_id, new_data = callback_data.split(CB_SEP, maxsplit=1)
return intent_id, new_data
Expand Down
4 changes: 2 additions & 2 deletions src/aiogram_dialog/widgets/markup/inline_keyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
from aiogram_dialog.api.internal.widgets import (
MarkupFactory, MarkupVariant, RawKeyboard,
)
from aiogram_dialog.utils import add_indent_id
from aiogram_dialog.utils import add_intent_id


class InlineKeyboardFactory(MarkupFactory):
async def render_markup(
self, data: dict, manager: DialogManager, keyboard: RawKeyboard,
) -> MarkupVariant:
# TODO validate buttons
add_indent_id(keyboard, manager.current_context().id)
add_intent_id(keyboard, manager.current_context().id)
return InlineKeyboardMarkup(
inline_keyboard=keyboard,
)
4 changes: 2 additions & 2 deletions src/aiogram_dialog/widgets/markup/reply_keyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from aiogram_dialog.api.internal.widgets import (
MarkupFactory, MarkupVariant, RawKeyboard,
)
from aiogram_dialog.utils import add_indent_id, transform_to_reply_keyboard
from aiogram_dialog.utils import add_intent_id, transform_to_reply_keyboard
from aiogram_dialog.widgets.text import Text


Expand Down Expand Up @@ -34,7 +34,7 @@ async def render_markup(
)
else:
placeholder = None
add_indent_id(keyboard, manager.current_context().id)
add_intent_id(keyboard, manager.current_context().id)
return ReplyKeyboardMarkup(
keyboard=transform_to_reply_keyboard(keyboard),
resize_keyboard=self.resize_keyboard,
Expand Down

0 comments on commit 00fa375

Please sign in to comment.