Minor bugfix of addcom command, some other cleanup.

This commit is contained in:
Griatch 2009-05-02 15:55:47 +00:00
parent 5bc1db70ed
commit 1314629a06
4 changed files with 17 additions and 20 deletions

View file

@ -19,20 +19,20 @@ def cmd_addcom(command):
addcom foo=Bar
"""
source_object = command.source_object
command_argument = command.command_argument
if not command.command_argument:
source_object.emit_to("You need to specify a channel alias and name.")
return
eq_args = command.command_argument.split('=', 1)
chan_alias = eq_args[0]
chan_name = eq_args[1]
if len(eq_args) < 2 or len(chan_name) == 0:
source_object.emit_to("You need to specify a channel name.")
return
if not command_argument:
source_object.emit_to("Usage: addcom [alias=]channelname.")
return
command_argument
if '=' in command_argument:
chan_alias, chan_name = command.command_argument.split('=', 1)
chan_alias, chan_name = chan_alias.strip(), chan_name.strip()
else:
chan_name = command_argument.strip()
chan_alias = chan_name
if chan_alias in command.session.channels_subscribed:
source_object.emit_to("You are already on that channel.")
return

View file

@ -257,9 +257,11 @@ def cmd_find(command):
if len(results) > 0:
source_object.emit_to("Name matches for: %s" % (searchstring,))
s = ""
for result in results:
source_object.emit_to(" %s" % (result.get_name(fullname=True),))
source_object.emit_to("%d matches returned." % (len(results),))
s += " %s\n\r" % (result.get_name(fullname=True),)
s += "%d matches returned." % (len(results),)
source_object.emit_to(s)
else:
source_object.emit_to("No name matches found for: %s" % (searchstring,))
GLOBAL_CMD_TABLE.add_command("@find", cmd_find,

View file

@ -279,4 +279,4 @@ try:
import django_extensions
INSTALLED_APPS = INSTALLED_APPS + ('django_extensions',)
except ImportError:
pass
pass