Added test, changed to use commands.wrap.

This commit is contained in:
Jeremy Fincher 2004-11-08 20:03:42 +00:00
parent beffc15c0d
commit 54db030707
2 changed files with 9 additions and 8 deletions

View File

@ -54,7 +54,7 @@ import random
import supybot.plugins import supybot.plugins
import supybot.conf as conf import supybot.conf as conf
import supybot.utils as utils import supybot.utils as utils
import supybot.privmsgs as privmsgs from supybot.commands import *
import supybot.registry as registry import supybot.registry as registry
import supybot.callbacks as callbacks import supybot.callbacks as callbacks
@ -170,19 +170,19 @@ class Insult(callbacks.Privmsg):
return 'You are nothing but %s %s %s of %s %s.' % ( return 'You are nothing but %s %s %s of %s %s.' % (
an, adj1, amount, adj2, noun) an, adj1, amount, adj2, noun)
def insult(self, irc, msg, args): def insult(self, irc, msg, args, victim):
"""[<target>] """[<target>]
Reply optionally directed at a random string, person, Reply optionally directed at a random string, person,
object, etc. object, etc.
""" """
tempinsult = self._buildInsult() tempinsult = self._buildInsult()
victim = privmsgs.getArgs(args, required=0, optional=1)
if not victim: if not victim:
irc.reply(tempinsult, prefixName=False) irc.reply(tempinsult, prefixName=False)
else: else:
irc.reply('%s - %s ' % (victim, tempinsult), irc.reply('%s - %s ' % (victim, tempinsult),
prefixName=False) prefixName=False)
insult = wrap(insult, [additional('text')])
Class = Insult Class = Insult

View File

@ -1,5 +1,5 @@
### ###
# Copyright (c) 2004, Grant Bowman # Copyright (c) 2002-2004, Jeremiah Fincher
# All rights reserved. # All rights reserved.
# #
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
@ -29,12 +29,13 @@
from testsupport import * from testsupport import *
class InsultTest(ChannelPluginTestCase, PluginDocumentation): class InsultTestCase(PluginTestCase):
plugins = ('Insult',) plugins = ('Insult',)
def testInsult(self): def testInsult(self):
self.assertNotError('insult') self.assertNotError('insult')
self.assertNotError('insult Osama bin Laden') self.assertNotError('insult foo')
self.assertNotError('insult foo bar baz')
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: