add Server.send_part() that optionally awaits PART confirmation

This commit is contained in:
jesopo 2020-04-20 16:53:49 +01:00
parent a79958affd
commit 5892c9ff45

View file

@ -12,7 +12,8 @@ from .ircv3 import (CAPContext, sts_transmute, CAP_ECHO, CAP_SASL,
CAP_LABEL, LABEL_TAG) CAP_LABEL, LABEL_TAG)
from .sasl import SASLContext, SASLResult from .sasl import SASLContext, SASLResult
from .join_info import WHOContext from .join_info import WHOContext
from .matching import ResponseOr, Responses, Response, ParamAny, ParamFolded from .matching import (ResponseOr, Responses, Response, ParamAny, ParamFolded,
Nickname)
from .asyncs import MaybeAwait from .asyncs import MaybeAwait
from .struct import Whois from .struct import Whois
from .params import ConnectionParams, SASLParams, STSPolicy from .params import ConnectionParams, SASLParams, STSPolicy
@ -244,6 +245,17 @@ class Server(IServer):
channels = await fut channels = await fut
return channels[0] return channels[0]
return MaybeAwait(_assure) return MaybeAwait(_assure)
def send_part(self, name: str):
fut = self.send(build("PART", [name]))
async def _assure():
line = await self.wait_for(Response(
"PART",
[ParamFolded(name)],
source=Nickname(self.nickname_lower)
))
return
return MaybeAwait(_assure)
def send_joins(self, def send_joins(self,
names: List[str], names: List[str],