-
Notifications
You must be signed in to change notification settings - Fork 1
/
miniirc.pyi
209 lines (157 loc) · 6.91 KB
/
miniirc.pyi
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# miniirc stub file
# This allows type checking without breaking compatibility or making the main
# file slower to load.
from __future__ import annotations
import atexit, concurrent.futures, errno, io, threading, time, socket, sys
from collections.abc import Callable, Iterable
from typing import Any, Optional, Union, overload
if sys.version_info >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal
# The version string and tuple
ver: tuple[int, int, int] = ...
version: str = ...
# __all__ and _default_caps
__all__: list[str] = ['CmdHandler', 'Handler', 'IRC']
_default_caps: set[str] = {'account-tag', 'cap-notify', 'chghost',
'draft/message-tags-0.2', 'invite-notify', 'message-tags',
'oragono.io/maxline-2', 'server-time', 'sts'}
# Get the certificate list.
get_ca_certs: Callable[[], Optional[str]]
# Create global handlers
_global_handlers: dict[str, Callable] = {}
def _add_handler(handlers, events, ircv3, cmd_arg, colon) \
-> Callable[[Callable], Callable]: ...
_handler_func_1 = Callable[['IRC', tuple[str, str, str], list[str]], Any]
_handler_func_2 = Callable[['IRC', tuple[str, str, str],
dict[str, Union[str, bool]], list[str]], Any]
@overload
def Handler(*events: str, colon: bool, ircv3: Literal[False] = False) \
-> Callable[[_handler_func_1], _handler_func_1]: ...
@overload
def Handler(*events: str, colon: bool, ircv3: Literal[True]) \
-> Callable[[_handler_func_2], _handler_func_2]: ...
_handler_func_3 = Callable[['IRC', str, tuple[str, str, str], list[str]], Any]
_handler_func_4 = Callable[['IRC', str, tuple[str, str, str],
dict[str, Union[str, bool]], list[str]], Any]
@overload
def CmdHandler(*events: str, colon: bool, ircv3: Literal[False] = False) \
-> Callable[[_handler_func_3], _handler_func_3]: ...
@overload
def CmdHandler(*events: str, colon: bool, ircv3: Literal[True]) \
-> Callable[[_handler_func_4], _handler_func_4]: ...
# Parse IRCv3 tags
ircv3_tag_escapes: dict[str, str] = {':': ';', 's': ' ', 'r': '\r', 'n': '\n'}
def _tags_to_dict(tag_list: Union[str, list[str]],
separator: Optional[str] = ';') -> dict[str, Union[str, bool]]: ...
# Create the IRCv2/3 parser
def ircv3_message_parser(msg: str) -> tuple[str, tuple[str, str, str],
dict[str, Union[str, bool]], list[str]]: ...
# Escape tags
def _escape_tag(tag: str) -> str: ...
# Convert a dict into an IRCv3 tags string
def _dict_to_tags(tags: dict[str, Union[str, bool]]) -> bytes: ...
# A wrapper for callable logfiles
class _Logfile:
__slots__ = ('_buffer', '_func')
def write(self, data: str) -> None: ...
def __init__(self, func: Callable[[str], Any]) -> None: ...
# Create the IRC class
class IRC:
connected: Optional[bool] = None
debug_file: Optional[Union[io.TextIOWrapper, _Logfile]] = ...
msglen: int = 512
_main_lock: Optional[threading.Thread] = None
_sasl: bool = False
_unhandled_caps: Optional[set] = None
@property
def current_nick(self) -> str:
...
ip: str
port: int
nick: str
channels: set[str]
ident: str
realname: str
ssl: Optional[bool]
persist: bool
ircv3_caps: set[str]
active_caps: set[str]
isupport: dict[str, Union[str, int]]
connect_modes: Optional[str]
quit_message: str
ping_interval: int
verify_ssl: bool
ns_identity: Union[tuple[str, str], str]
# Debug print()
def debug(self, *args: Any, **kwargs) -> None: ...
# Send raw messages
def quote(self, *msg: str, force: Optional[bool] = None,
tags: Optional[dict[str, Union[str, bool]]] = None) -> None: ...
def send(self, *msg: str, force: Optional[bool] = None,
tags: Optional[dict[str, Union[str, bool]]] = None) -> None: ...
# User-friendly msg, notice, and ctcp functions.
def msg(self, target: str, *msg: str,
tags: Optional[dict[str, Union[str, bool]]] = None) -> None: ...
def notice(self, target: str, *msg: str,
tags: Optional[dict[str, Union[str, bool]]] = None) -> None: ...
def ctcp(self, target: str, *msg: str, reply: bool = False,
tags: Optional[dict[str, Union[str, bool]]] = None) -> None: ...
def me(self, target: str, *msg: str,
tags: Optional[dict[str, Union[str, bool]]] = None) -> None: ...
# Allow per-connection handlers
@overload
def Handler(*events: str, colon: bool, ircv3: Literal[False] = False) \
-> Callable[[_handler_func_1], _handler_func_1]: ...
@overload
def Handler(*events: str, colon: bool, ircv3: Literal[True]) \
-> Callable[[_handler_func_2], _handler_func_2]: ...
@overload
def CmdHandler(*events: str, colon: bool, ircv3: Literal[False] = False) \
-> Callable[[_handler_func_3], _handler_func_3]: ...
@overload
def CmdHandler(*events: str, colon: bool, ircv3: Literal[True]) \
-> Callable[[_handler_func_4], _handler_func_4]: ...
# The connect function
def connect(self) -> None: ...
# An easier way to disconnect
def disconnect(self, msg: Optional[str] = None, *,
auto_reconnect: bool = False) -> None: ...
# Finish capability negotiation
def finish_negotiation(self, cap: str) -> None: ...
# Change the message parser
def change_parser(self, parser: Callable[
[str],
tuple[str, tuple[str, str, str], dict[str, Union[str, bool]],
list[str]]
] = ircv3_message_parser) -> None: ...
# Start a handler function
def _start_handler(
self, handlers: list[Callable], command: str,
hostmask: tuple[str, str, str], tags: dict[str, Union[str, bool]],
args: list[str]
) -> None: ...
# Launch handlers
def _handle(self, cmd: str, hostmask: tuple[str, str, str],
tags: dict[str, Union[str, bool]], args: list[str]) -> bool: ...
# Launch IRCv3 handlers
def _handle_cap(self, cap: str) -> None: ...
# The main loop
def _main(self) -> None: ...
# Waits until the client is disconnected and won't auto reconnect
def wait_until_disconnected(self) -> None: ...
# Initialize the class
def __init__(
self, ip: str, port: int, nick: str,
channels: Union[Iterable[str], str] = None, *,
ssl: Optional[bool] = None, ident: Optional[str] = None,
realname: Optional[str] = None, persist: bool = True,
debug: Union[bool, io.TextIOWrapper, _Logfile] = False,
ns_identity: Optional[Union[tuple[str, str], str]] = None,
auto_connect: bool = True, ircv3_caps: Optional[set[str]] = None,
connect_modes: Optional[str] = None,
quit_message: str = 'I grew sick and died.', ping_interval: int = 60,
verify_ssl: bool = True, server_password: Optional[str] = None,
executor: Optional[concurrent.futures.ThreadPoolExecutor]
) -> None: ...