def execute(self): """Create a new SMIRC conversation. Executor automatically joins the created conversation and is given operator permissions in it. /CREATE [conversation name] Example: /CREATE HelloWorld Creates a new SMIRC conversation called "HelloWorld" and automatically joins the executing user to it with full operator permissions. """ try: Conversation.validate_name(self.arguments['conversation_identifier']) except SmircRestrictedNameException as e: raise SmircCommandException(str(e)) try: m = Membership.load_membership(self.executor, self.arguments['conversation_identifier']) except Membership.DoesNotExist: c = Conversation() c.name = self.arguments['conversation_identifier'] c.save() m = Membership() m.conversation = c m.mode_operator = True m.user = self.executor m.save() return 'you have created a conversation named "%s"' % (c.name) else: raise SmircCommandException('you are already taking part in a conversation named "%s"' % (m.conversation.name))