mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Compare commits
No commits in common. "ac12d0fc0245863284e15273e9deeb4c0d2250c3" and "b8ebe4fd58f419c41ba27f75a1019993b31fbf69" have entirely different histories.
ac12d0fc02
...
b8ebe4fd58
@ -769,6 +769,7 @@ See more examples in our [examples](https://github.com/eternnoir/pyTelegramBotAP
|
|||||||
Telegram Bot API support new type Chat for message.chat.
|
Telegram Bot API support new type Chat for message.chat.
|
||||||
|
|
||||||
- Check the ```type``` attribute in ```Chat``` object:
|
- Check the ```type``` attribute in ```Chat``` object:
|
||||||
|
-
|
||||||
```python
|
```python
|
||||||
if message.chat.type == "private":
|
if message.chat.type == "private":
|
||||||
# private chat message
|
# private chat message
|
||||||
|
@ -28,10 +28,8 @@ By cloning repository
|
|||||||
Directly using pip
|
Directly using pip
|
||||||
------------------
|
------------------
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
|
|
||||||
$ pip install git+https://github.com/eternnoir/pyTelegramBotAPI.git
|
$ pip install git+https://github.com/eternnoir/pyTelegramBotAPI.git
|
||||||
|
|
||||||
|
|
||||||
It is generally recommended to use the first option.
|
It is generally recommended to use the first option.
|
||||||
|
|
||||||
While the API is production-ready, it is still under development and it has regular updates, do not forget to update it regularly by calling:
|
While the API is production-ready, it is still under development and it has regular updates, do not forget to update it regularly by calling:
|
||||||
|
@ -278,18 +278,6 @@ class StateFilter(AdvancedCustomFilter):
|
|||||||
async def check(self, message, text):
|
async def check(self, message, text):
|
||||||
if text == '*': return True
|
if text == '*': return True
|
||||||
|
|
||||||
# needs to work with callbackquery
|
|
||||||
if isinstance(message, types.Message):
|
|
||||||
chat_id = message.chat.id
|
|
||||||
user_id = message.from_user.id
|
|
||||||
|
|
||||||
if isinstance(message, types.CallbackQuery):
|
|
||||||
|
|
||||||
chat_id = message.message.chat.id
|
|
||||||
user_id = message.from_user.id
|
|
||||||
message = message.message
|
|
||||||
|
|
||||||
|
|
||||||
if isinstance(text, list):
|
if isinstance(text, list):
|
||||||
new_text = []
|
new_text = []
|
||||||
for i in text:
|
for i in text:
|
||||||
@ -300,7 +288,7 @@ class StateFilter(AdvancedCustomFilter):
|
|||||||
text = text.name
|
text = text.name
|
||||||
|
|
||||||
if message.chat.type == 'group':
|
if message.chat.type == 'group':
|
||||||
group_state = await self.bot.current_states.get_state(user_id, chat_id)
|
group_state = await self.bot.current_states.get_state(message.chat.id, message.from_user.id)
|
||||||
if group_state == text:
|
if group_state == text:
|
||||||
return True
|
return True
|
||||||
elif group_state in text and type(text) is list:
|
elif group_state in text and type(text) is list:
|
||||||
@ -308,7 +296,7 @@ class StateFilter(AdvancedCustomFilter):
|
|||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
user_state = await self.bot.current_states.get_state(user_id, chat_id)
|
user_state = await self.bot.current_states.get_state(message.chat.id, message.from_user.id)
|
||||||
if user_state == text:
|
if user_state == text:
|
||||||
return True
|
return True
|
||||||
elif type(text) is list and user_state in text:
|
elif type(text) is list and user_state in text:
|
||||||
|
@ -5,8 +5,6 @@ from telebot.handler_backends import State
|
|||||||
from telebot import types
|
from telebot import types
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class SimpleCustomFilter(ABC):
|
class SimpleCustomFilter(ABC):
|
||||||
"""
|
"""
|
||||||
Simple Custom Filter base class.
|
Simple Custom Filter base class.
|
||||||
@ -283,20 +281,6 @@ class StateFilter(AdvancedCustomFilter):
|
|||||||
|
|
||||||
def check(self, message, text):
|
def check(self, message, text):
|
||||||
if text == '*': return True
|
if text == '*': return True
|
||||||
|
|
||||||
# needs to work with callbackquery
|
|
||||||
if isinstance(message, types.Message):
|
|
||||||
chat_id = message.chat.id
|
|
||||||
user_id = message.from_user.id
|
|
||||||
|
|
||||||
if isinstance(message, types.CallbackQuery):
|
|
||||||
|
|
||||||
chat_id = message.message.chat.id
|
|
||||||
user_id = message.from_user.id
|
|
||||||
message = message.message
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if isinstance(text, list):
|
if isinstance(text, list):
|
||||||
new_text = []
|
new_text = []
|
||||||
@ -306,9 +290,8 @@ class StateFilter(AdvancedCustomFilter):
|
|||||||
text = new_text
|
text = new_text
|
||||||
elif isinstance(text, State):
|
elif isinstance(text, State):
|
||||||
text = text.name
|
text = text.name
|
||||||
|
|
||||||
if message.chat.type == 'group':
|
if message.chat.type == 'group':
|
||||||
group_state = self.bot.current_states.get_state(user_id, chat_id)
|
group_state = self.bot.current_states.get_state(message.chat.id, message.from_user.id)
|
||||||
if group_state == text:
|
if group_state == text:
|
||||||
return True
|
return True
|
||||||
elif group_state in text and type(text) is list:
|
elif group_state in text and type(text) is list:
|
||||||
@ -316,7 +299,7 @@ class StateFilter(AdvancedCustomFilter):
|
|||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
user_state = self.bot.current_states.get_state(user_id, chat_id)
|
user_state = self.bot.current_states.get_state(message.chat.id, message.from_user.id)
|
||||||
if user_state == text:
|
if user_state == text:
|
||||||
return True
|
return True
|
||||||
elif type(text) is list and user_state in text:
|
elif type(text) is list and user_state in text:
|
||||||
|
Loading…
Reference in New Issue
Block a user