From 6af1f8607f67bb97739bad024bd293b5b9f85e80 Mon Sep 17 00:00:00 2001 From: Forest Belton Date: Tue, 22 Jun 2021 04:04:36 -0400 Subject: [PATCH] Implement AWAY command --- paircd/handler/away.py | 18 ++++++++++++++++++ paircd/handlers.py | 2 ++ 2 files changed, 20 insertions(+) create mode 100644 paircd/handler/away.py diff --git a/paircd/handler/away.py b/paircd/handler/away.py new file mode 100644 index 0000000..80775ca --- /dev/null +++ b/paircd/handler/away.py @@ -0,0 +1,18 @@ +from paircd.client import Client +from paircd.command_handler import CommandHandler +from paircd.message import Message +from paircd.reply import RPL_NOWAWAY, RPL_UNAWAY +from paircd.server import Server + + +class AwayHandler(CommandHandler): + def __init__(self) -> None: + super().__init__("AWAY") + + async def handle(self, server: Server, client: Client, msg: Message) -> None: + if len(msg.args) == 0 or len(msg.args[0]) == 0: + client.away = "" + client.write_message(RPL_UNAWAY(client.nickname)) + else: + client.away = msg.args[0] + client.write_message(RPL_NOWAWAY(client.nickname)) \ No newline at end of file diff --git a/paircd/handlers.py b/paircd/handlers.py index 5ca0cba..1985d23 100644 --- a/paircd/handlers.py +++ b/paircd/handlers.py @@ -1,4 +1,5 @@ from logging import WARN +from paircd.handler.away import AwayHandler from typing import Dict from paircd.client import Client @@ -15,6 +16,7 @@ from paircd.handler.user import UserHandler from paircd.handler.who import WhoHandler HANDLER_CLASSES = [ + AwayHandler, JoinHandler, ModeHandler, NickHandler,