You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: telegram/ext/callbackqueryhandler.py
+43-5Lines changed: 43 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -18,14 +18,18 @@
18
18
# along with this program. If not, see [http://www.gnu.org/licenses/].
19
19
""" This module contains the CallbackQueryHandler class """
20
20
21
-
from .handlerimportHandler
21
+
importre
22
+
23
+
fromfuture.utilsimportstring_types
24
+
22
25
fromtelegramimportUpdate
23
26
fromtelegram.utils.deprecateimportdeprecate
27
+
from .handlerimportHandler
24
28
25
29
26
30
classCallbackQueryHandler(Handler):
27
31
"""
28
-
Handler class to handle Telegram callback queries.
32
+
Handler class to handle Telegram callback queries. Optionally based on a regex. Read the documentation of the ``re`` module for more information.
29
33
30
34
Args:
31
35
callback (function): A function that takes ``bot, update`` as
@@ -39,22 +43,56 @@ class CallbackQueryHandler(Handler):
39
43
``job_queue`` will be passed to the callback function. It will be a ``JobQueue``
40
44
instance created by the ``Updater`` which can be used to schedule new jobs.
41
45
Default is ``False``.
46
+
pattern (optional[str or Pattern]): Optional regex pattern. If not ``None`` The ``re.match`` function is used to determine if an update should be handled by this handler.
47
+
pass_groups (optional[bool]): If the callback should be passed the
48
+
result of ``re.match(pattern, data).groups()`` as a keyword
49
+
argument called ``groups``. Default is ``False``
50
+
pass_groupdict (optional[bool]): If the callback should be passed the
51
+
result of ``re.match(pattern, data).groupdict()`` as a keyword
52
+
argument called ``groupdict``. Default is ``False``
Copy file name to clipboardExpand all lines: telegram/ext/inlinequeryhandler.py
+42-5Lines changed: 42 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -17,15 +17,18 @@
17
17
# You should have received a copy of the GNU Lesser Public License
18
18
# along with this program. If not, see [http://www.gnu.org/licenses/].
19
19
""" This module contains the InlineQueryHandler class """
20
+
importre
21
+
22
+
fromfuture.utilsimportstring_types
20
23
21
-
from .handlerimportHandler
22
24
fromtelegramimportUpdate
23
25
fromtelegram.utils.deprecateimportdeprecate
26
+
from .handlerimportHandler
24
27
25
28
26
29
classInlineQueryHandler(Handler):
27
30
"""
28
-
Handler class to handle Telegram inline queries.
31
+
Handler class to handle Telegram inline queries. Optionally based on a regex. Read the documentation of the ``re`` module for more information.
29
32
30
33
Args:
31
34
callback (function): A function that takes ``bot, update`` as
@@ -39,22 +42,56 @@ class InlineQueryHandler(Handler):
39
42
``job_queue`` will be passed to the callback function. It will be a ``JobQueue``
40
43
instance created by the ``Updater`` which can be used to schedule new jobs.
41
44
Default is ``False``.
45
+
pattern (optional[str or Pattern]): Optional regex pattern. If not ``None`` The ``re.match`` function is used to determine if an update should be handled by this handler.
46
+
pass_groups (optional[bool]): If the callback should be passed the
47
+
result of ``re.match(pattern, query).groups()`` as a keyword
48
+
argument called ``groups``. Default is ``False``
49
+
pass_groupdict (optional[bool]): If the callback should be passed the
50
+
result of ``re.match(pattern, query).groupdict()`` as a keyword
51
+
argument called ``groupdict``. Default is ``False``
0 commit comments