Passed
Pull Request — main (#195)
by
unknown
01:35
created

pincer.middleware.activity   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 21
dl 0
loc 80
rs 10
c 0
b 0
f 0

4 Functions

Rating   Name   Duplication   Size   Complexity  
A activity_spectate_middleware() 0 17 1
A activity_join_request_middleware() 0 17 1
A export() 0 5 1
A activity_join_middleware() 0 17 1
1
# Copyright Pincer 2021-Present
2
# Full MIT License can be found in `LICENSE` at the project root.
3
4
"""
5
Activitys
6
"""
7
8
from ..objects.events.activity import ActivitySpectateEvent, ActivityJoinEvent
9
from ..utils.conversion import construct_client_dict
10
from ..core.dispatch import GatewayDispatch
11
from ..utils.types import Coro
12
from ..objects.user.user import User
13
14
15
async def activity_spectate_middleware(self, payload: GatewayDispatch):
16
    """|coro|
17
18
    Middleware for ``on_activity_spectate`` event.
19
20
    Parameters
21
    ----------
22
    payload : :class:`GatewayDispatch`
23
        The data received from the activity spectate event.
24
25
    Returns
26
    -------
27
    Tuple[:class:`str`, List[:class:`ActivitySpectateEvent`]]
28
        ``on_activity_spectate`` and an ``ActivitySpectateEvent``
29
    """
30
    return "on_activity_spectate", [
31
        ActivitySpectateEvent.from_dict(construct_client_dict(self, payload.data))
32
    ]
33
34
35
async def activity_join_request_middleware(self, payload: GatewayDispatch):
36
    """|coro|
37
38
    Middleware for ``on_activity_join_request`` event.
39
40
    Parameters
41
    ----------
42
    payload : :class:`GatewayDispatch`
43
        The data received from the activity join request event.
44
45
    Returns
46
    -------
47
    Tuple[:class:`str`, List[:class:`~pincer.objects.user.user.User`]]
48
        ``on_activity_join_request`` and a ``User``
49
    """
50
    return "on_activity_join_request", [
51
        User.from_dict(construct_client_dict(self, payload.data))
52
    ]
53
54
55
async def activity_join_middleware(self, payload: GatewayDispatch):
56
    """|coro|
57
58
    Middleware for ``on_activity_join`` event.
59
60
    Parameters
61
    ----------
62
    payload : :class:`GatewayDispatch`
63
        The data received from the activity join event.
64
65
    Returns
66
    -------
67
    Tuple[:class:`str`, List[:class:`ActivityJoinEvent`]]
68
        ``on_activity_join`` and an ``ActivityJoinEvent``
69
    """
70
    return "on_activity_join", [
71
        ActivityJoinEvent.from_dict(construct_client_dict(self, payload.data))
72
    ]
73
74
75
def export() -> Coro:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
76
    return (
77
        activity_spectate_middleware,
78
        activity_join_middleware,
79
        activity_join_request_middleware,
80
    )
81