24
24
CallbackQueryMessageId ,
25
25
CallbackQuerySenderId ,
26
26
)
27
- from ..filters import Filter
27
+ from ..filters import Filter , messages as mf
28
28
29
29
if TYPE_CHECKING :
30
30
from .. import ContextTemplate
@@ -63,6 +63,7 @@ def callback_query(
63
63
keys : Sequence [AbstractKeyResolver [CallbackQuery , Any ]],
64
64
filter : Filter [CallbackQuery ],
65
65
tag : Optional [str ] = None ,
66
+ other_continue_with : Optional [list [str ]] = None ,
66
67
* args : Any ,
67
68
** kwargs : Any ,
68
69
):
@@ -72,7 +73,10 @@ def decorator(
72
73
_tag = tag or _function .__name__
73
74
if not self ._context .dp .handler_tag_exists (_tag , CallbackQuery ):
74
75
self ._context .dp .add .handlers .callback_query (
75
- _tag , _function , filter , [self ._context .handler_tag ]
76
+ _tag ,
77
+ _function ,
78
+ filter ,
79
+ [self ._context .handler_tag ] + (other_continue_with or []),
76
80
)
77
81
self ._context .continue_with .callback_query (_tag , keys , * args , ** kwargs )
78
82
@@ -83,6 +87,7 @@ def callback_query_form(
83
87
user_id : int ,
84
88
filter : Filter [CallbackQuery ],
85
89
tag : Optional [str ] = None ,
90
+ other_continue_with : Optional [list [str ]] = None ,
86
91
* args : Any ,
87
92
** kwargs : Any ,
88
93
):
@@ -92,7 +97,10 @@ def decorator(
92
97
_tag = tag or _function .__name__
93
98
if not self ._context .dp .handler_tag_exists (_tag , CallbackQuery ):
94
99
self ._context .dp .add .handlers .callback_query (
95
- _tag , _function , filter , [self ._context .handler_tag ]
100
+ _tag ,
101
+ _function ,
102
+ filter ,
103
+ [self ._context .handler_tag ] + (other_continue_with or []),
96
104
)
97
105
self ._context .continue_with .callback_query (
98
106
_tag , [CallbackQuerySenderId (user_id )], * args , ** kwargs
@@ -106,6 +114,7 @@ def callback_query_same_message_form(
106
114
user_id : int ,
107
115
filter : Filter [CallbackQuery ],
108
116
tag : Optional [str ] = None ,
117
+ other_continue_with : Optional [list [str ]] = None ,
109
118
* args : Any ,
110
119
** kwargs : Any ,
111
120
):
@@ -115,7 +124,10 @@ def decorator(
115
124
_tag = tag or _function .__name__
116
125
if not self ._context .dp .handler_tag_exists (_tag , CallbackQuery ):
117
126
self ._context .dp .add .handlers .callback_query (
118
- _tag , _function , filter , [self ._context .handler_tag ]
127
+ _tag ,
128
+ _function ,
129
+ filter ,
130
+ [self ._context .handler_tag ] + (other_continue_with or []),
119
131
)
120
132
self ._context .continue_with .callback_query (
121
133
_tag ,
@@ -131,6 +143,7 @@ def callback_query_same_message(
131
143
message_id : int ,
132
144
filter : Filter [CallbackQuery ],
133
145
tag : Optional [str ] = None ,
146
+ other_continue_with : Optional [list [str ]] = None ,
134
147
* args : Any ,
135
148
** kwargs : Any ,
136
149
):
@@ -140,7 +153,10 @@ def decorator(
140
153
_tag = tag or _function .__name__
141
154
if not self ._context .dp .handler_tag_exists (_tag , CallbackQuery ):
142
155
self ._context .dp .add .handlers .callback_query (
143
- _tag , _function , filter , [self ._context .handler_tag ]
156
+ _tag ,
157
+ _function ,
158
+ filter ,
159
+ [self ._context .handler_tag ] + (other_continue_with or []),
144
160
)
145
161
self ._context .continue_with .callback_query (
146
162
_tag ,
@@ -156,6 +172,7 @@ def message(
156
172
keys : list [AbstractKeyResolver [Message , Any ]],
157
173
filter : "Filter[Message]" ,
158
174
tag : Optional [str ] = None ,
175
+ other_continue_with : Optional [list [str ]] = None ,
159
176
* args : Any ,
160
177
** kwargs : Any ,
161
178
):
@@ -165,7 +182,10 @@ def decorator(
165
182
_tag = tag or _function .__name__
166
183
if not self ._context .dp .handler_tag_exists (_tag , Message ):
167
184
self ._context .dp .add .handlers .message (
168
- _tag , _function , filter , [self ._context .handler_tag ]
185
+ _tag ,
186
+ _function ,
187
+ filter ,
188
+ [self ._context .handler_tag ] + (other_continue_with or []),
169
189
)
170
190
self ._context .continue_with .message (_tag , keys , * args , ** kwargs )
171
191
@@ -176,6 +196,7 @@ def message_from(
176
196
user_id : int ,
177
197
filter : "Filter[Message]" ,
178
198
tag : Optional [str ] = None ,
199
+ other_continue_with : Optional [list [str ]] = None ,
179
200
* args : Any ,
180
201
** kwargs : Any ,
181
202
):
@@ -185,7 +206,35 @@ def decorator(
185
206
_tag = tag or _function .__name__
186
207
if not self ._context .dp .handler_tag_exists (_tag , Message ):
187
208
self ._context .dp .add .handlers .message (
188
- _tag , _function , filter , [self ._context .handler_tag ]
209
+ _tag ,
210
+ _function ,
211
+ filter ,
212
+ [self ._context .handler_tag ] + (other_continue_with or []),
213
+ )
214
+ self ._context .continue_with .message (
215
+ _tag , [MessageSenderId (user_id )], * args , ** kwargs
216
+ )
217
+
218
+ return decorator
219
+
220
+ def text_input_from (
221
+ self ,
222
+ user_id : int ,
223
+ tag : Optional [str ] = None ,
224
+ other_continue_with : Optional [list [str ]] = None ,
225
+ * args : Any ,
226
+ ** kwargs : Any ,
227
+ ):
228
+ def decorator (
229
+ _function : Callable [["MessageContext" ], Coroutine [Any , Any , None ]]
230
+ ):
231
+ _tag = tag or _function .__name__
232
+ if not self ._context .dp .handler_tag_exists (_tag , Message ):
233
+ self ._context .dp .add .handlers .message (
234
+ _tag ,
235
+ _function , # type: ignore
236
+ mf .text_message ,
237
+ [self ._context .handler_tag ] + (other_continue_with or []),
189
238
)
190
239
self ._context .continue_with .message (
191
240
_tag , [MessageSenderId (user_id )], * args , ** kwargs
0 commit comments