1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

Merge pull request #1469 from abdullaev388/master

argument of 'func' parameter in handlers can be async function
This commit is contained in:
Badiboy 2022-03-01 18:11:20 +03:00 committed by GitHub
commit b8ebe4fd58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,7 @@ import logging
import re
import time
import traceback
import inspect
from typing import Any, List, Optional, Union
# this imports are used to avoid circular import error
@ -593,6 +594,8 @@ class AsyncTeleBot:
elif message_filter == 'chat_types':
return message.chat.type in filter_value
elif message_filter == 'func':
if inspect.iscoroutinefunction(filter_value):
return await filter_value(message)
return filter_value(message)
elif self.custom_filters and message_filter in self.custom_filters:
return await self._check_filter(message_filter,filter_value,message)