Change !create to !clone

This commit is contained in:
Joscha 2016-05-23 21:35:01 +02:00
parent 8b12b62217
commit e5c3d05941

View file

@ -36,12 +36,14 @@ class Bot():
self.commands = callbacks.Callbacks() self.commands = callbacks.Callbacks()
self.add_command("create", self.create_command, "Create a new bot of this bot's type.", # possibly add option to set nick? self.add_command("clone", self.create_command, "Clone this bot to another room.", # possibly add option to set nick?
("!create @bot [ <room> [ --pw=<password> ] ]\n" ("!clone @bot [ <room> [ --pw=<password> ] ]\n"
"<room> : the name of the room to clone the bot to\n"
"--pw : the room's password\n\n" "--pw : the room's password\n\n"
"Create a bot in the room specified, or the current room if no room\n" "Clone this bot to the room specified.\n"
"is specified. If the target room is passworded, you can use the\n" "If the target room is passworded, you can use the --pw option to set\n"
"--pw option to set a password for the bot to use.")) "a password for the bot to use.\n"
"If no room is specified, this will use the current room and password."))
self.add_command("help", self.help_command, "Show help information about the bot.", self.add_command("help", self.help_command, "Show help information about the bot.",
("!help @bot [ -s | <command> ]\n" ("!help @bot [ -s | <command> ]\n"
@ -382,15 +384,16 @@ class Bot():
# ----- COMMANDS ----- # ----- COMMANDS -----
def create_command(self, message, arguments, flags, options): def clone_command(self, message, arguments, flags, options):
""" """
create_command(message, *arguments, flags, options) -> None clone_command(message, *arguments, flags, options) -> None
Create a new bot. Create a new bot.
""" """
if not arguments: if not arguments:
room = self.roomname() room = self.roomname()
password = self.room.password
else: else:
room = arguments[0] room = arguments[0]
@ -405,12 +408,12 @@ class Bot():
try: try:
bot = self.manager.create(room, password=password) bot = self.manager.create(room, password=password)
except exceptions.CreateBotException: except exceptions.CreateBotException:
self.room.send_message("Bot could not be created.", parent=message.id) self.room.send_message("Bot could not be cloned.", parent=message.id)
else: else:
bot.created_in = self.roomname() bot.created_in = self.roomname()
bot.created_by = self.room.mentionable(message.sender.name) bot.created_by = self.room.mentionable(message.sender.name)
self.room.send_message("Created @{} in &{}.".format(bot.mentionable(), room), self.room.send_message("Cloned @{} to &{}.".format(bot.mentionable(), room),
parent=message.id) parent=message.id)
def help_command(self, message, arguments, flags, options): def help_command(self, message, arguments, flags, options):