summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Rosdahl <joel@rosdahl.net>2011-08-20 23:00:33 +0200
committerJoel Rosdahl <joel@rosdahl.net>2011-08-21 15:57:19 +0200
commit4c4c318024fa2688b31be0abe0a27da86b808bf7 (patch)
tree7863e694299d969c2bc52fbe3cae03e215d6bb42
parent33a59734d80b63630dee8dbab0578a7c18d11bef (diff)
downloadminiircd-4c4c318024fa2688b31be0abe0a27da86b808bf7.tar.gz
miniircd-4c4c318024fa2688b31be0abe0a27da86b808bf7.zip
Refactor 461 reply into a method
-rwxr-xr-xminiircd20
1 files changed, 10 insertions, 10 deletions
diff --git a/miniircd b/miniircd
index bb9bd7b..6cfa6cc 100755
--- a/miniircd
+++ b/miniircd
@@ -123,7 +123,7 @@ class Client(object):
server = self.server
if command == "PASS":
if len(arguments) == 0:
- self.reply("461 * PASS :Not enough parameters")
+ self.reply_461("PASS")
else:
if arguments[0].lower() == server.password:
self.__handle_command = self.__registration_handler
@@ -149,7 +149,7 @@ class Client(object):
server.client_changed_nickname(self, None)
elif command == "USER":
if len(arguments) < 4:
- self.reply("461 * USER :Not enough parameters")
+ self.reply_461("USER")
return
self.user = arguments[0]
self.realname = arguments[3]
@@ -175,8 +175,7 @@ class Client(object):
def join_handler():
if len(arguments) < 1:
- self.reply("461 %s JOIN :Not enough parameters"
- % self.nickname)
+ self.reply_461("JOIN")
return
if arguments[0] == "0":
for channelname, channel in self.channels.items():
@@ -233,8 +232,7 @@ class Client(object):
def mode_handler():
if len(arguments) < 1:
- self.reply("461 %s MODE :Not enough parameters"
- % self.nickname)
+ self.reply_461("MODE")
return
targetname = arguments[0]
channel = server.get_channel(targetname)
@@ -317,8 +315,7 @@ class Client(object):
def part_handler():
if len(arguments) < 1:
- self.reply("461 %s PART :Not enough parameters"
- % self.nickname)
+ self.reply_461("PART")
return
if len(arguments) > 1:
partmsg = arguments[1]
@@ -361,8 +358,7 @@ class Client(object):
def topic_handler():
if len(arguments) < 1:
- self.reply("461 %s TOPIC :Not enough parameters"
- % self.nickname)
+ self.reply_461("TOPIC")
return
channelname = arguments[0]
if channelname in self.channels:
@@ -488,6 +484,10 @@ class Client(object):
def reply(self, msg):
self.message(":%s %s" % (self.server.name, msg))
+ def reply_461(self, command):
+ nickname = self.nickname or "*"
+ self.reply("461 %s %s :Not enough parameters" % (nickname, command))
+
def message_channel(self, channel, line, include_self=False):
for client in channel.members:
if client != self or include_self: