2010-05-24 13:38:06 +00:00
|
|
|
# -*- Encoding: utf-8 -*-
|
|
|
|
###
|
|
|
|
# Copyright (c) 2008-2010 Terence Simpson
|
|
|
|
# Copyright (c) 2010 Elián Hanisch
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of version 2 of the GNU General Public License as
|
|
|
|
# published by the Free Software Foundation.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
###
|
|
|
|
|
2006-06-26 17:57:20 +00:00
|
|
|
from supybot.test import *
|
|
|
|
|
2010-03-30 20:13:51 +00:00
|
|
|
import supybot.conf as conf
|
|
|
|
import supybot.ircmsgs as ircmsgs
|
2010-04-04 04:31:15 +00:00
|
|
|
import supybot.world as world
|
2010-03-30 20:13:51 +00:00
|
|
|
|
2012-06-25 22:35:42 +00:00
|
|
|
import re
|
2010-03-30 20:13:51 +00:00
|
|
|
import time
|
|
|
|
|
|
|
|
|
2010-04-01 19:34:59 +00:00
|
|
|
pluginConf = conf.supybot.plugins.Bantracker
|
|
|
|
pluginConf.enabled.setValue(True)
|
|
|
|
pluginConf.bansite.setValue('http://foo.bar.com')
|
|
|
|
pluginConf.database.setValue('bantracker-test.db')
|
2010-03-30 20:13:51 +00:00
|
|
|
|
2010-04-01 19:34:59 +00:00
|
|
|
def quiet(channel, hostmask, prefix='', msg=None):
|
|
|
|
"""Returns a MODE to quiet nick on channel."""
|
|
|
|
return ircmsgs.mode(channel, ('+q', hostmask), prefix, msg)
|
2010-03-30 20:13:51 +00:00
|
|
|
|
|
|
|
class BantrackerTestCase(ChannelPluginTestCase):
|
2006-06-26 17:57:20 +00:00
|
|
|
plugins = ('Bantracker',)
|
2010-03-30 20:13:51 +00:00
|
|
|
|
2010-04-01 19:34:59 +00:00
|
|
|
def setUp(self):
|
2010-04-13 00:41:14 +00:00
|
|
|
self.setDb()
|
2010-04-01 19:34:59 +00:00
|
|
|
super(BantrackerTestCase, self).setUp()
|
2010-04-03 23:06:29 +00:00
|
|
|
pluginConf.request.setValue(False) # disable comments
|
|
|
|
pluginConf.request.ignore.set('')
|
2010-04-03 03:17:26 +00:00
|
|
|
pluginConf.request.forward.set('')
|
2011-05-29 22:22:34 +00:00
|
|
|
pluginConf.review.setValue(False) # disable reviews
|
|
|
|
pluginConf.review.when.setValue(1.0/86400) # one second
|
|
|
|
pluginConf.review.ignore.set('')
|
|
|
|
pluginConf.review.forward.set('')
|
2010-04-04 04:31:15 +00:00
|
|
|
# Bantracker for some reason doesn't use Supybot's own methods for check capabilities,
|
|
|
|
# so it doesn't have a clue about testing and screws my tests by default.
|
|
|
|
# This would fix it until I bring myself to take a look
|
|
|
|
cb = self.getCallback()
|
|
|
|
f = cb.check_auth
|
|
|
|
def test_check_auth(*args, **kwargs):
|
|
|
|
if world.testing:
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
return f(*args, **kwargs)
|
|
|
|
cb.check_auth = test_check_auth
|
2012-08-26 00:24:20 +00:00
|
|
|
cb.opped.clear()
|
2010-04-01 19:34:59 +00:00
|
|
|
|
|
|
|
def setDb(self):
|
|
|
|
import sqlite, os
|
|
|
|
dbfile = os.path.join(os.curdir, pluginConf.database())
|
|
|
|
try:
|
|
|
|
os.remove(dbfile)
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
db = sqlite.connect(dbfile)
|
|
|
|
cursor = db.cursor()
|
|
|
|
cursor.execute('CREATE TABLE bans ('
|
|
|
|
'id INTEGER PRIMARY KEY,'
|
|
|
|
'channel VARCHAR(30) NOT NULL,'
|
|
|
|
'mask VARCHAR(100) NOT NULL,'
|
|
|
|
'operator VARCHAR(30) NOT NULL,'
|
|
|
|
'time VARCHAR(300) NOT NULL,'
|
|
|
|
'removal DATETIME,'
|
|
|
|
'removal_op VARCHAR(30),'
|
|
|
|
'log TEXT)')
|
|
|
|
cursor.execute('CREATE TABLE comments ('
|
|
|
|
'ban_id INTEGER,'
|
|
|
|
'who VARCHAR(100) NOT NULL,'
|
|
|
|
'comment MEDIUMTEXT NOT NULL,'
|
|
|
|
'time VARCHAR(300) NOT NULL)')
|
|
|
|
cursor.execute('CREATE TABLE sessions ('
|
|
|
|
'session_id VARCHAR(50) PRIMARY KEY,'
|
|
|
|
'user MEDIUMTEXT NOT NULL,'
|
|
|
|
'time INT NOT NULL)')
|
|
|
|
cursor.execute('CREATE TABLE users ('
|
|
|
|
'username VARCHAR(50) PRIMARY KEY,'
|
|
|
|
'salt VARCHAR(8),'
|
|
|
|
'password VARCHAR(50))')
|
|
|
|
db.commit()
|
|
|
|
cursor.close()
|
|
|
|
db.close()
|
|
|
|
|
2010-03-30 20:13:51 +00:00
|
|
|
def getCallback(self):
|
|
|
|
for cb in self.irc.callbacks:
|
|
|
|
if cb.name() == 'Bantracker':
|
|
|
|
break
|
|
|
|
return cb
|
|
|
|
|
2010-04-01 19:34:59 +00:00
|
|
|
def getDb(self):
|
|
|
|
return self.getCallback().db
|
|
|
|
|
|
|
|
def query(self, query, parms=()):
|
|
|
|
cursor = self.getDb().cursor()
|
|
|
|
cursor.execute(query, parms)
|
|
|
|
return cursor.fetchall()
|
|
|
|
|
|
|
|
def feedBan(self, hostmask, prefix='', channel=None, mode='b'):
|
|
|
|
if not channel:
|
|
|
|
channel = self.channel
|
|
|
|
if not prefix:
|
|
|
|
prefix = 'op!user@host.net'
|
|
|
|
if mode == 'b':
|
|
|
|
ban = ircmsgs.ban(channel, hostmask, prefix=prefix)
|
|
|
|
elif mode == 'q':
|
|
|
|
ban = quiet(channel, hostmask, prefix=prefix)
|
2010-04-03 03:17:26 +00:00
|
|
|
elif mode == 'k':
|
|
|
|
ban = ircmsgs.kick(channel, hostmask, s='kthxbye!', prefix=prefix)
|
|
|
|
elif mode == 'p':
|
|
|
|
ban = ircmsgs.part(channel, prefix=hostmask,
|
|
|
|
s='requested by %s (kthxbye!)' %prefix[:prefix.find('!')])
|
2010-03-30 20:13:51 +00:00
|
|
|
self.irc.feedMsg(ban)
|
2010-04-03 03:17:26 +00:00
|
|
|
return ban
|
2010-04-01 19:34:59 +00:00
|
|
|
|
2012-08-18 14:27:50 +00:00
|
|
|
def op(self):
|
|
|
|
msg = ircmsgs.mode(self.channel, ('+o', self.irc.nick),
|
|
|
|
'Chanserv!service@service')
|
|
|
|
self.irc.feedMsg(msg)
|
|
|
|
|
|
|
|
def deop(self):
|
|
|
|
msg = ircmsgs.mode(self.channel, ('-o', self.irc.nick),
|
|
|
|
'Chanserv!service@service')
|
|
|
|
self.irc.feedMsg(msg)
|
|
|
|
|
2010-04-03 04:44:57 +00:00
|
|
|
def testComment(self):
|
2012-07-27 03:50:25 +00:00
|
|
|
self.assertResponse('comment 1', "I don't know any ban with id 1.")
|
|
|
|
self.feedBan('asd!*@*')
|
|
|
|
self.assertResponse('comment 1', 'No comments recorded for ban 1')
|
2012-07-28 00:44:29 +00:00
|
|
|
self.assertResponse('comment 1 this is a test',
|
2012-07-30 02:36:18 +00:00
|
|
|
'Comment added.')
|
2012-07-27 03:50:25 +00:00
|
|
|
self.assertRegexp('comment 1', 'test: this is a test$')
|
2012-07-28 00:08:25 +00:00
|
|
|
self.assertResponse('comment 1 this is a test, another test',
|
2012-07-30 02:36:18 +00:00
|
|
|
'Comment added.')
|
2012-07-28 00:44:29 +00:00
|
|
|
self.feedBan('nick', mode='k')
|
|
|
|
self.assertResponse('comment 2 this is a kick, 2week',
|
2012-07-30 02:36:18 +00:00
|
|
|
"Failed to set duration time on 2 (not a ban or quiet)")
|
|
|
|
msg = self.irc.takeMsg()
|
|
|
|
self.assertEqual(msg.args[1], 'test: Comment added.')
|
2012-07-28 02:12:35 +00:00
|
|
|
self.assertResponse('comment 1 not a valid, duration 2',
|
2012-07-30 02:36:18 +00:00
|
|
|
'Comment added.')
|
2012-07-27 03:50:25 +00:00
|
|
|
|
|
|
|
def testMultiComment(self):
|
|
|
|
self.feedBan('asd!*@*')
|
|
|
|
self.feedBan('qwe!*@*')
|
2012-07-30 02:36:18 +00:00
|
|
|
self.assertResponse('comment 1,2,3 this is a test, 2 days',
|
2012-07-27 03:50:25 +00:00
|
|
|
"I don't know any ban with id 3.")
|
|
|
|
msg = self.irc.takeMsg()
|
2012-07-30 02:36:18 +00:00
|
|
|
self.assertEqual(msg.args[1],
|
|
|
|
"test: Comment added. 1 and 2 will be removed after 2 days.")
|
|
|
|
self.assertRegexp('comment 1,2', 'test: this is a test, 2 days$')
|
2012-07-27 03:50:25 +00:00
|
|
|
msg = self.irc.takeMsg()
|
2012-07-30 02:36:18 +00:00
|
|
|
self.assertTrue(msg.args[1].endswith("test: this is a test, 2 days"))
|
2012-07-27 03:50:25 +00:00
|
|
|
|
|
|
|
def testCommentDuration(self):
|
|
|
|
self.feedBan('asd!*@*')
|
2012-07-28 00:44:29 +00:00
|
|
|
self.assertResponse('comment 1 this is a test, 1 week 10',
|
2012-07-30 02:36:18 +00:00
|
|
|
'Comment added. 1 will be removed after 1 week.')
|
2012-07-27 03:50:25 +00:00
|
|
|
self.assertRegexp('comment 1', 'test: this is a test, 1 week 10$')
|
2012-07-27 22:21:21 +00:00
|
|
|
self.assertRegexp('duration 1', 'expires in 1 week$')
|
2012-07-27 03:50:25 +00:00
|
|
|
|
2012-08-03 14:46:17 +00:00
|
|
|
def testCommentDurationRemove(self):
|
|
|
|
self.feedBan('asd!*@*')
|
|
|
|
self.assertResponse('comment 1 this is a test, -10',
|
|
|
|
"Failed to set duration time on 1 (ban isn't marked for removal)")
|
|
|
|
msg = self.irc.takeMsg()
|
|
|
|
self.assertEqual(msg.args[1], 'test: Comment added.')
|
|
|
|
self.assertResponse('comment 1 this is a test, 10',
|
|
|
|
'Comment added. 1 will be removed soon.')
|
|
|
|
self.assertResponse('comment 1 this is a test, -10',
|
|
|
|
"Comment added. 1 won't expire.")
|
|
|
|
self.assertRegexp('duration 1', 'never expires$')
|
|
|
|
|
2012-07-27 03:50:25 +00:00
|
|
|
def testCommentRequest(self):
|
2010-04-03 23:06:29 +00:00
|
|
|
pluginConf.request.setValue(True)
|
2010-04-01 19:34:59 +00:00
|
|
|
# test bans
|
|
|
|
self.feedBan('asd!*@*')
|
2010-03-30 20:13:51 +00:00
|
|
|
msg = self.irc.takeMsg()
|
|
|
|
self.assertEqual(str(msg).strip(),
|
2010-04-01 19:34:59 +00:00
|
|
|
"PRIVMSG op :Please comment on the ban of asd!*@* in #test, use: @comment 1"
|
|
|
|
" <comment>")
|
|
|
|
# test quiets
|
|
|
|
self.feedBan('dude!*@*', mode='q')
|
|
|
|
msg = self.irc.takeMsg()
|
|
|
|
self.assertEqual(str(msg).strip(),
|
|
|
|
"PRIVMSG op :Please comment on the quiet of dude!*@* in #test, use: @comment 2"
|
2010-03-30 20:13:51 +00:00
|
|
|
" <comment>")
|
2010-04-03 03:17:26 +00:00
|
|
|
# test kick/part
|
|
|
|
self.feedBan('dude', mode='k')
|
|
|
|
msg = self.irc.takeMsg()
|
|
|
|
self.assertEqual(str(msg).strip(),
|
|
|
|
"PRIVMSG op :Please comment on the removal of dude in #test, use: @comment 3"
|
|
|
|
" <comment>")
|
2010-04-13 00:33:15 +00:00
|
|
|
self.feedBan('dude!dude@trollpit.com', mode='p')
|
2010-04-03 03:17:26 +00:00
|
|
|
msg = self.irc.takeMsg()
|
|
|
|
self.assertEqual(str(msg).strip(),
|
|
|
|
"PRIVMSG op :Please comment on the removal of dude in #test, use: @comment 4"
|
|
|
|
" <comment>")
|
2010-04-03 04:44:57 +00:00
|
|
|
|
2010-04-13 02:02:07 +00:00
|
|
|
def testCommentIgnore(self):
|
|
|
|
pluginConf.request.setValue(True)
|
|
|
|
pluginConf.request.ignore.set('FloodBot? FloodBotK?')
|
|
|
|
self.feedBan('asd!*@*', prefix='floodbotk1!bot@botpit.com')
|
|
|
|
msg = self.irc.takeMsg()
|
|
|
|
self.assertEqual(msg, None)
|
|
|
|
self.feedBan('dude!*@*', mode='q', prefix='FloodBot1!bot@botpit.com')
|
|
|
|
msg = self.irc.takeMsg()
|
|
|
|
self.assertEqual(msg, None)
|
|
|
|
self.feedBan('dude', mode='k', prefix='FloodBot2!bot@botbag.com')
|
|
|
|
msg = self.irc.takeMsg()
|
|
|
|
self.assertEqual(msg, None)
|
|
|
|
self.feedBan('dude!dude@trollpit.com', mode='p', prefix='FloodBotK2!bot@botbag.com')
|
|
|
|
msg = self.irc.takeMsg()
|
|
|
|
self.assertEqual(msg, None)
|
|
|
|
self.feedBan('asd!*@*')
|
|
|
|
msg = self.irc.takeMsg()
|
|
|
|
self.assertEqual(str(msg).strip(),
|
|
|
|
"PRIVMSG op :Please comment on the ban of asd!*@* in #test, use: @comment 5"
|
|
|
|
" <comment>")
|
|
|
|
|
2010-04-03 04:44:57 +00:00
|
|
|
def testCommentForward(self):
|
2010-04-03 23:06:29 +00:00
|
|
|
pluginConf.request.setValue(True)
|
2010-04-03 03:17:26 +00:00
|
|
|
pluginConf.request.forward.set('bot')
|
|
|
|
pluginConf.request.forward.channels.set('#channel')
|
|
|
|
self.feedBan('qwe!*@*')
|
|
|
|
msg = self.irc.takeMsg()
|
|
|
|
self.assertEqual(str(msg).strip(),
|
2010-04-03 04:44:57 +00:00
|
|
|
"PRIVMSG op :Please comment on the ban of qwe!*@* in #test, use: @comment 1"
|
2010-04-03 03:17:26 +00:00
|
|
|
" <comment>")
|
|
|
|
self.feedBan('zxc!*@*', prefix='bot!user@host.com')
|
|
|
|
msg = self.irc.takeMsg()
|
|
|
|
self.assertEqual(str(msg).strip(),
|
|
|
|
"NOTICE #channel :Please somebody comment on the ban of zxc!*@* in #test done by bot,"
|
2010-04-03 04:44:57 +00:00
|
|
|
" use: @comment 2 <comment>")
|
2010-03-30 20:13:51 +00:00
|
|
|
|
2010-04-03 04:44:57 +00:00
|
|
|
def testReview(self):
|
2011-05-29 22:22:34 +00:00
|
|
|
pluginConf.review.setValue(True)
|
2010-03-30 20:13:51 +00:00
|
|
|
cb = self.getCallback()
|
2010-04-01 19:34:59 +00:00
|
|
|
self.feedBan('asd!*@*')
|
2010-03-30 20:13:51 +00:00
|
|
|
cb.reviewBans()
|
|
|
|
self.assertFalse(cb.pendingReviews)
|
2010-04-01 20:52:53 +00:00
|
|
|
print 'waiting 4 secs..'
|
2010-03-30 20:13:51 +00:00
|
|
|
time.sleep(2)
|
|
|
|
cb.reviewBans()
|
|
|
|
# check is pending
|
|
|
|
self.assertTrue(cb.pendingReviews)
|
2010-04-01 20:52:53 +00:00
|
|
|
# send msg if a user with a matching host says something
|
|
|
|
self.feedMsg('Hi!', frm='op!user@fakehost.net')
|
2011-05-31 06:39:28 +00:00
|
|
|
self.assertEqual(self.irc.takeMsg(), None)
|
2010-04-01 20:52:53 +00:00
|
|
|
self.feedMsg('Hi!', frm='op_!user@host.net')
|
2011-05-31 06:39:28 +00:00
|
|
|
self.assertEqual(str(self.irc.takeMsg()).strip(),
|
|
|
|
"PRIVMSG op_ :Review: ban 'asd!*@*' set on %s in #test, link: "\
|
|
|
|
"%s/bans.cgi?log=1" %(cb.bans['#test'][0].ascwhen, pluginConf.bansite()))
|
2010-03-30 20:13:51 +00:00
|
|
|
# don't ask again
|
|
|
|
cb.reviewBans()
|
|
|
|
self.assertFalse(cb.pendingReviews)
|
2010-04-04 02:48:54 +00:00
|
|
|
# test again with two ops
|
2010-04-01 20:52:53 +00:00
|
|
|
self.feedBan('asd2!*@*')
|
|
|
|
self.irc.takeMsg()
|
2011-05-31 04:45:05 +00:00
|
|
|
self.feedBan('qwe!*@*', prefix='otherop!user@home.net', mode='q')
|
2010-04-01 20:52:53 +00:00
|
|
|
self.irc.takeMsg()
|
|
|
|
time.sleep(2)
|
|
|
|
cb.reviewBans()
|
|
|
|
self.assertTrue(len(cb.pendingReviews) == 2)
|
|
|
|
self.feedMsg('Hi!', frm='op!user@fakehost.net')
|
2011-05-31 06:39:28 +00:00
|
|
|
self.assertEqual(self.irc.takeMsg(), None)
|
2010-04-03 03:17:26 +00:00
|
|
|
self.assertResponse('banreview', 'Pending ban reviews (2): otherop:1 op:1')
|
2010-04-01 20:52:53 +00:00
|
|
|
self.feedMsg('Hi!', frm='mynickissocreative!user@home.net')
|
2011-05-31 06:39:28 +00:00
|
|
|
self.assertEqual(str(self.irc.takeMsg()).strip(),
|
|
|
|
"PRIVMSG mynickissocreative :Review: quiet 'qwe!*@*' set on %s in #test, link: "\
|
|
|
|
"%s/bans.cgi?log=3" %(cb.bans['#test'][2].ascwhen, pluginConf.bansite()))
|
2010-04-01 20:52:53 +00:00
|
|
|
self.feedMsg('ping', to='test', frm='op!user@host.net') # in a query
|
|
|
|
self.irc.takeMsg() # drop pong reply
|
2011-05-31 06:39:28 +00:00
|
|
|
self.assertEqual(str(self.irc.takeMsg()).strip(),
|
|
|
|
"PRIVMSG op :Review: ban 'asd2!*@*' set on %s in #test, link: "\
|
|
|
|
"%s/bans.cgi?log=2" %(cb.bans['#test'][1].ascwhen, pluginConf.bansite()))
|
2010-04-01 20:52:53 +00:00
|
|
|
|
2010-04-03 04:44:57 +00:00
|
|
|
def testReviewForward(self):
|
2011-05-29 22:22:34 +00:00
|
|
|
pluginConf.review.setValue(True)
|
|
|
|
pluginConf.review.forward.set('bot')
|
|
|
|
pluginConf.review.forward.channels.set('#channel')
|
2010-04-03 04:44:57 +00:00
|
|
|
cb = self.getCallback()
|
|
|
|
self.feedBan('asd!*@*', prefix='bot!user@host.net')
|
2011-05-31 04:45:05 +00:00
|
|
|
self.feedBan('asd!*@*', prefix='bot!user@host.net', mode='q')
|
2010-04-03 04:44:57 +00:00
|
|
|
cb.reviewBans(self.irc)
|
|
|
|
self.assertFalse(cb.pendingReviews)
|
|
|
|
print 'waiting 2 secs..'
|
|
|
|
time.sleep(2)
|
|
|
|
cb.reviewBans(self.irc)
|
|
|
|
# since it's a forward, it was sent already
|
|
|
|
self.assertFalse(cb.pendingReviews)
|
2012-06-25 22:35:42 +00:00
|
|
|
self.assertTrue(re.search(
|
|
|
|
r"^NOTICE #channel :Review: ban 'asd!\*@\*' set by bot on .* in #test,"\
|
|
|
|
r" link: .*/bans\.cgi\?log=1$", str(self.irc.takeMsg()).strip()))
|
|
|
|
self.assertTrue(re.search(
|
|
|
|
r"^NOTICE #channel :Review: quiet 'asd!\*@\*' set by bot on .* in #test,"\
|
|
|
|
r" link: .*/bans\.cgi\?log=2$", str(self.irc.takeMsg()).strip()))
|
2010-04-03 04:44:57 +00:00
|
|
|
|
2010-04-13 02:06:25 +00:00
|
|
|
def testReviewIgnore(self):
|
2011-05-29 22:22:34 +00:00
|
|
|
pluginConf.review.setValue(True)
|
|
|
|
pluginConf.review.ignore.set('FloodBot? FloodBotK?')
|
2010-04-13 02:06:25 +00:00
|
|
|
cb = self.getCallback()
|
|
|
|
self.feedBan('asd!*@*', prefix='floodbotk1!bot@botpit.com')
|
|
|
|
cb.reviewBans(self.irc)
|
|
|
|
self.assertFalse(cb.pendingReviews)
|
|
|
|
print 'waiting 2 secs..'
|
|
|
|
time.sleep(2)
|
|
|
|
cb.reviewBans(self.irc)
|
|
|
|
# since it's was ignored, it should not be queued
|
|
|
|
self.assertFalse(cb.pendingReviews)
|
|
|
|
|
2010-04-03 16:20:15 +00:00
|
|
|
def testReviewNickFallback(self):
|
|
|
|
"""If for some reason we don't have ops full hostmask, revert to nick match. This may be
|
|
|
|
needed in the future as hostmasks aren't stored in the db."""
|
2011-05-29 22:22:34 +00:00
|
|
|
pluginConf.review.setValue(True)
|
2010-04-03 16:20:15 +00:00
|
|
|
cb = self.getCallback()
|
|
|
|
self.feedBan('asd!*@*')
|
|
|
|
cb.bans['#test'][0].who = 'op' # replace hostmask by nick
|
|
|
|
print 'waiting 2 secs..'
|
|
|
|
time.sleep(2)
|
|
|
|
cb.reviewBans()
|
|
|
|
# check is pending
|
|
|
|
self.assertTrue(cb.pendingReviews)
|
|
|
|
self.assertResponse('banreview', 'Pending ban reviews (1): op:1')
|
|
|
|
# send msg if a user with a matching nick says something
|
|
|
|
self.feedMsg('Hi!', frm='op_!user@host.net')
|
|
|
|
msg = self.irc.takeMsg()
|
|
|
|
self.assertEqual(msg, None)
|
|
|
|
self.feedMsg('Hi!', frm='op!user@host.net')
|
|
|
|
msg = self.irc.takeMsg()
|
|
|
|
self.assertEqual(str(msg).strip(),
|
2011-05-31 06:39:28 +00:00
|
|
|
"PRIVMSG op :Review: ban 'asd!*@*' set on %s in #test, link: "\
|
|
|
|
"%s/bans.cgi?log=1" %(cb.bans['#test'][0].ascwhen, pluginConf.bansite()))
|
2010-04-03 16:20:15 +00:00
|
|
|
# check not pending anymore
|
|
|
|
self.assertFalse(cb.pendingReviews)
|
|
|
|
|
2012-06-25 22:30:11 +00:00
|
|
|
def testReviewStore(self):
|
2010-04-03 16:20:15 +00:00
|
|
|
"""Save pending reviews and when bans were last checked. This is needed for plugin
|
|
|
|
reloads"""
|
2010-04-03 03:17:26 +00:00
|
|
|
msg1 = ircmsgs.privmsg('nick', 'Hello World')
|
2010-05-14 03:09:50 +00:00
|
|
|
msg2 = ircmsgs.privmsg('nick', 'Hello World') # duplicate msg, should be ignored
|
|
|
|
msg2 = ircmsgs.privmsg('nick', 'Hello World2')
|
2010-04-03 03:17:26 +00:00
|
|
|
msg3 = ircmsgs.notice('#chan', 'Hello World')
|
|
|
|
msg4 = ircmsgs.privmsg('nick_', 'Hello World')
|
2010-04-04 04:31:15 +00:00
|
|
|
pr = self.getCallback().pendingReviews
|
2010-04-03 03:17:26 +00:00
|
|
|
pr['host.net'] = [('op', msg1), ('op', msg2), ('op_', msg3)]
|
|
|
|
pr['home.net'] = [('dude', msg4)]
|
2010-04-03 16:20:15 +00:00
|
|
|
self.assertResponse('banreview', 'Pending ban reviews (4): op_:1 dude:1 op:2')
|
2010-04-03 03:17:26 +00:00
|
|
|
pr.close()
|
|
|
|
pr.clear()
|
|
|
|
pr.open()
|
2010-04-03 16:20:15 +00:00
|
|
|
self.assertResponse('banreview', 'Pending ban reviews (4): op_:1 dude:1 op:2')
|
2010-04-03 03:17:26 +00:00
|
|
|
items = pr['host.net']
|
|
|
|
self.assertTrue(items[0][0] == 'op' and items[0][1] == msg1)
|
|
|
|
self.assertTrue(items[1][0] == 'op' and items[1][1] == msg2)
|
|
|
|
self.assertTrue(items[2][0] == 'op_' and items[2][1] == msg3)
|
|
|
|
items = pr['home.net']
|
|
|
|
self.assertTrue(items[0][0] == 'dude' and items[0][1] == msg4)
|
2010-03-30 20:13:51 +00:00
|
|
|
|
2010-04-04 04:31:15 +00:00
|
|
|
def testReviewBanreview(self):
|
|
|
|
pr = self.getCallback().pendingReviews
|
2011-05-29 22:21:27 +00:00
|
|
|
m = ircmsgs.privmsg('#test', 'ban review')
|
2010-04-04 04:31:15 +00:00
|
|
|
pr['host.net'] = [('op', m), ('op_', m), ('op', m)]
|
|
|
|
pr['home.net'] = [('dude', m)]
|
2011-05-29 22:21:27 +00:00
|
|
|
pr[None] = [('dude_', m)]
|
|
|
|
self.assertResponse('banreview', 'Pending ban reviews (5): dude_:1 op_:1 dude:1 op:2')
|
|
|
|
self.assertResponse('banreview --verbose',
|
|
|
|
'Pending ban reviews (5): op@host.net:2 dude_:1 op_@host.net:1 dude@home.net:1')
|
|
|
|
self.assertRegexp('banreview --flush op@host', '^No reviews for op@host')
|
|
|
|
self.assertResponse('banreview --view dude_', 'ban review')
|
|
|
|
self.assertResponse('banreview', 'Pending ban reviews (5): dude_:1 op_:1 dude:1 op:2')
|
|
|
|
self.assertResponse('banreview --flush op@host.net', 'ban review')
|
|
|
|
# love ya supybot ↓
|
|
|
|
self.assertEqual(self.irc.takeMsg().args[1], 'test: ban review')
|
|
|
|
self.assertResponse('banreview', 'Pending ban reviews (3): dude_:1 op_:1 dude:1')
|
2010-04-04 04:31:15 +00:00
|
|
|
|
2010-04-01 19:34:59 +00:00
|
|
|
def testBan(self):
|
|
|
|
self.feedBan('asd!*@*')
|
|
|
|
fetch = self.query("SELECT id,channel,mask,operator FROM bans")
|
|
|
|
self.assertEqual((1, '#test', 'asd!*@*', 'op'), fetch[0])
|
|
|
|
|
2012-09-08 02:14:44 +00:00
|
|
|
def testBanRealname(self):
|
|
|
|
self.feedBan('$r:asd')
|
|
|
|
fetch = self.query("SELECT id,channel,mask,operator FROM bans")
|
|
|
|
self.assertEqual((1, '#test', '$r:asd', 'op'), fetch[0])
|
|
|
|
|
2010-04-01 19:34:59 +00:00
|
|
|
def testQuiet(self):
|
|
|
|
self.feedBan('asd!*@*', mode='q')
|
|
|
|
fetch = self.query("SELECT id,channel,mask,operator FROM bans")
|
|
|
|
self.assertEqual((1, '#test', '%asd!*@*', 'op'), fetch[0])
|
|
|
|
|
2010-04-03 03:17:26 +00:00
|
|
|
def testKick(self):
|
|
|
|
self.feedBan('troll', mode='k')
|
|
|
|
fetch = self.query("SELECT id,channel,mask,operator FROM bans")
|
|
|
|
self.assertEqual((1, '#test', 'troll', 'op'), fetch[0])
|
|
|
|
|
|
|
|
def testPart(self):
|
|
|
|
self.feedBan('troll!user@trollpit.net', mode='p')
|
|
|
|
fetch = self.query("SELECT id,channel,mask,operator FROM bans")
|
2010-04-13 00:33:15 +00:00
|
|
|
self.assertEqual((1, '#test', 'troll', 'op'), fetch[0])
|
2010-04-03 03:17:26 +00:00
|
|
|
|
2012-07-27 19:09:05 +00:00
|
|
|
def testDuration(self):
|
2012-08-18 14:27:50 +00:00
|
|
|
self.op()
|
2012-06-25 22:40:09 +00:00
|
|
|
cb = self.getCallback()
|
|
|
|
self.feedBan('asd!*@*')
|
2012-06-27 04:14:51 +00:00
|
|
|
cb.autoRemoveBans(self.irc)
|
2012-07-04 03:22:53 +00:00
|
|
|
self.assertFalse(cb.managedBans)
|
2012-07-30 02:36:18 +00:00
|
|
|
self.assertResponse('duration 1 1', "1 will be removed soon.")
|
2012-06-25 22:40:09 +00:00
|
|
|
self.assertTrue(cb.managedBans) # ban in list
|
2012-06-27 04:14:51 +00:00
|
|
|
print 'waiting 2 secs ...'
|
2012-06-25 22:40:09 +00:00
|
|
|
time.sleep(2)
|
2012-06-27 04:14:51 +00:00
|
|
|
cb.autoRemoveBans(self.irc)
|
2012-06-25 22:40:09 +00:00
|
|
|
self.assertFalse(cb.managedBans) # ban removed
|
2012-06-27 04:14:51 +00:00
|
|
|
msg = self.irc.takeMsg() # unban msg
|
|
|
|
self.assertEqual(str(msg).strip(), "MODE #test -b :asd!*@*")
|
2012-06-25 22:40:09 +00:00
|
|
|
|
2012-08-03 14:46:17 +00:00
|
|
|
def testDurationRemove(self):
|
|
|
|
self.feedBan('asd!*@*')
|
|
|
|
self.assertResponse('duration 1 -1',
|
|
|
|
"Failed to set duration time on 1 (ban isn't marked for removal)")
|
|
|
|
self.assertResponse('duration 1 10', '1 will be removed soon.')
|
|
|
|
self.assertResponse('duration 1 -1', "1 won't expire.")
|
|
|
|
self.assertRegexp('duration 1', 'never expires')
|
|
|
|
|
2012-07-27 19:09:05 +00:00
|
|
|
def testDurationMergeModes(self):
|
2012-08-18 14:27:50 +00:00
|
|
|
self.op()
|
2012-07-16 01:28:38 +00:00
|
|
|
cb = self.getCallback()
|
|
|
|
self.feedBan('asd!*@*')
|
|
|
|
self.feedBan('qwe!*@*')
|
|
|
|
self.feedBan('zxc!*@*')
|
|
|
|
self.feedBan('asd!*@*', mode='q')
|
|
|
|
self.feedBan('qwe!*@*', mode='q')
|
|
|
|
self.feedBan('zxc!*@*', mode='q')
|
2012-08-03 14:46:17 +00:00
|
|
|
self.assertNotError('duration 1,2,3,4,5,6 1')
|
|
|
|
print 'waiting 2 secs ...'
|
|
|
|
time.sleep(2)
|
2012-07-16 01:28:38 +00:00
|
|
|
cb.autoRemoveBans(self.irc)
|
|
|
|
msg = self.irc.takeMsg() # unban msg
|
|
|
|
self.assertEqual(str(msg).strip(),
|
|
|
|
"MODE #test -qqqb zxc!*@* qwe!*@* asd!*@* :zxc!*@*")
|
|
|
|
msg = self.irc.takeMsg()
|
|
|
|
self.assertEqual(str(msg).strip(), "MODE #test -bb qwe!*@* :asd!*@*")
|
|
|
|
|
2012-07-27 19:09:05 +00:00
|
|
|
def testDurationMultiSet(self):
|
2012-07-19 00:34:49 +00:00
|
|
|
self.feedBan('asd!*@*')
|
2012-07-30 02:36:18 +00:00
|
|
|
self.assertResponse('duration 1,2 10d',
|
2012-07-28 00:44:29 +00:00
|
|
|
"Failed to set duration time on 2 (unknow id)")
|
2012-07-19 00:34:49 +00:00
|
|
|
msg = self.irc.takeMsg()
|
2012-07-30 02:36:18 +00:00
|
|
|
self.assertEqual(msg.args[1],
|
|
|
|
"test: 1 will be removed after 1 week and 3 days.")
|
2012-07-19 00:34:49 +00:00
|
|
|
|
2012-07-27 19:09:05 +00:00
|
|
|
def testDurationQuiet(self):
|
2012-08-18 14:27:50 +00:00
|
|
|
self.op()
|
2012-07-05 22:08:44 +00:00
|
|
|
cb = self.getCallback()
|
|
|
|
self.feedBan('asd!*@*', mode='q')
|
2012-08-03 14:46:17 +00:00
|
|
|
self.assertNotError('duration 1 1')
|
|
|
|
print 'waiting 2 sec ...'
|
|
|
|
time.sleep(2)
|
2012-07-05 22:08:44 +00:00
|
|
|
cb.autoRemoveBans(self.irc)
|
|
|
|
msg = self.irc.takeMsg() # unban msg
|
|
|
|
self.assertEqual(str(msg).strip(), "MODE #test -q :asd!*@*")
|
|
|
|
|
2012-09-08 02:14:44 +00:00
|
|
|
def testDurationRealname(self):
|
|
|
|
self.op()
|
|
|
|
cb = self.getCallback()
|
|
|
|
self.feedBan('$r:asd?asd', mode='b')
|
|
|
|
self.assertNotError('duration 1 1')
|
|
|
|
print 'waiting 2 sec ...'
|
|
|
|
time.sleep(2)
|
|
|
|
cb.autoRemoveBans(self.irc)
|
|
|
|
msg = self.irc.takeMsg() # unban msg
|
|
|
|
self.assertEqual(str(msg).strip(), "MODE #test -b :$r:asd?asd")
|
|
|
|
|
2012-07-27 19:09:05 +00:00
|
|
|
def testDurationBadType(self):
|
2012-07-05 22:12:38 +00:00
|
|
|
self.feedBan('nick', mode='k')
|
2012-08-03 14:46:17 +00:00
|
|
|
self.assertResponse('duration 1 1',
|
2012-07-28 00:44:29 +00:00
|
|
|
"Failed to set duration time on 1 (not a ban or quiet)")
|
2012-07-05 22:36:13 +00:00
|
|
|
self.feedBan('$a:nick')
|
2012-08-03 14:46:17 +00:00
|
|
|
self.assertResponse('duration 2 1', '2 will be removed soon.')
|
2012-07-05 22:12:38 +00:00
|
|
|
|
2012-07-27 19:09:05 +00:00
|
|
|
def testDurationBadId(self):
|
2012-08-03 14:46:17 +00:00
|
|
|
self.assertResponse('duration 1 1',
|
2012-07-28 00:44:29 +00:00
|
|
|
"Failed to set duration time on 1 (unknow id)")
|
2012-07-04 03:22:53 +00:00
|
|
|
|
2012-07-27 19:09:05 +00:00
|
|
|
def testDurationInactiveBan(self):
|
2012-07-04 03:22:53 +00:00
|
|
|
self.feedBan('asd!*@*')
|
|
|
|
self.irc.feedMsg(ircmsgs.unban(self.channel, 'asd!*@*',
|
|
|
|
'op!user@host.net'))
|
2012-08-03 14:46:17 +00:00
|
|
|
self.assertResponse('duration 1 1',
|
2012-07-28 00:44:29 +00:00
|
|
|
"Failed to set duration time on 1 (ban was removed)")
|
2012-07-04 03:22:53 +00:00
|
|
|
|
2012-07-27 19:09:05 +00:00
|
|
|
def testDurationTimeFormat(self):
|
2012-07-04 22:23:37 +00:00
|
|
|
cb = self.getCallback()
|
|
|
|
self.feedBan('asd!*@*')
|
2012-07-27 19:09:05 +00:00
|
|
|
self.assertNotError('duration 1 10m')
|
2012-07-04 22:23:37 +00:00
|
|
|
self.assertEqual(cb.managedBans.shelf[0].expires, 600)
|
2012-07-27 19:09:05 +00:00
|
|
|
self.assertNotError('duration 1 2 weeks')
|
2012-07-04 22:23:37 +00:00
|
|
|
self.assertEqual(cb.managedBans.shelf[0].expires, 1209600)
|
2012-07-27 19:09:05 +00:00
|
|
|
self.assertNotError('duration 1 1m 2 days')
|
2012-07-04 22:23:37 +00:00
|
|
|
self.assertEqual(cb.managedBans.shelf[0].expires, 172860)
|
2012-07-27 19:09:05 +00:00
|
|
|
self.assertNotError('duration 1 24h 1day')
|
2012-07-04 22:23:37 +00:00
|
|
|
self.assertEqual(cb.managedBans.shelf[0].expires, 172800)
|
2012-11-03 22:00:31 +00:00
|
|
|
self.assertNotError('duration 1 1s1m1h1d1w1M1y')
|
|
|
|
self.assertEqual(cb.managedBans.shelf[0].expires, 34822861)
|
2012-07-27 19:09:05 +00:00
|
|
|
self.assertNotError('duration 1 999')
|
2012-07-04 22:52:20 +00:00
|
|
|
self.assertEqual(cb.managedBans.shelf[0].expires, 999)
|
2012-11-03 22:00:31 +00:00
|
|
|
self.assertNotError('duration 1 1 second')
|
|
|
|
self.assertEqual(cb.managedBans.shelf[0].expires, 1)
|
2012-07-04 22:23:37 +00:00
|
|
|
|
2012-07-27 19:09:05 +00:00
|
|
|
def testDurationTimeFormatBad(self):
|
|
|
|
self.assertError('duration 1 10 apples')
|
2012-06-25 22:40:09 +00:00
|
|
|
|
2012-07-27 19:09:05 +00:00
|
|
|
def testDurationNotice(self):
|
2012-07-05 00:35:07 +00:00
|
|
|
cb = self.getCallback()
|
|
|
|
self.feedBan('asd!*@*')
|
2012-07-27 19:09:05 +00:00
|
|
|
self.assertNotError('duration 1 300')
|
2012-08-23 10:21:58 +00:00
|
|
|
pluginConf.autoremove.notify.channels.set('#test')
|
2012-07-05 01:12:55 +00:00
|
|
|
try:
|
|
|
|
cb.autoRemoveBans(self.irc)
|
|
|
|
msg = self.irc.takeMsg()
|
|
|
|
self.assertEqual(str(msg).strip(),
|
2012-07-05 23:40:57 +00:00
|
|
|
"NOTICE #test :ban \x0309[\x03\x021\x02\x0309]\x03 \x0310asd!*@*\x03"\
|
|
|
|
" in \x0310#test\x03 will expire in a few minutes.")
|
2012-07-05 01:12:55 +00:00
|
|
|
# don't send the notice again.
|
|
|
|
cb.autoRemoveBans(self.irc)
|
|
|
|
self.assertFalse(self.irc.takeMsg())
|
|
|
|
finally:
|
2012-08-23 10:21:58 +00:00
|
|
|
pluginConf.autoremove.notify.channels.set('')
|
2012-07-05 00:35:07 +00:00
|
|
|
|
2012-07-05 05:31:53 +00:00
|
|
|
def testAutoremoveStore(self):
|
|
|
|
self.feedBan('asd!*@*')
|
|
|
|
self.feedBan('qwe!*@*')
|
|
|
|
self.feedBan('zxc!*@*', mode='q')
|
2012-07-27 19:09:05 +00:00
|
|
|
self.assertNotError('duration 1 10m')
|
|
|
|
self.assertNotError('duration 2 1d')
|
|
|
|
self.assertNotError('duration 3 1w')
|
2012-07-05 05:31:53 +00:00
|
|
|
cb = self.getCallback()
|
|
|
|
cb.managedBans.shelf[1].notified = True
|
|
|
|
cb.managedBans.close()
|
|
|
|
cb.managedBans.shelf = []
|
|
|
|
cb.managedBans.open()
|
|
|
|
L = cb.managedBans.shelf
|
|
|
|
for i, n in enumerate((600, 86400, 604800)):
|
|
|
|
self.assertEqual(L[i].expires, n)
|
|
|
|
for i, n in enumerate((False, True, False)):
|
|
|
|
self.assertEqual(L[i].notified, n)
|
|
|
|
for i, n in enumerate((1, 2, 3)):
|
|
|
|
self.assertEqual(L[i].ban.id, n)
|
|
|
|
for i, n in enumerate(('asd!*@*', 'qwe!*@*', '%zxc!*@*')):
|
|
|
|
self.assertEqual(L[i].ban.mask, n)
|
|
|
|
self.assertEqual(L[0].ban.channel, '#test')
|
|
|
|
|
2012-07-13 16:45:37 +00:00
|
|
|
def testBaninfo(self):
|
|
|
|
cb = self.getCallback()
|
|
|
|
self.feedBan('asd!*@*')
|
2012-07-28 00:44:29 +00:00
|
|
|
self.assertResponse('duration 1',
|
|
|
|
"[1] ban - asd!*@* - #test - never expires")
|
2012-07-27 19:09:05 +00:00
|
|
|
self.assertNotError('duration 1 10')
|
2012-07-28 00:44:29 +00:00
|
|
|
self.assertResponse('duration 1',
|
|
|
|
"[1] ban - asd!*@* - #test - expires soon")
|
2012-07-27 19:09:05 +00:00
|
|
|
self.assertNotError('duration 1 34502')
|
2012-07-28 00:44:29 +00:00
|
|
|
self.assertResponse('duration 1',
|
|
|
|
"[1] ban - asd!*@* - #test - expires in 9 hours and 35 minutes")
|
2012-07-16 00:06:23 +00:00
|
|
|
self.irc.feedMsg(ircmsgs.unban(self.channel, 'asd!*@*',
|
|
|
|
'op!user@host.net'))
|
2012-07-28 00:44:29 +00:00
|
|
|
self.assertResponse('duration 1',
|
|
|
|
"[1] ban - asd!*@* - #test - not active")
|
2010-04-03 03:17:26 +00:00
|
|
|
|
2012-07-27 19:03:15 +00:00
|
|
|
def testBaninfoGeneral(self):
|
|
|
|
cb = self.getCallback()
|
|
|
|
self.feedBan('asd!*@*')
|
|
|
|
self.feedBan('qwe!*@*')
|
2012-07-27 19:09:05 +00:00
|
|
|
self.assertNotError('duration 1 1d')
|
2012-07-30 02:53:17 +00:00
|
|
|
self.assertResponse('duration', "1 ban set to expire: 1")
|
2012-07-27 19:09:05 +00:00
|
|
|
self.assertNotError('duration 2 1d')
|
2012-07-30 02:36:18 +00:00
|
|
|
self.assertResponse('duration', "2 bans set to expire: 1 and 2")
|
2012-07-27 19:03:15 +00:00
|
|
|
|
2012-08-18 14:27:50 +00:00
|
|
|
def testOpTrack(self):
|
|
|
|
cb = self.getCallback()
|
|
|
|
self.assertEqual(cb.opped['#test'], False)
|
|
|
|
self.op()
|
|
|
|
self.assertEqual(cb.opped['#test'], True)
|
|
|
|
self.deop()
|
|
|
|
self.assertEqual(cb.opped['#test'], False)
|
2012-09-08 02:08:11 +00:00
|
|
|
self.op()
|
|
|
|
self.irc.feedMsg(ircmsgs.part('#test', prefix=self.prefix))
|
|
|
|
self.irc.feedMsg(ircmsgs.join('#test', prefix=self.prefix))
|
|
|
|
self.irc.takeMsg() # MODE msg
|
|
|
|
self.irc.takeMsg() # WHO msg
|
|
|
|
self.assertEqual(cb.opped['#test'], False)
|
2012-08-18 14:27:50 +00:00
|
|
|
|
|
|
|
def testOpDuration(self):
|
|
|
|
cb = self.getCallback()
|
|
|
|
self.feedBan('asd!*@*')
|
2012-08-23 10:21:58 +00:00
|
|
|
self.assertNotError('duration 1 1')
|
2012-08-18 14:27:50 +00:00
|
|
|
print 'waiting 2 secs ...'
|
|
|
|
time.sleep(2)
|
|
|
|
cb.autoRemoveBans(self.irc)
|
|
|
|
msg = self.irc.takeMsg() # op msg
|
|
|
|
self.assertEqual(str(msg).strip(), "PRIVMSG Chanserv :op #test test")
|
|
|
|
self.op()
|
|
|
|
msg = self.irc.takeMsg() # unban msg
|
|
|
|
self.assertEqual(str(msg).strip(), "MODE #test -bo asd!*@* :test")
|
|
|
|
|
2012-08-23 10:21:58 +00:00
|
|
|
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")
|
2012-08-23 10:50:39 +00:00
|
|
|
self.op()
|
|
|
|
msg = self.irc.takeMsg() # unban msg
|
|
|
|
self.assertEqual(str(msg).strip(), "MODE #test -b :asd!*@*")
|
2012-08-23 10:21:58 +00:00
|
|
|
finally:
|
|
|
|
pluginConf.autoremove.notify.channels.set('')
|
2012-08-18 14:27:50 +00:00
|
|
|
|
2012-10-02 12:34:20 +00:00
|
|
|
def testQuietList(self):
|
|
|
|
self.irc.feedMsg(ircmsgs.IrcMsg(
|
|
|
|
':server.net 005 test CHANMODES=eIbq,k,flj,CFLMPQcgimnprstz :are supported'))
|
|
|
|
self.irc.feedMsg(ircmsgs.IrcMsg(
|
|
|
|
':server.net 728 test #channel q troll!*@* op!user@home.com 123456789'))
|
|
|
|
self.irc.feedMsg(ircmsgs.IrcMsg(
|
|
|
|
':server.net 729 test #channel q :End of Channel Quiet List'))
|
|
|
|
L = self.getCallback().bans.get('#channel')
|
|
|
|
self.assertTrue(L != None)
|
|
|
|
self.assertEqual('%troll!*@*', L[0].mask)
|
|
|
|
|
|
|
|
def testQuietListNotSupported(self):
|
|
|
|
self.irc.feedMsg(ircmsgs.IrcMsg(
|
|
|
|
':server.net 005 test CHANMODES=eIb,k,flj,CFLMPQcgimnprstz :are supported'))
|
|
|
|
self.irc.feedMsg(ircmsgs.IrcMsg(
|
|
|
|
':server.net 728 test #channel q troll!*@* op!user@home.com 123456789'))
|
|
|
|
self.irc.feedMsg(ircmsgs.IrcMsg(
|
|
|
|
':server.net 729 test #channel q :End of Channel Quiet List'))
|
|
|
|
L = self.getCallback().bans.get('#channel')
|
|
|
|
self.assertTrue(L == None)
|
|
|
|
|
|
|
|
def testBanList(self):
|
|
|
|
self.irc.feedMsg(ircmsgs.IrcMsg(
|
|
|
|
':server.net 367 test #channel troll!*@* op!user@home.com 123456789'))
|
|
|
|
self.irc.feedMsg(ircmsgs.IrcMsg(
|
|
|
|
':server.net 368 test #channel :End of Channel Ban List'))
|
2012-09-15 23:00:41 +00:00
|
|
|
obj = self.getCallback().bans['#channel'][0]
|
|
|
|
self.assertEqual('troll!*@*', obj.mask)
|
|
|
|
|
2010-04-01 19:34:59 +00:00
|
|
|
|