Repository: aiogram/aiogram

Issue:
TypeError: aiogram.dispatcher.router.Router.emit_startup() got multiple values for keyword argument 'bot'
## Expected Behavior

Successful startup of Dispatcher.start_polling

## Current Behavior

`TypeError: aiogram.dispatcher.router.Router.emit_startup() got multiple values for keyword argument 'bot'`

### Steps to Reproduce

Please provide detailed steps for reproducing the issue.

1. `dispatcher.start_polling(bot)`

### Failure Logs

```
Traceback (most recent call last):
  File "...lib\site-packages\aiogram\dispatcher\dispatcher.py", line 519, in start_polling
    await self.emit_startup(bot=bots[-1], **workflow_data)
TypeError: aiogram.dispatcher.router.Router.emit_startup() got multiple values for keyword argument 'bot'
```

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

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

[![Impacted file tree graph](https://app.codecov.io/gh/aiogram/aiogram/pull/1247/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://app.codecov.io/gh/aiogram/aiogram/pull/1247?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     #1247   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          364       364           
  Lines         9305      9307    +2     
=========================================
+ Hits          9305      9307    +2     
```

| 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.

| [Files Changed](https://app.codecov.io/gh/aiogram/aiogram/pull/1247?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiogram) | Coverage Δ | |
|---|---|---|
| [aiogram/dispatcher/dispatcher.py](https://app.codecov.io/gh/aiogram/aiogram/pull/1247?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=aiogram#diff-YWlvZ3JhbS9kaXNwYXRjaGVyL2Rpc3BhdGNoZXIucHk=) | `100.00% <100.00%> (ø)` | |


Patch:
diff --git a/CHANGES/1242.bugfix.rst b/CHANGES/1242.bugfix.rst
new file mode 100644
index 00000000..eb981383
--- /dev/null
+++ b/CHANGES/1242.bugfix.rst
@@ -0,0 +1,1 @@
+Fixed polling startup when "bot" key is passed manually into dispatcher workflow data
diff --git a/aiogram/dispatcher/dispatcher.py b/aiogram/dispatcher/dispatcher.py
index eb2d55f2..f85c91d4 100644
--- a/aiogram/dispatcher/dispatcher.py
+++ b/aiogram/dispatcher/dispatcher.py
@@ -516,6 +516,9 @@ class Dispatcher(Router):
                 **self.workflow_data,
                 **kwargs,
             }
+            if "bot" in workflow_data:
+                workflow_data.pop("bot")
+
             await self.emit_startup(bot=bots[-1], **workflow_data)
             loggers.dispatcher.info("Start polling")
             try:


Test patch:
diff --git a/tests/test_dispatcher/test_dispatcher.py b/tests/test_dispatcher/test_dispatcher.py
index 69aece69..b0cc5b79 100644
--- a/tests/test_dispatcher/test_dispatcher.py
+++ b/tests/test_dispatcher/test_dispatcher.py
@@ -675,6 +675,7 @@ class TestDispatcher:
 
     async def test_start_polling(self, bot: MockedBot):
         dispatcher = Dispatcher()
+        dispatcher.workflow_data["bot"] = 42
         with pytest.raises(
             ValueError, match="At least one bot instance is required to start polling"
         ):
@@ -708,6 +709,8 @@ class TestDispatcher:
             mocked_emit_startup.assert_awaited()
             mocked_process_update.assert_awaited()
             mocked_emit_shutdown.assert_awaited()
+            assert dispatcher.workflow_data["bot"] == 42
+            assert mocked_emit_shutdown.call_args.kwargs["bot"] == bot
 
     async def test_stop_polling(self):
         dispatcher = Dispatcher()