diff options
author | Joel Rosdahl <joel@rosdahl.net> | 2011-09-22 20:50:24 +0200 |
---|---|---|
committer | Joel Rosdahl <joel@rosdahl.net> | 2011-09-22 20:50:24 +0200 |
commit | cbf1c3ca2a154bbc7312db3efd644fd4c3400964 (patch) | |
tree | 58209dd3ddb0952f92c61aa60697879263d4962e | |
parent | 2a47cbb0cb6bdf6e2b7e5d29b015d94d2587aca7 (diff) | |
download | miniircd-cbf1c3ca2a154bbc7312db3efd644fd4c3400964.tar.gz miniircd-cbf1c3ca2a154bbc7312db3efd644fd4c3400964.zip |
Refactor 403 reply into a method
-rwxr-xr-x | miniircd | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -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)) |