Repository: aiogram/aiogram

Issue:
[3.x] Rename "extract()" to "extract_from()" for entities
**Is your feature request related to a problem? Please describe.**
The current way to extract entity from message text looks like
```python
for item in message.entities:
    item.extract(message.text)
```
This sounds weird, since we extract entity from message, not vice versa.

**Describe the solution you'd like**
Rename `extract`  to `extract_from`. For example:
```python
for item in message.entities:
    item.extract_from(message.text)
```



Discussion:
github-actions[bot]: # :heavy_check_mark: Changelog found.

Thank you for adding a description of the changes
codecov[bot]: # [Codecov](https://codecov.io/gh/aiogram/aiogram/pull/945?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiogram) Report
> Merging [#945](https://codecov.io/gh/aiogram/aiogram/pull/945?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiogram) (0076a6f) into [dev-3.x](https://codecov.io/gh/aiogram/aiogram/commit/fadb11515e389a1edf53a059883fd42b2336c62b?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiogram) (fadb115) will **not change** coverage.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/aiogram/aiogram/pull/945/graphs/tree.svg?width=650&height=150&src=pr&token=cFqEr3p9MX&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiogram)](https://codecov.io/gh/aiogram/aiogram/pull/945?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiogram)

```diff
@@            Coverage Diff            @@
##           dev-3.x      #945   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          301       301           
  Lines         8139      8143    +4     
=========================================
+ Hits          8139      8143    +4     
```

| Flag | Coverage Δ | |
|---|---|---|
| unittests | `100.00% <100.00%> (ø)` | |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiogram#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Impacted Files](https://codecov.io/gh/aiogram/aiogram/pull/945?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiogram) | Coverage Δ | |
|---|---|---|
| [aiogram/types/message\_entity.py](https://codecov.io/gh/aiogram/aiogram/pull/945/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiogram#diff-YWlvZ3JhbS90eXBlcy9tZXNzYWdlX2VudGl0eS5weQ==) | `100.00% <100.00%> (ø)` | |

MasterGroosha: Awesome, thanks!

Patch:
diff --git a/CHANGES/944.misc.rst b/CHANGES/944.misc.rst
new file mode 100644
index 00000000..1dc64aaa
--- /dev/null
+++ b/CHANGES/944.misc.rst
@@ -0,0 +1,1 @@
+`MessageEntity` method `get_text` was removed and `extract` was renamed to `extract_from`
diff --git a/aiogram/types/message_entity.py b/aiogram/types/message_entity.py
index 7d090134..fa6aea41 100644
--- a/aiogram/types/message_entity.py
+++ b/aiogram/types/message_entity.py
@@ -1,5 +1,6 @@
 from __future__ import annotations
 
+import warnings
 from typing import TYPE_CHECKING, Optional
 
 from ..utils.text_decorations import add_surrogates, remove_surrogates
@@ -29,7 +30,15 @@ class MessageEntity(MutableTelegramObject):
     language: Optional[str] = None
     """*Optional*. For 'pre' only, the programming language of the entity text"""
 
-    def extract(self, text: str) -> str:
+    def extract_from(self, text: str) -> str:
         return remove_surrogates(
             add_surrogates(text)[self.offset * 2 : (self.offset + self.length) * 2]
         )
+
+    def extract(self, text: str) -> str:
+        warnings.warn(
+            "Method `MessageEntity.extract(...)` deprecated and will be removed in 3.0b5.\n"
+            " Use `MessageEntity.extract_from(...)` instead.",
+            DeprecationWarning,
+        )
+        return self.extract_from(text=text)


Test patch:
diff --git a/tests/test_api/test_types/test_message_entity.py b/tests/test_api/test_types/test_message_entity.py
index 572dbcb6..8dc4c0ea 100644
--- a/tests/test_api/test_types/test_message_entity.py
+++ b/tests/test_api/test_types/test_message_entity.py
@@ -1,7 +1,13 @@
 from aiogram.types import MessageEntity
+from tests.deprecated import check_deprecated
 
 
 class TestMessageEntity:
+    def test_extract_from(self):
+        entity = MessageEntity(type="hashtag", length=4, offset=5)
+        assert entity.extract_from("#foo #bar #baz") == "#bar"
+
     def test_extract(self):
         entity = MessageEntity(type="hashtag", length=4, offset=5)
-        assert entity.extract("#foo #bar #baz") == "#bar"
+        with check_deprecated("3.0b5", exception=AttributeError):
+            assert entity.extract("#foo #bar #baz") == "#bar"