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
|
|
|
async def activity_join_request_middleware(self, payload: GatewayDispatch): |
35
|
|
|
"""|coro| |
36
|
|
|
|
37
|
|
|
Middleware for ``on_activity_join_request`` event. |
38
|
|
|
|
39
|
|
|
Parameters |
40
|
|
|
---------- |
41
|
|
|
payload : :class:`GatewayDispatch` |
42
|
|
|
The data received from the activity join request event. |
43
|
|
|
|
44
|
|
|
Returns |
45
|
|
|
------- |
46
|
|
|
Tuple[:class:`str`, List[:class:`~pincer.objects.user.user.User`]] |
47
|
|
|
``on_activity_join_request`` and a ``User`` |
48
|
|
|
""" |
49
|
|
|
return "on_activity_join_request", [ |
50
|
|
|
User.from_dict(construct_client_dict(self, payload.data)) |
51
|
|
|
] |
52
|
|
|
|
53
|
|
|
async def activity_join_middleware(self, payload: GatewayDispatch): |
54
|
|
|
"""|coro| |
55
|
|
|
|
56
|
|
|
Middleware for ``on_activity_join`` event. |
57
|
|
|
|
58
|
|
|
Parameters |
59
|
|
|
---------- |
60
|
|
|
payload : :class:`GatewayDispatch` |
61
|
|
|
The data received from the activity join event. |
62
|
|
|
|
63
|
|
|
Returns |
64
|
|
|
------- |
65
|
|
|
Tuple[:class:`str`, List[:class:`ActivityJoinEvent`]] |
66
|
|
|
``on_activity_join`` and an ``ActivityJoinEvent`` |
67
|
|
|
""" |
68
|
|
|
return "on_activity_join", [ |
69
|
|
|
ActivityJoinEvent.from_dict(construct_client_dict(self, payload.data)) |
70
|
|
|
] |
71
|
|
|
|
72
|
|
|
|
73
|
|
|
def export() -> Coro: |
|
|
|
|
74
|
|
|
return activity_spectate_middleware, activity_join_middleware, activity_join_request_middleware |
|
|
|
|