Browse Source

Implement AWAY command

master
Forest Belton 2 years ago
parent
commit
6af1f8607f
2 changed files with 20 additions and 0 deletions
  1. +18
    -0
      paircd/handler/away.py
  2. +2
    -0
      paircd/handlers.py

+ 18
- 0
paircd/handler/away.py View File

@ -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))

+ 2
- 0
paircd/handlers.py View File

@ -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,

Loading…
Cancel
Save