From cbf1c3ca2a154bbc7312db3efd644fd4c3400964 Mon Sep 17 00:00:00 2001 From: Joel Rosdahl Date: Thu, 22 Sep 2011 20:50:24 +0200 Subject: Refactor 403 reply into a method --- miniircd | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/miniircd b/miniircd index 5bb08c3..724ea56 100755 --- a/miniircd +++ b/miniircd @@ -186,8 +186,7 @@ class Client(object): if irc_lower(arguments[0]) in self.channels: pass elif not valid_channel_re.match(channelname): - self.reply("403 %s %s :No such channel" - % (self.nickname, channelname)) + self.reply_403(channelname) else: server.add_member_to_channel(self, channelname) channel = server.get_channel(channelname) @@ -246,8 +245,7 @@ class Client(object): else: self.reply("501 %s :Unknown MODE flag" % self.nickname) else: - self.reply("403 %s %s :That channel doesn't exist" - % (self.nickname, targetname)) + self.reply_403(targetname) def motd_handler(): self.send_motd() @@ -311,8 +309,7 @@ class Client(object): partmsg = self.nickname for channelname in arguments[0].split(","): if not valid_channel_re.match(channelname): - self.reply("403 %s %s :No such channel" - % (self.nickname, channelname)) + self.reply_403(channelname) elif not irc_lower(channelname) in self.channels: self.reply("442 %s %s :You're not on that channel" % (self.nickname, channelname)) @@ -467,6 +464,9 @@ class Client(object): def reply(self, msg): self.message(":%s %s" % (self.server.name, msg)) + def reply_403(self, channel): + self.reply("403 %s %s :No such channel" % (self.nickname, channel)) + def reply_461(self, command): nickname = self.nickname or "*" self.reply("461 %s %s :Not enough parameters" % (nickname, command)) -- cgit v1.2.3