-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinterface.py
56 lines (46 loc) · 1.63 KB
/
interface.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# -*- coding: utf-8 -*-
# vim: set ft=python ts=4 sw=4 expandtab:
"""
Object interface used by plugin to access code in the local package.
"""
from datetime import datetime
from typing import Callable, Iterable, Optional
from attrs import frozen
@frozen
class Context:
# noinspection PyUnresolvedReferences
"""
Context for a message or command, including callbacks that can be invoked.
Attributes:
get_topic(Callable[[], str]): Get the topic for the current context
set_topic(Callable[[str], None]): Set a topic in the correct context
send_reply(Callable[[str], None]): Send a reply in the current context
send_message(Callable[[str], None]): Send a message to the server immediately
"""
get_topic: Callable[[], str]
set_topic: Callable[[str], None]
send_reply: Callable[[str], None]
send_message: Callable[[str], None]
@frozen
class Message:
# noinspection PyUnresolvedReferences
"""
A message to be processed.
Attributes:
id(str): Identifier for the message
timestamp(str): Time the message was received
nick(str): Nickname of the IRC user that sent the message
channel(str): Channel the message was sent to
network(str): Network the message was sent on
payload(str): Message payload
topic(Optional[str]): Current topic of the channel
channel_nicks(Optional[Iterable[str]]): List of nicknames currently in the channel
"""
id: str
timestamp: datetime
nick: str
channel: str
network: str
payload: str
topic: Optional[str] = None
channel_nicks: Optional[Iterable[str]] = None