Notification message for when bot fails to get op
This commit is contained in:
parent
5002195005
commit
7774890027
|
@ -534,9 +534,9 @@ class Bantracker(callbacks.Plugin):
|
||||||
|
|
||||||
# add our scheduled events for check bans for reviews or removal
|
# add our scheduled events for check bans for reviews or removal
|
||||||
schedule.addPeriodicEvent(lambda: self.reviewBans(irc), 60*60,
|
schedule.addPeriodicEvent(lambda: self.reviewBans(irc), 60*60,
|
||||||
name=self.name() + '_review')
|
'Bantracker_review')
|
||||||
schedule.addPeriodicEvent(lambda: self.autoRemoveBans(irc), 600,
|
schedule.addPeriodicEvent(lambda: self.autoRemoveBans(irc), 600,
|
||||||
name=self.name() + '_autoremove')
|
'Bantracker_autoremove')
|
||||||
|
|
||||||
def get_nicks(self, irc):
|
def get_nicks(self, irc):
|
||||||
self.hosts.clear()
|
self.hosts.clear()
|
||||||
|
@ -896,6 +896,19 @@ class Bantracker(callbacks.Plugin):
|
||||||
def getOp(self, irc, channel):
|
def getOp(self, irc, channel):
|
||||||
msg = ircmsgs.privmsg('Chanserv', "op %s %s" % (channel, irc.nick))
|
msg = ircmsgs.privmsg('Chanserv', "op %s %s" % (channel, irc.nick))
|
||||||
irc.queueMsg(msg)
|
irc.queueMsg(msg)
|
||||||
|
schedule.addEvent(lambda: self._getOpFail(irc, channel), 60,
|
||||||
|
'Bantracker_getop_%s' % channel)
|
||||||
|
|
||||||
|
def _getOpFail(self, irc, channel):
|
||||||
|
for c in self.registryValue('autoremove.notify.channels', channel):
|
||||||
|
notice = ircmsgs.notice(c, "Failed to get op in %s" % channel)
|
||||||
|
irc.queueMsg(notice)
|
||||||
|
|
||||||
|
def _getOpOK(self, channel):
|
||||||
|
try:
|
||||||
|
schedule.removeEvent('Bantracker_getop_%s' % channel)
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
def removeBans(self, irc, channel, modes, deop=False):
|
def removeBans(self, irc, channel, modes, deop=False):
|
||||||
# send unban messages, with 4 modes max each.
|
# send unban messages, with 4 modes max each.
|
||||||
|
@ -1096,6 +1109,7 @@ class Bantracker(callbacks.Plugin):
|
||||||
if ircutils.nickEqual(irc.nick, param[1]):
|
if ircutils.nickEqual(irc.nick, param[1]):
|
||||||
opped = self.opped[channel] = mode[0] == '+'
|
opped = self.opped[channel] = mode[0] == '+'
|
||||||
if opped == True:
|
if opped == True:
|
||||||
|
self._getOpOK(channel)
|
||||||
# check if we have bans to remove
|
# check if we have bans to remove
|
||||||
if channel in self.pendingBanremoval:
|
if channel in self.pendingBanremoval:
|
||||||
modes = self.pendingBanremoval.pop(channel)
|
modes = self.pendingBanremoval.pop(channel)
|
||||||
|
|
|
@ -507,7 +507,7 @@ class BantrackerTestCase(ChannelPluginTestCase):
|
||||||
cb = self.getCallback()
|
cb = self.getCallback()
|
||||||
self.feedBan('asd!*@*')
|
self.feedBan('asd!*@*')
|
||||||
self.assertNotError('duration 1 300')
|
self.assertNotError('duration 1 300')
|
||||||
pluginConf.autoremove.notify.channels().append('#test')
|
pluginConf.autoremove.notify.channels.set('#test')
|
||||||
try:
|
try:
|
||||||
cb.autoRemoveBans(self.irc)
|
cb.autoRemoveBans(self.irc)
|
||||||
msg = self.irc.takeMsg()
|
msg = self.irc.takeMsg()
|
||||||
|
@ -518,7 +518,7 @@ class BantrackerTestCase(ChannelPluginTestCase):
|
||||||
cb.autoRemoveBans(self.irc)
|
cb.autoRemoveBans(self.irc)
|
||||||
self.assertFalse(self.irc.takeMsg())
|
self.assertFalse(self.irc.takeMsg())
|
||||||
finally:
|
finally:
|
||||||
del pluginConf.autoremove.notify.channels()[:]
|
pluginConf.autoremove.notify.channels.set('')
|
||||||
|
|
||||||
def testAutoremoveStore(self):
|
def testAutoremoveStore(self):
|
||||||
self.feedBan('asd!*@*')
|
self.feedBan('asd!*@*')
|
||||||
|
@ -579,7 +579,7 @@ class BantrackerTestCase(ChannelPluginTestCase):
|
||||||
def testOpDuration(self):
|
def testOpDuration(self):
|
||||||
cb = self.getCallback()
|
cb = self.getCallback()
|
||||||
self.feedBan('asd!*@*')
|
self.feedBan('asd!*@*')
|
||||||
self.assertResponse('duration 1 1', "1 will be removed soon.")
|
self.assertNotError('duration 1 1')
|
||||||
print 'waiting 2 secs ...'
|
print 'waiting 2 secs ...'
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
cb.autoRemoveBans(self.irc)
|
cb.autoRemoveBans(self.irc)
|
||||||
|
@ -589,5 +589,27 @@ class BantrackerTestCase(ChannelPluginTestCase):
|
||||||
msg = self.irc.takeMsg() # unban msg
|
msg = self.irc.takeMsg() # unban msg
|
||||||
self.assertEqual(str(msg).strip(), "MODE #test -bo asd!*@* :test")
|
self.assertEqual(str(msg).strip(), "MODE #test -bo asd!*@* :test")
|
||||||
|
|
||||||
|
def testOpFail(self):
|
||||||
|
import supybot.drivers as drivers
|
||||||
|
import supybot.schedule as schedule
|
||||||
|
|
||||||
|
pluginConf.autoremove.notify.channels.set('#test')
|
||||||
|
try:
|
||||||
|
cb = self.getCallback()
|
||||||
|
self.feedBan('asd!*@*')
|
||||||
|
self.assertNotError('duration 1 1')
|
||||||
|
print 'waiting 4 secs ...'
|
||||||
|
time.sleep(2)
|
||||||
|
cb.autoRemoveBans(self.irc)
|
||||||
|
msg = self.irc.takeMsg() # op msg
|
||||||
|
self.assertEqual(str(msg).strip(), "PRIVMSG Chanserv :op #test test")
|
||||||
|
schedule.rescheduleEvent('Bantracker_getop_#test', 1)
|
||||||
|
time.sleep(2)
|
||||||
|
drivers.run()
|
||||||
|
msg = self.irc.takeMsg() # fail msg
|
||||||
|
self.assertEqual(str(msg).strip(),
|
||||||
|
"NOTICE #test :Failed to get op in #test")
|
||||||
|
finally:
|
||||||
|
pluginConf.autoremove.notify.channels.set('')
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue