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.
 

28 lines
897 B

from paircd.client import Client
from paircd.command_handler import CommandHandler
from paircd.message import Message
from paircd.reply import NOTICE
from paircd.server import Server
class NoticeHandler(CommandHandler):
def __init__(self) -> None:
super().__init__("NOTICE", 2)
async def handle(self, server: Server, client: Client, msg: Message) -> None:
recipient, raw_msg = msg.args
if len(raw_msg) == 0:
return
out = NOTICE(recipient, raw_msg, prefix=client.id())
# Directly message a user
if recipient in server.clients_by_nick:
other_client = server.clients_by_nick[recipient]
other_client.write_message(out)
return
# Broadcast to channel
if recipient in server.channels_by_name:
server.channels_by_name[recipient].write_message(out)
return