summaryrefslogtreecommitdiff
path: root/miniirc_idc.py
diff options
context:
space:
mode:
authorluk3yx <luk3yx@users.noreply.github.com>2022-05-06 17:31:19 +1200
committerluk3yx <luk3yx@users.noreply.github.com>2022-05-06 17:31:19 +1200
commitecbdaa9e94f5a7acc13119f31754ce4d9f0a0919 (patch)
tree7fd8bde2f2b4f95a1f5d28b96f9b7d6a00f76472 /miniirc_idc.py
parent4cee3618b13ac7cc3c4d06a4a6f30163c02eae8d (diff)
downloadminiirc_idc-ecbdaa9e94f5a7acc13119f31754ce4d9f0a0919.tar.gz
miniirc_idc-ecbdaa9e94f5a7acc13119f31754ce4d9f0a0919.zip
Use = instead of : and make mypy happy
Diffstat (limited to 'miniirc_idc.py')
-rw-r--r--miniirc_idc.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/miniirc_idc.py b/miniirc_idc.py
index a4b2781..6169dc1 100644
--- a/miniirc_idc.py
+++ b/miniirc_idc.py
@@ -38,14 +38,15 @@ _esc_re = re.compile(r'\\(.)')
_idc_escapes = {'\\': '\\\\', 'r': '\r', 'n': '\n', 't': '\t'}
-def _get_idc_args(command: str, kwargs: dict[str, Optional[str]]
+def _get_idc_args(command: str, kwargs: dict[str, Optional[str | float]]
) -> Iterator[str]:
yield command
for key, value in kwargs.items():
if value is not None:
+ value = str(value)
for escape_char, char in _idc_escapes.items():
value = value.replace(char, '\\' + escape_char)
- yield f'{key.upper()}:{value}'
+ yield f'{key.upper()}={value}'
class IDC(miniirc.IRC):
@@ -55,8 +56,8 @@ class IDC(miniirc.IRC):
idc_cmd = None
idc_args = {}
for arg in msg.split('\t'):
- if ':' in arg:
- key, value = arg.split(':', 1)
+ if '=' in arg:
+ key, value = arg.split('=', 1)
idc_args[key] = _esc_re.sub(
lambda m: _idc_escapes.get(m.group(1), '\ufffd'),
value
@@ -107,11 +108,11 @@ class IDC(miniirc.IRC):
return command, hostmask, tags, args
# Send raw messages
- def idc_send(self, command: str, **kwargs: Optional[str]):
+ def idc_send(self, command: str, **kwargs: Optional[str | float]):
super().quote('\t'.join(_get_idc_args(command, kwargs)), force=True)
def quote(self, *msg: str, force: Optional[bool] = None,
- tags: Optional[dict[str, str]] = None) -> None:
+ tags: Optional[dict[str, str | bool]] = None) -> None:
cmd, _, tags2, args = miniirc.ircv3_message_parser(' '.join(msg))
if miniirc.ver[0] < 2 and args and args[-1].startswith(':'):
args[-1] = args[-1][1:]
@@ -128,7 +129,7 @@ class IDC(miniirc.IRC):
return self._get_idc_account()[0]
def send(self, cmd: str, *args: str, force: Optional[bool] = None,
- tags: Optional[dict[str, str]] = None) -> None:
+ tags: Optional[dict[str, str | bool]] = None) -> None:
cmd = cmd.upper()
label = tags.get('label') if tags else None
if cmd in ('PRIVMSG', 'NOTICE'):