|
@ -2,7 +2,6 @@ import logging |
|
|
|
|
|
|
|
|
from paircd.client import Client |
|
|
from paircd.client import Client |
|
|
from paircd.command_handler import CommandHandler |
|
|
from paircd.command_handler import CommandHandler |
|
|
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 |
|
|
|
|
|
|
|
@ -13,20 +12,20 @@ class JoinHandler(CommandHandler): |
|
|
|
|
|
|
|
|
async def handle(self, server: Server, client: Client, msg: Message) -> None: |
|
|
async def handle(self, server: Server, client: Client, msg: Message) -> None: |
|
|
if not client.registered: |
|
|
if not client.registered: |
|
|
log_client(client, "join: not registered", level=logging.WARN) |
|
|
|
|
|
|
|
|
client.log("join: not registered", level=logging.WARN) |
|
|
return |
|
|
return |
|
|
|
|
|
|
|
|
channel_name = msg.args[0] |
|
|
channel_name = msg.args[0] |
|
|
if not channel_name.startswith("#"): |
|
|
if not channel_name.startswith("#"): |
|
|
log_client(client, "tried to join invalid channel", level=logging.WARN) |
|
|
|
|
|
|
|
|
client.log("tried to join invalid channel", level=logging.WARN) |
|
|
return |
|
|
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) |
|
|
log_client(client, f"joined {channel_name}") |
|
|
|
|
|
|
|
|
client.log(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()) |
|
|
) |
|
|
) |