Create functions for is_voiced and is_oper checks
In order to be able to easily mock voice and oper checks, create specific functions that implement those checks. Change-Id: I6250c0d181085ff39d6ff0dae95c700dbeb931a3
This commit is contained in:
parent
df17b77f7e
commit
6bf2598db6
@ -264,6 +264,13 @@ class PTGBot(SASL, SSL, irc.bot.SingleServerIRCBot):
|
|||||||
"Cancelled subscription %s" % existing_re
|
"Cancelled subscription %s" % existing_re
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def is_chanop(self, nick, chan):
|
||||||
|
return self.channels[chan].is_oper(nick)
|
||||||
|
|
||||||
|
def is_voiced(self, nick, chan):
|
||||||
|
return (self.channels[chan].is_voiced(nick) or
|
||||||
|
self.channels[chan].is_oper(nick))
|
||||||
|
|
||||||
@make_safe
|
@make_safe
|
||||||
def on_pubmsg(self, c, e):
|
def on_pubmsg(self, c, e):
|
||||||
if not self.identify_msg_cap:
|
if not self.identify_msg_cap:
|
||||||
@ -295,9 +302,8 @@ class PTGBot(SASL, SSL, irc.bot.SingleServerIRCBot):
|
|||||||
self.unsubscribe(chan, nick)
|
self.unsubscribe(chan, nick)
|
||||||
return
|
return
|
||||||
|
|
||||||
if (self.data.is_voice_required() and not
|
if (self.data.is_voice_required() and
|
||||||
(self.channels[chan].is_voiced(nick) or
|
not self.is_voiced(nick, chan)):
|
||||||
self.channels[chan].is_oper(nick))):
|
|
||||||
self.send(chan, "%s: Need voice to issue commands" % (nick,))
|
self.send(chan, "%s: Need voice to issue commands" % (nick,))
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -367,7 +373,7 @@ class PTGBot(SASL, SSL, irc.bot.SingleServerIRCBot):
|
|||||||
"scheduled today." % (nick, track))
|
"scheduled today." % (nick, track))
|
||||||
|
|
||||||
if msg.startswith('~'):
|
if msg.startswith('~'):
|
||||||
if not self.channels[chan].is_oper(nick):
|
if not self.is_chanop(nick, chan):
|
||||||
self.send(chan, "%s: Need op for admin commands" % (nick,))
|
self.send(chan, "%s: Need op for admin commands" % (nick,))
|
||||||
return
|
return
|
||||||
words = msg.split()
|
words = msg.split()
|
||||||
|
Loading…
Reference in New Issue
Block a user