Repository: aiogram/aiogram

Issue:
Magic .as_(...) operation works incorrectly with negative results
### Checklist

- [X] I am sure the error is coming from aiogram code
- [X] I have searched in the issue tracker for similar bug reports, including closed ones

### Operating system

Any

### Python version

Any

### aiogram version

3.0

### Expected behavior

`F.text.cast(int).as_("value")` should works when text is "0"

### Current behavior

0 interpreted as negative result

### Steps to reproduce

1. Send 0 as a text message

### Code example

```python3
from aiogram import Router, F
from aiogram.types import Message

demo_router = Router(name=__name__)


@demo_router.message(F.text.cast(int).as_("value"))
async def zero_handler(message: Message, value: int):
    await message.answer(f"Value: {value}")
```


### Logs

_No response_

### Additional information

_No response_

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

Thank you for adding a description of the changes

Patch:
diff --git a/CHANGES/1281.bugfix.rst b/CHANGES/1281.bugfix.rst
new file mode 100644
index 00000000..285b180d
--- /dev/null
+++ b/CHANGES/1281.bugfix.rst
@@ -0,0 +1,1 @@
+Fixed magic :code:`.as_(...)` operation for values that can be interpreted as `False` (e.g. `0`).
diff --git a/CHANGES/1282.bugfix.rst b/CHANGES/1282.bugfix.rst
new file mode 100644
index 00000000..323060b1
--- /dev/null
+++ b/CHANGES/1282.bugfix.rst
@@ -0,0 +1,1 @@
+Italic markdown from utils now uses correct decorators
\ No newline at end of file
diff --git a/aiogram/utils/magic_filter.py b/aiogram/utils/magic_filter.py
index fed406a7..94c92079 100644
--- a/aiogram/utils/magic_filter.py
+++ b/aiogram/utils/magic_filter.py
@@ -1,4 +1,4 @@
-from typing import Any
+from typing import Any, Iterable
 
 from magic_filter import MagicFilter as _MagicFilter
 from magic_filter import MagicT as _MagicT
@@ -12,7 +12,7 @@ class AsFilterResultOperation(BaseOperation):
         self.name = name
 
     def resolve(self, value: Any, initial_value: Any) -> Any:
-        if not value:
+        if value is None or (isinstance(value, Iterable) and not value):
             return None
         return {self.name: value}
 
diff --git a/aiogram/utils/markdown.py b/aiogram/utils/markdown.py
index 37600963..08b14a77 100644
--- a/aiogram/utils/markdown.py
+++ b/aiogram/utils/markdown.py
@@ -48,7 +48,7 @@ def italic(*content: Any, sep: str = " ") -> str:
     :param sep:
     :return:
     """
-    return markdown_decoration.italic(value=html_decoration.quote(_join(*content, sep=sep)))
+    return markdown_decoration.italic(value=markdown_decoration.quote(_join(*content, sep=sep)))
 
 
 def hitalic(*content: Any, sep: str = " ") -> str:


Test patch:
diff --git a/tests/test_utils/test_magic_filter.py b/tests/test_utils/test_magic_filter.py
index 4a1d05f3..097c8365 100644
--- a/tests/test_utils/test_magic_filter.py
+++ b/tests/test_utils/test_magic_filter.py
@@ -19,3 +19,17 @@ class TestMagicFilter:
         result = magic.resolve(MyObject(text="123"))
         assert isinstance(result, dict)
         assert isinstance(result["match"], Match)
+
+    def test_operation_as_not_none(self):
+        # Issue: https://github.com/aiogram/aiogram/issues/1281
+        magic = F.cast(int).as_("value")
+
+        result = magic.resolve("0")
+        assert result == {"value": 0}
+
+    def test_operation_as_not_none_iterable(self):
+        # Issue: https://github.com/aiogram/aiogram/issues/1281
+        magic = F.as_("value")
+
+        result = magic.resolve([])
+        assert result is None