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: |
|
|
|
|
76
|
|
|
return ( |
77
|
|
|
activity_spectate_middleware, |
78
|
|
|
activity_join_middleware, |
79
|
|
|
activity_join_request_middleware, |
80
|
|
|
) |
81
|
|
|
|