From b46cecf4207dd90820e7d1bf5077f966ae737098 Mon Sep 17 00:00:00 2001 From: jesopo Date: Thu, 2 Apr 2020 17:54:27 +0100 Subject: [PATCH] move ConnectionParams (and SASLParams) out to params.py --- ircrobots/interface.py | 23 +++++++---------------- ircrobots/params.py | 27 +++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 16 deletions(-) create mode 100644 ircrobots/params.py diff --git a/ircrobots/interface.py b/ircrobots/interface.py index 6661281..2baed82 100644 --- a/ircrobots/interface.py +++ b/ircrobots/interface.py @@ -1,25 +1,13 @@ -from typing import Optional +from typing import Awaitable, Optional from enum import IntEnum from dataclasses import dataclass from ircstates import Server from irctokens import Line -from .ircv3 import Capability -from .sasl import SASLParams - -@dataclass -class ConnectionParams(object): - nickname: str - host: str - port: int - ssl: bool - - username: Optional[str] = None - realname: Optional[str] = None - bindhost: Optional[str] = None - - sasl: Optional[SASLParams] = None +from .ircv3 import Capability +from .matching import BaseResponse +from .params import ConnectionParams class SendPriority(IntEnum): HIGH = 0 @@ -42,6 +30,9 @@ class IServer(Server): async def send(self, line: Line, priority=SendPriority.DEFAULT): pass + def wait_for(self, response: BaseResponse) -> Awaitable[Line]: + pass + def set_throttle(self, rate: int, time: float): pass diff --git a/ircrobots/params.py b/ircrobots/params.py new file mode 100644 index 0000000..8fd706c --- /dev/null +++ b/ircrobots/params.py @@ -0,0 +1,27 @@ +from typing import Optional +from dataclasses import dataclass + +@dataclass +class SASLParams(object): + mechanism: str + username: Optional[str] = None + password: Optional[str] = None +class SASLUserPass(SASLParams): + def __init__(self, username: str, password: str): + super().__init__("USERPASS", username, password) +class SASLExternal(SASLParams): + def __init__(self): + super().__init__("EXTERNAL") + +@dataclass +class ConnectionParams(object): + nickname: str + host: str + port: int + ssl: bool + + username: Optional[str] = None + realname: Optional[str] = None + bindhost: Optional[str] = None + + sasl: Optional[SASLParams] = None