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

@ -64,11 +64,6 @@ class RedButton(BasicObject):
""" """
This function is called when object is created. Use this This function is called when object is created. Use this
preferably over __init__. preferably over __init__.
In this case all we do is add the commandtable
to the object's own command_table variable; this makes
the commands we've added to COMMAND_TABLE available to
the user whenever the object is around.
""" """
#get stored object related to this class #get stored object related to this class
obj = self.scripted_obj obj = self.scripted_obj

View file

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

View file

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