|
|
@ -0,0 +1,28 @@ |
|
|
|
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 |