activity_spectate_middleware()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 20
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 20
rs 10
c 0
b 0
f 0
cc 1
nop 3
1
# Copyright Pincer 2021-Present
2
# Full MIT License can be found in `LICENSE` at the project root.
3
4
"""
5
sent when the user clicks a Rich Presence spectate invite in chat to
6
spectate a game
7
"""
8
9
from __future__ import annotations
10
11
from typing import TYPE_CHECKING
12
13
from ..objects.events.activity import ActivitySpectateEvent
14
from ..utils.types import Coro
15
16
if TYPE_CHECKING:
17
    from ..client import Client
18
    from ..core.gateway import Gateway
19
    from ..core.gateway import GatewayDispatch
20
21
22
async def activity_spectate_middleware(
23
    self: Client, gateway: Gateway, payload: GatewayDispatch
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
Unused Code introduced by
The argument gateway seems to be unused.
Loading history...
Unused Code introduced by
The argument self seems to be unused.
Loading history...
24
):
25
    """|coro|
26
27
    Middleware for the ``on_activity_spectate`` event.
28
29
    Parameters
30
    ----------
31
    payload : :class:`~pincer.core.gateway.GatewayDispatch`
32
        The data received from the activity spectate event.
33
    gateway : :class:`~pincer.core.gateway.Gateway`
34
        The gateway for the current shard.
35
36
    Returns
37
    -------
38
    Tuple[:class:`str`, :class:`~pincer.objects.event.activity.ActivitySpectateEvent`]
39
        ``on_activity_spectate`` and an ``ActivitySpectateEvent``
40
    """  # noqa: E501
41
    return "on_activity_spectate", ActivitySpectateEvent.from_dict(payload.data)
42
43
44
def export() -> Coro:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
45
    return activity_spectate_middleware
46