コード例 #1
0
ファイル: models.py プロジェクト: volundmush/athanor
 def setup_channels(self):
     if self.ic_channel:
         ic_channel = self.ic_channel
         ic_channel.key = 'group_%s_ic' % self.key
     else:
         self.ic_channel = create_channel('group_%s_ic' % self.key, typeclass='athanor.classes.channels.GroupIC')
         self.save(update_fields=['ic_channel'])
         self.ic_channel.init_locks(group=self)
     if self.ooc_channel:
         ooc_channel = self.ooc_channel
         ooc_channel.key = 'group_%s_ooc' % self.key
     else:
         self.ooc_channel = create_channel('group_%s_ooc' % self.key, typeclass='athanor.classes.channels.GroupOOC')
         self.save(update_fields=['ooc_channel'])
         self.ooc_channel.init_locks(group=self)
コード例 #2
0
ファイル: comms.py プロジェクト: ergodicbreak/evennia
    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 = lhs.split(';', 1)
            aliases = [alias.strip().lower() for alias in aliases.split(';')]
        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.strip(),
                                         aliases,
                                         description,
                                         locks=lockstring)
        new_chan.connect(caller)
        CHANNELHANDLER.update()
        self.msg("Created channel %s and connected to it." % new_chan.key)
コード例 #3
0
ファイル: initial_setup.py プロジェクト: Antraeus/evennia
def create_channels():
    """
    Creates some sensible default channels.
    """
    print " Creating default channels ..."

    goduser = get_god_player()
    for channeldict in settings.DEFAULT_CHANNELS:
        channel = create.create_channel(**channeldict)
        channel.connect(goduser)
コード例 #4
0
ファイル: initial_setup.py プロジェクト: BlauFeuer/evennia
def create_channels():
    """
    Creates some sensible default channels.

    """
    logger.log_info("Creating default channels ...")

    goduser = get_god_account()
    for channeldict in settings.DEFAULT_CHANNELS:
        channel = create.create_channel(**channeldict)
        channel.connect(goduser)
コード例 #5
0
ファイル: scripts.py プロジェクト: remy-r/evennia
    def at_start(self):
        """Set up the event system when starting.

        Note that this hook is called every time the server restarts
        (including when it's reloaded).  This hook performs the following
        tasks:

        -   Create temporarily stored events.
        -   Generate locals (individual events' namespace).
        -   Load eventfuncs, including user-defined ones.
        -   Re-schedule tasks that aren't set to fire anymore.
        -   Effectively connect the handler to the main script.

        """
        self.ndb.events = {}
        for typeclass, name, variables, help_text, custom_call, custom_add in EVENTS:
            self.add_event(typeclass, name, variables, help_text, custom_call, custom_add)

        # Generate locals
        self.ndb.current_locals = {}
        self.ndb.fresh_locals = {}
        addresses = ["evennia.contrib.ingame_python.eventfuncs"]
        addresses.extend(getattr(settings, "EVENTFUNCS_LOCATIONS", ["world.eventfuncs"]))
        for address in addresses:
            if pypath_to_realpath(address):
                self.ndb.fresh_locals.update(all_from_module(address))

        # Restart the delayed tasks
        now = datetime.now()
        for task_id, definition in tuple(self.db.tasks.items()):
            future, obj, event_name, locals = definition
            seconds = (future - now).total_seconds()
            if seconds < 0:
                seconds = 0

            delay(seconds, complete_task, task_id)

        # Place the script in the CallbackHandler
        from evennia.contrib.ingame_python import typeclasses
        CallbackHandler.script = self
        DefaultObject.callbacks = typeclasses.EventObject.callbacks

        # Create the channel if non-existent
        try:
            self.ndb.channel = ChannelDB.objects.get(db_key="everror")
        except ChannelDB.DoesNotExist:
            self.ndb.channel = create_channel("everror", desc="Event errors",
                    locks="control:false();listen:perm(Builders);send:false()")
コード例 #6
0
ファイル: models.py プロジェクト: volundmush/athanor
 def setup(self):
     if not self.channel:
         self.channel = create_channel('%s' % self.key, typeclass='classes.channels.RadioChannel')
         self.channel.init_locks()
         self.save()