Allow ids to have # in front of them.

This commit is contained in:
Jeremy Fincher 2004-10-23 20:32:29 +00:00
parent 0d2b710aa2
commit e3bdd34f3f
2 changed files with 11 additions and 3 deletions

View File

@ -206,9 +206,14 @@ def getIndex(irc, msg, args, state):
def getId(irc, msg, args, state, kind=None):
type = 'id'
if kind is not None:
if kind is not None and not kind.endswith('id'):
type = kind + ' id'
getInt(irc, msg, args, state, type=type)
try:
original = args[0]
args[0] = args[0].lstrip('#')
getInt(irc, msg, args, state, type=type)
except Exception, e:
args[0] = original
def getExpiry(irc, msg, args, state):
now = int(time.time())
@ -243,7 +248,6 @@ def getHaveOp(irc, msg, args, state, action='do that'):
def validChannel(irc, msg, args, state):
if irc.isChannel(args[0]):
# XXX Check maxlength in irc.state.supported.
state.args.append(args.pop(0))
else:
irc.errorInvalid('channel', args[0])

View File

@ -99,6 +99,10 @@ class CommandsTestCase(SupyTestCase):
spec = ['channel', 'text']
self.assertState(spec, ['#foo', '+s'], ['#foo', '+s'])
self.assertState(spec, ['+s'], ['#foo', '+s'], target='#foo')
def testGetId(self):
spec = ['id']
self.assertState(spec, ['#12'], [12])
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: