|
@ -3,23 +3,26 @@ import logging |
|
|
|
|
|
|
|
|
from paircd.channel import Channel |
|
|
from paircd.channel import Channel |
|
|
from paircd.client import Client |
|
|
from paircd.client import Client |
|
|
|
|
|
from paircd.log import log_client |
|
|
from paircd.message import Message |
|
|
from paircd.message import Message |
|
|
from paircd.server import Server |
|
|
from paircd.server import Server |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async def handle_join(server: Server, client: Client, msg: Message) -> None: |
|
|
async def handle_join(server: Server, client: Client, msg: Message) -> None: |
|
|
channel_name = msg.args[0] |
|
|
|
|
|
if not client.registered: |
|
|
if not client.registered: |
|
|
raise RuntimeError("JOIN: not registered") |
|
|
|
|
|
|
|
|
log_client(client, "join: not registered", level=logging.WARN) |
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
channel_name = msg.args[0] |
|
|
if not channel_name.startswith("#"): |
|
|
if not channel_name.startswith("#"): |
|
|
raise RuntimeError("invalid channel name") |
|
|
|
|
|
|
|
|
log_client(client, "tried to join invalid channel", level=logging.WARN) |
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
channel = server.get_channel_by_name(channel_name) |
|
|
channel = server.get_channel_by_name(channel_name) |
|
|
channel.add_client(client) |
|
|
channel.add_client(client) |
|
|
|
|
|
|
|
|
client.channels.add(channel_name) |
|
|
client.channels.add(channel_name) |
|
|
logging.info(f"{client.hostname} ({client.id()}) joined {channel_name}") |
|
|
|
|
|
|
|
|
log_client(client, f"joined {channel_name}") |
|
|
|
|
|
|
|
|
await channel.msg_queue.put( |
|
|
await channel.msg_queue.put( |
|
|
Message(cmd="JOIN", args=[channel_name], prefix=client.id()).encode() |
|
|
Message(cmd="JOIN", args=[channel_name], prefix=client.id()).encode() |
|
|