Keep send_kwargs through get() and argument filter

This commit is contained in:
Richard Chien 2019-01-25 14:03:57 +08:00
parent 1fd740d223
commit ae35c2e08a
2 changed files with 7 additions and 4 deletions

View File

@ -260,7 +260,8 @@ class SwitchException(Exception):
class CommandSession(BaseSession): class CommandSession(BaseSession):
__slots__ = ('cmd', 'current_key', 'current_arg_filters', __slots__ = ('cmd',
'current_key', 'current_arg_filters', '_current_send_kwargs',
'current_arg', '_current_arg_text', '_current_arg_images', 'current_arg', '_current_arg_text', '_current_arg_images',
'_state', '_last_interaction', '_running') '_state', '_last_interaction', '_running')
@ -275,6 +276,8 @@ class CommandSession(BaseSession):
# initialize current argument filters # initialize current argument filters
self.current_arg_filters: Optional[List[ArgFilter_T]] = None self.current_arg_filters: Optional[List[ArgFilter_T]] = None
self._current_send_kwargs: Dict[str, Any] = {}
# initialize current argument # initialize current argument
self.current_arg: str = '' # with potential CQ codes self.current_arg: str = '' # with potential CQ codes
self._current_arg_text = None self._current_arg_text = None
@ -392,8 +395,7 @@ class CommandSession(BaseSession):
self.current_key = key self.current_key = key
self.current_arg_filters = arg_filters self.current_arg_filters = arg_filters
# TODO: self.current_send_kwargs self._current_send_kwargs = kwargs
# ask the user for more information
self.pause(prompt, **kwargs) self.pause(prompt, **kwargs)
def get_optional(self, key: str, def get_optional(self, key: str,

View File

@ -44,7 +44,8 @@ async def run_arg_filters(session: 'CommandSession',
failure_message = render_expression( failure_message = render_expression(
session.bot.config.DEFAULT_VALIDATION_FAILURE_EXPRESSION session.bot.config.DEFAULT_VALIDATION_FAILURE_EXPRESSION
) )
session.pause(failure_message) # noinspection PyProtectedMember
session.pause(failure_message, **session._current_send_kwargs)
# passed all filters # passed all filters
session.state[session.current_key] = arg session.state[session.current_key] = arg