def func(self): "Implement the command" caller = self.caller if not self.args: self.msg("Usage @ccreate <channelname>[;alias;alias..] = description") return description = "" if self.rhs: description = self.rhs lhs = self.lhs channame = lhs aliases = None if ';' in lhs: channame, aliases = [part.strip().lower() for part in lhs.split(';', 1) if part.strip()] aliases = [alias.strip().lower() for alias in aliases.split(';') if alias.strip()] channel = ChannelDB.objects.channel_search(channame) if channel: self.msg("A channel with that name already exists.") return # Create and set the channel up lockstring = "send:all();listen:all();control:id(%s)" % caller.id new_chan = create.create_channel(channame, aliases, description, locks=lockstring) new_chan.connect(caller) self.msg("Created channel %s and connected to it." % new_chan.key)
def func(self): "Run the test program" caller = self.caller if 'create' in self.switches: if self.args: chankey = self.args try: channel = create.create_channel(chankey) except IntegrityError: caller.msg("Channel '%s' already exists." % chankey) return channel.connect_to(caller) caller.msg("Created new channel %s" % chankey) msgobj = create.create_message(caller.player, "First post to new channel!") channel.msg(msgobj) return elif 'list' in self.switches: msgresults = Msg.objects.get_messages_by_sender(caller) string = "\n".join(["%s %s: %s" % (msg.date_sent, [str(chan.key) for chan in msg.channels.all()], msg.message) for msg in msgresults]) caller.msg(string) return caller.msg("Usage: @testcom/create channel")
def create_channels(): """ Creates some sensible default channels. """ print " Creating default channels ..." # public channel key1, aliases, desc, locks = settings.CHANNEL_PUBLIC pchan = create.create_channel(key1, aliases, desc, locks=locks) # mudinfo channel key2, aliases, desc, locks = settings.CHANNEL_MUDINFO ichan = create.create_channel(key2, aliases, desc, locks=locks) # connectinfo channel key3, aliases, desc, locks = settings.CHANNEL_CONNECTINFO cchan = create.create_channel(key3, aliases, desc, locks=locks) # TODO: postgresql-psycopg2 has a strange error when trying to # connect the user to the default channels. It works fine from inside # the game, but not from the initial startup. We are temporarily bypassing # the problem with the following fix. See Evennia Issue 151. if ((".".join(str(i) for i in django.VERSION) < "1.2" and settings.DATABASE_ENGINE == "postgresql_psycopg2") or (hasattr(settings, 'DATABASES') and settings.DATABASES.get("default", {}).get('ENGINE', None) == 'django.db.backends.postgresql_psycopg2')): warning = """ PostgreSQL-psycopg2 compatability fix: The in-game channels %s, %s and %s were created, but the superuser was not yet connected to them. Please use in game commands to onnect Player #1 to those channels when first logging in. """ % (key1, key2, key3) print warning return # connect the god user to all these channels by default. goduser = get_god_player() from src.comms.models import PlayerChannelConnection PlayerChannelConnection.objects.create_connection(goduser, pchan) PlayerChannelConnection.objects.create_connection(goduser, ichan) PlayerChannelConnection.objects.create_connection(goduser, cchan)
def create_channels(): """ Creates some sensible default channels. """ print " Creating default channels ..." # public channel key1, aliases, desc, locks = settings.CHANNEL_PUBLIC pchan = create.create_channel(key1, aliases, desc, locks=locks) # mudinfo channel key2, aliases, desc, locks = settings.CHANNEL_MUDINFO ichan = create.create_channel(key2, aliases, desc, locks=locks) # connectinfo channel key3, aliases, desc, locks = settings.CHANNEL_CONNECTINFO cchan = create.create_channel(key3, aliases, desc, locks=locks) # TODO: postgresql-psycopg2 has a strange error when trying to # connect the user to the default channels. It works fine from inside # the game, but not from the initial startup. We are temporarily bypassing # the problem with the following fix. See Evennia Issue 151. if ((".".join(str(i) for i in django.VERSION) < "1.2" and settings.DATABASE_ENGINE == "postgresql_psycopg2") or (hasattr(settings, 'DATABASES') and settings.DATABASES.get("default", {}).get('ENGINE', None) == 'django.db.backends.postgresql_psycopg2')): warning = """ PostgreSQL-psycopg2 compatability fix: The in-game channels %s, %s and %s were created, but the superuser was not yet connected to them. Please use in game commands to onnect Player #1 to those channels when first logging in. """ % (key1, key2, key3) print warning return # connect the god user to all these channels by default. goduser = get_god_player() pchan.connect(goduser) ichan.connect(goduser) cchan.connect(goduser)
def create_channels(): # public channel print "Creating Public channel!" key, aliases, desc, locks = settings.CHANNEL_PUBLIC print key, aliases, desc, locks create.create_channel(key, aliases=aliases, desc=desc, locks=locks) # newbie channel print "Creating Newbie Channel!" key, aliases, desc, locks = settings.CHANNEL_NEWBIE print key, aliases, desc, locks create.create_channel(key, aliases=aliases, desc=desc, locks=locks) # mudinfo channel print "Creating MUDInfo channel!" key, aliases, desc, locks = settings.CHANNEL_MUDINFO print key, aliases, desc, locks create.create_channel(key, aliases=aliases, desc=desc, locks=locks) # connectinfo channel print "Creating ConnecttInfo channel!" key, aliases, desc, locks = settings.CHANNEL_CONNECTINFO print key, aliases, desc, locks create.create_channel(key, aliases=aliases, desc=desc, locks=locks)
def func(self): "Implement the command" caller = self.caller if not self.args: self.msg( "Usage @ccreate <channelname>[;alias;alias..] = description") return description = "" if self.rhs: description = self.rhs lhs = self.lhs channame = lhs aliases = None if ';' in lhs: channame, aliases = [ part.strip().lower() for part in lhs.split(';', 1) if part.strip() ] aliases = [ alias.strip().lower() for alias in aliases.split(';') if alias.strip() ] channel = ChannelDB.objects.channel_search(channame) if channel: self.msg("A channel with that name already exists.") return # Create and set the channel up lockstring = "send:all();listen:all();control:id(%s)" % caller.id new_chan = create.create_channel(channame, aliases, description, locks=lockstring) new_chan.connect(caller) self.msg("Created channel %s and connected to it." % new_chan.key)