mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-02 15:44:06 +01:00
Added ignore, unignore, and ignores to be complete with Channel.
This commit is contained in:
parent
afeba84113
commit
830301570f
53
src/Admin.py
53
src/Admin.py
@ -44,7 +44,9 @@ import textwrap
|
|||||||
|
|
||||||
import conf
|
import conf
|
||||||
import ircdb
|
import ircdb
|
||||||
|
import utils
|
||||||
import ircmsgs
|
import ircmsgs
|
||||||
|
import ircutils
|
||||||
import privmsgs
|
import privmsgs
|
||||||
import callbacks
|
import callbacks
|
||||||
|
|
||||||
@ -179,6 +181,57 @@ class Admin(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
s = 'You can\'t remove capabilities you don\'t have.'
|
s = 'You can\'t remove capabilities you don\'t have.'
|
||||||
irc.error(msg, s)
|
irc.error(msg, s)
|
||||||
|
|
||||||
|
def ignore(self, irc, msg, args):
|
||||||
|
"""<hostmask|nick>
|
||||||
|
|
||||||
|
Ignores <hostmask> or, if a nick is given, ignores whatever hostmask
|
||||||
|
that nick is currently using.
|
||||||
|
"""
|
||||||
|
arg = privmsgs.getArgs(args)
|
||||||
|
if ircutils.isUserHostmask(arg):
|
||||||
|
hostmask = arg
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
hostmask = irc.state.nickToHostmask(arg)
|
||||||
|
except KeyError:
|
||||||
|
irc.error(msg, 'I can\'t find a hostmask for %s' % arg)
|
||||||
|
return
|
||||||
|
conf.ignores.append(hostmask)
|
||||||
|
irc.reply(msg, conf.replySuccess)
|
||||||
|
|
||||||
|
def unignore(self, irc, msg, args):
|
||||||
|
"""<hostmask|nick>
|
||||||
|
|
||||||
|
Ignores <hostmask> or, if a nick is given, ignores whatever hostmask
|
||||||
|
that nick is currently using.
|
||||||
|
"""
|
||||||
|
arg = privmsgs.getArgs(args)
|
||||||
|
if ircutils.isUserHostmask(arg):
|
||||||
|
hostmask = arg
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
hostmask = irc.state.nickToHostmask(arg)
|
||||||
|
except KeyError:
|
||||||
|
irc.error(msg, 'I can\'t find a hostmask for %s' % arg)
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
conf.ignores.remove(hostmask)
|
||||||
|
while hostmask in conf.ignores:
|
||||||
|
conf.ignores.remove(hostmask)
|
||||||
|
irc.reply(msg, conf.replySuccess)
|
||||||
|
except ValueError:
|
||||||
|
irc.error(msg, '%s wasn\'t in conf.ignores.' % hostmask)
|
||||||
|
|
||||||
|
def ignores(self, irc, msg, args):
|
||||||
|
"""takes no arguments
|
||||||
|
|
||||||
|
Returns the hostmasks currently being globally ignored.
|
||||||
|
"""
|
||||||
|
if conf.ignores:
|
||||||
|
irc.reply(msg, utils.commaAndify(map(repr, conf.ignores)))
|
||||||
|
else:
|
||||||
|
irc.reply(msg, 'I\'m not currently globally ignoring anyone.')
|
||||||
|
|
||||||
def setprefixchar(self, irc, msg, args):
|
def setprefixchar(self, irc, msg, args):
|
||||||
"""<prefixchars>
|
"""<prefixchars>
|
||||||
|
|
||||||
|
@ -31,8 +31,29 @@
|
|||||||
|
|
||||||
from test import *
|
from test import *
|
||||||
|
|
||||||
|
import conf
|
||||||
|
|
||||||
class AdminTestCase(PluginTestCase, PluginDocumentation):
|
class AdminTestCase(PluginTestCase, PluginDocumentation):
|
||||||
plugins = ('Admin', 'Misc')
|
plugins = ('Admin',)
|
||||||
|
def testIgnoreUnignore(self):
|
||||||
|
try:
|
||||||
|
self.assertNotError('admin ignore foo!bar@baz')
|
||||||
|
self.assertError('admin ignore alsdkfjlasd')
|
||||||
|
self.assertNotError('admin unignore foo!bar@baz')
|
||||||
|
self.assertError('admin unignore foo!bar@baz')
|
||||||
|
finally:
|
||||||
|
conf.ignores = []
|
||||||
|
|
||||||
|
def testIgnores(self):
|
||||||
|
try:
|
||||||
|
self.assertNotError('admin ignores')
|
||||||
|
self.assertNotError('admin ignore foo!bar@baz')
|
||||||
|
self.assertNotError('admin ignores')
|
||||||
|
self.assertNotError('admin ignore foo!bar@baz')
|
||||||
|
self.assertNotError('admin ignores')
|
||||||
|
finally:
|
||||||
|
conf.ignores = []
|
||||||
|
|
||||||
def testSetprefixchar(self):
|
def testSetprefixchar(self):
|
||||||
self.assertNotError('setprefixchar $')
|
self.assertNotError('setprefixchar $')
|
||||||
self.assertResponse('getprefixchar', "'$'")
|
self.assertResponse('getprefixchar', "'$'")
|
||||||
|
Loading…
Reference in New Issue
Block a user