python ircd using asyncio
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

22 lines
699 B

from paircd.client import Client
from paircd.message import Message
from paircd.server import Server
async def handle_privmsg(server: Server, client: Client, msg: Message) -> None:
recipient = msg.args[0]
raw_msg = msg.args[1]
msg = Message("PRIVMSG", [recipient, f":{raw_msg}"], prefix=client.id()).encode()
for name, other_client in server.clients_by_nick.items():
if name == recipient:
other_client.msg_queue.put_nowait(msg)
return
for name, channel in server.channels_by_name.items():
if name == recipient:
channel.msg_queue.put_nowait(msg)
return
raise RuntimeError(f"Unknown recipient {recipient}")