Passed
Pull Request — main (#174)
by Yohann
01:54
created

pincer.middleware.notification_create.export()   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 2
rs 10
c 0
b 0
f 0
cc 1
nop 0
1
# Copyright Pincer 2021-Present
2
# Full MIT License can be found in `LICENSE` at the project root.
3
4
"""
5
sent when the client receives a notification
6
(mention or new message in eligible channels)
7
"""
8
9
from ..core.dispatch import GatewayDispatch
10
from ..objects.events.notification import NotificationCreateEvent
11
from ..utils.conversion import construct_client_dict
12
from ..utils.types import Coro
13
14
15
async def notification_create_middleware(self, payload: GatewayDispatch):
16
    """|coro|
17
18
    Middleware for ``on_notification_create`` event.
19
20
    Parameters
21
    ----------
22
    payload : :class:`GatewayDispatch`
23
        The data received from the notification create event.
24
25
    Returns
26
    -------
27
    Tuple[:class:`str`, List[:class:`~pincer.objects.events.notification.NotificationCreateEvent`]]
28
        ``on_notification_create`` and a ``NotificationCreateEvent``
29
    """
30
    channel_id: int = payload.data.get("channel_id")
31
    payload.data["message"]["channel_id"] = channel_id
32
    return "on_notification_create", [
33
        NotificationCreateEvent.from_dict(construct_client_dict(self, payload.data))
34
    ]
35
36
37
def export() -> Coro:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
38
    return notification_create_middleware
39