add send_message() - optionally await echo
This commit is contained in:
parent
9d4572edcc
commit
04354c7d36
1 changed files with 14 additions and 0 deletions
|
@ -399,6 +399,20 @@ class Server(IServer):
|
||||||
return channels
|
return channels
|
||||||
return MaybeAwait(_assure)
|
return MaybeAwait(_assure)
|
||||||
|
|
||||||
|
def send_message(self, target: str, message: str
|
||||||
|
) -> Awaitable[Optional[str]]:
|
||||||
|
fut = self.send(build("PRIVMSG", [target, message]))
|
||||||
|
async def _assure():
|
||||||
|
await fut
|
||||||
|
line = await self.wait_for(
|
||||||
|
Response("PRIVMSG", [Folded(target), ANY], source=MASK_SELF)
|
||||||
|
)
|
||||||
|
if line.command == "PRIVMSG":
|
||||||
|
return line.params[1]
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
return MaybeAwait(_assure)
|
||||||
|
|
||||||
def send_whois(self, target: str) -> Awaitable[Whois]:
|
def send_whois(self, target: str) -> Awaitable[Whois]:
|
||||||
folded = self.casefold(target)
|
folded = self.casefold(target)
|
||||||
fut = self.send(build("WHOIS", [target, target]))
|
fut = self.send(build("WHOIS", [target, target]))
|
||||||
|
|
Loading…
Reference in a new issue