Browse Source

Simplify PRIVMSG handling

master
Forest Belton 3 years ago
parent
commit
2e598c442c
1 changed files with 14 additions and 12 deletions
  1. +14
    -12
      paircd/handler/privmsg.py

+ 14
- 12
paircd/handler/privmsg.py View File

@ -22,18 +22,20 @@ class PrivmsgHandler(CommandHandler):
return return
out = PRIVMSG(recipient, raw_msg, prefix=client.id()) out = PRIVMSG(recipient, raw_msg, prefix=client.id())
for name, other_client in server.clients_by_nick.items():
if name == recipient:
if other_client.away:
client.write_message(
RPL_AWAY(client.nickname, name, other_client.away)
)
other_client.write_message(out)
return
for name, channel in server.channels_by_name.items():
if name == recipient:
channel.write_message(out)
return
# Directly message a user
if recipient in server.clients_by_nick:
other_client = server.clients_by_nick[recipient]
if other_client.away:
client.write_message(
RPL_AWAY(client.nickname, recipient, other_client.away)
)
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
client.write_message(ERR_NOSUCHNICK(client.nickname, recipient)) client.write_message(ERR_NOSUCHNICK(client.nickname, recipient))

Loading…
Cancel
Save