New method send_msg_verified that checks the user is on the message destination channel
This commit is contained in:
parent
1f5127e921
commit
05cf740151
@ -86,7 +86,7 @@ class Message:
|
|||||||
|
|
||||||
def send_msg (self, channel, msg, cmd = "PRIVMSG", endl = "\r\n"):
|
def send_msg (self, channel, msg, cmd = "PRIVMSG", endl = "\r\n"):
|
||||||
if CREDITS[self.realname].speak():
|
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"):
|
def send_global (self, msg, cmd = "PRIVMSG", endl = "\r\n"):
|
||||||
if CREDITS[self.realname].speak():
|
if CREDITS[self.realname].speak():
|
||||||
|
10
server.py
10
server.py
@ -98,16 +98,20 @@ class Server(threading.Thread):
|
|||||||
if self.accepted_channel(channel):
|
if self.accepted_channel(channel):
|
||||||
self.send_msg_final(channel, msg, cmd, endl)
|
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"):
|
def send_global (self, msg, cmd = "PRIVMSG", endl = "\r\n"):
|
||||||
for channel in self.channels.keys():
|
for channel in self.channels.keys():
|
||||||
self.send_msg (channel, msg, cmd, endl)
|
self.send_msg (channel, msg, cmd, endl)
|
||||||
|
|
||||||
|
|
||||||
def accepted_channel(self, chan):
|
def accepted_channel(self, chan, sender = None):
|
||||||
if self.listen_nick:
|
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:
|
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):
|
def disconnect(self):
|
||||||
if self.connected:
|
if self.connected:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user