New method send_msg_verified that checks the user is on the message destination channel

This commit is contained in:
Némunaire 2012-07-20 03:24:51 +02:00
parent 1f5127e921
commit 05cf740151
2 changed files with 8 additions and 4 deletions

View File

@ -86,7 +86,7 @@ class Message:
def send_msg (self, channel, msg, cmd = "PRIVMSG", endl = "\r\n"):
if CREDITS[self.realname].speak():
self.srv.send_msg (channel, msg, cmd, endl)
self.srv.send_msg_verified (self.sender, channel, msg, cmd, endl)
def send_global (self, msg, cmd = "PRIVMSG", endl = "\r\n"):
if CREDITS[self.realname].speak():

View File

@ -98,16 +98,20 @@ class Server(threading.Thread):
if self.accepted_channel(channel):
self.send_msg_final(channel, msg, cmd, endl)
def send_msg_verified (self, sender, channel, msg, cmd = "PRIVMSG", endl = "\r\n"):
if self.accepted_channel(channel, sender):
self.send_msg_final(channel, msg, cmd, endl)
def send_global (self, msg, cmd = "PRIVMSG", endl = "\r\n"):
for channel in self.channels.keys():
self.send_msg (channel, msg, cmd, endl)
def accepted_channel(self, chan):
def accepted_channel(self, chan, sender = None):
if self.listen_nick:
return chan in self.channels or chan == self.nick
return (chan in self.channels and (sender is None or sender in self.channels[chan].people)) or chan == self.nick
else:
return chan in self.channels
return chan in self.channels and (sender is None or sender in self.channels[chan].people)
def disconnect(self):
if self.connected: