Esempio n. 1
0
 def add_to_list(self, propname, success, redundant, announce_online=False):
     """
         Add a user to a list, letting them know if the work is redundant.
     If announce_online is true, lets the user know if the target is
     currently online.
     """
     object_list = getattr(self.caller.db, propname)
     if not object_list:
         object_list = []
     adding_list = validate_targets(self.caller,
                                    self.arglist,
                                    ignores=False,
                                    local_only=False)
     net_list = []
     for item in adding_list:
         if item in object_list:
             self.caller.msg(ALERT % "%s %s." % (redundant, item.name))
         else:
             net_list.append(item)
     for item in net_list:
         if announce_online and item.sessions and check_ignores(
                 self.caller, [item], silent=True) and check_hiding(
                     self.caller, [item]):
             self.caller.msg(ALERT % "%s is currently online." % item.name)
         self.caller.msg(ALERT % "%s %s." % (success, item.name))
         object_list.extend(net_list)
     setattr(self.caller.db, propname, object_list)
Esempio n. 2
0
 def toggle_ignores(self, switch):
     """
     Toggle whether or not some folks are ignored.
     """
     targets = validate_targets(self.caller, self.arglist, ignores=False, local_only=False)
     if not targets:
         self.caller.msg("No valid targets found.")
         return
     ignore = self.caller.db.ignore
     if switch:
         for target in targets:
             if target not in ignore:
                 ignore.append(target)
                 self.caller.msg("Ignoring %s." % target.name)
             else:
                 self.caller.msg("Already ignoring %s." % target.name)
             if target.locks.check_lockstring(target, 'admin:perm(Wizards)'):
                 self.caller.msg('{rWARNING: Your ignore will be null as long as %s is an administrator.{n' % target.name)
     else:
         for target in targets:
             if target not in ignore:
                 self.caller.msg("You were not ignoring %s." % target.name)
             else:
                 ignore = [ person for person in ignore if person != target ]
                 self.caller.msg("No longer ignoring %s." % target.name)
     self.caller.db.ignore = ignore
Esempio n. 3
0
 def toggle_hiding(self, switch):
     """
     Toggle whether or not some folks are hidden from.
     """
     targets = validate_targets(self.caller,
                                self.arglist,
                                ignores=False,
                                local_only=False)
     if not targets:
         self.caller.msg("No valid targets found.")
         return
     hiding_from = self.caller.db.hiding_from
     if switch:
         for target in targets:
             if target not in hiding_from:
                 hiding_from.append(target)
                 self.caller.msg("Hiding from %s." % target.name)
             else:
                 self.caller.msg("Already hiding from %s." % target.name)
             if target.locks.check_lockstring(target,
                                              'admin:perm(Wizards)'):
                 self.caller.msg(
                     '{rWARNING: %s is an administrator. Hiding is futile.{n'
                     % target.name)
     else:
         for target in targets:
             if target not in hiding_from:
                 self.caller.msg("You were not hiding from %s." %
                                 target.name)
             else:
                 hiding_from = [
                     person for person in hiding_from if person != target
                 ]
                 self.caller.msg("No longer hiding from %s." % target.name)
     self.caller.db.hiding_from = hiding_from
Esempio n. 4
0
 def toggle_ignores(self, switch):
     """
     Toggle whether or not some folks are ignored.
     """
     targets = validate_targets(self.caller, self.arglist, ignores=False, local_only=False)
     if not targets:
         self.caller.msg("No valid targets found.")
         return
     ignore = self.caller.db.ignore
     if switch:
         for target in targets:
             if target not in ignore:
                 ignore.append(target)
                 self.caller.msg("Ignoring %s." % target.name)
             else:
                 self.caller.msg("Already ignoring %s." % target.name)
             if target.locks.check_lockstring(target, 'admin:perm(Wizards)'):
                 self.caller.msg('{rWARNING: Your ignore will be null as long as %s is an administrator.{n' % target.name)
     else:
         for target in targets:
             if target not in ignore:
                 self.caller.msg("You were not ignoring %s." % target.name)
             else:
                 ignore = [ person for person in ignore if person != target ]
                 self.caller.msg("No longer ignoring %s." % target.name)
     self.caller.db.ignore = ignore
Esempio n. 5
0
 def toggle_hiding(self, switch):
     """
     Toggle whether or not some folks are hidden from.
     """
     targets = validate_targets(self.caller, self.arglist, ignores=False, local_only=False)
     if not targets:
         self.caller.msg("No valid targets found.")
         return
     hiding_from = self.caller.db.hiding_from
     if switch:
         for target in targets:
             if target not in hiding_from:
                 hiding_from.append(target)
                 self.caller.msg("Hiding from %s." % target.name)
             else:
                 self.caller.msg("Already hiding from %s." % target.name)
             if target.locks.check_lockstring(target, 'admin:perm(Wizards)'):
                 self.caller.msg('{rWARNING: %s is an administrator. Hiding is futile.{n' % target.name)
     else:
         for target in targets:
             if target not in hiding_from:
                 self.caller.msg("You were not hiding from %s." % target.name)
             else:
                 hiding_from = [ person for person in hiding_from if person != target ]
                 self.caller.msg("No longer hiding from %s." % target.name)
     self.caller.db.hiding_from = hiding_from
Esempio n. 6
0
 def switch_processor(self):
     """
     Handle command arguments.
     """
     if 'r' in self.switches:
         if self.caller.ndb.page_recent:
             self.targets = check_sleepers(self.caller,
                                           self.caller.ndb.page_recent)
         else:
             self.caller.msg("No one has paged you recently.")
         self.message = self.args
         return True
     if self.rhs:
         self.message = self.rhs
     else:
         self.caller.msg(
             "You must specify a message to send. Did you forget the = sign?"
         )
         return False
     if self.lhslist:
         self.targets = check_sleepers(
             self.caller,
             validate_targets(self.caller,
                              self.lhslist,
                              local_only=self.local_only))
     else:
         self.caller.msg("You must specify people to send the message to.")
     return True
Esempio n. 7
0
    def long_handler(self):
        """
        Handles a long form message by calling a line editor.
        """
        receivers = validate_targets(self.caller,
                                     self.lhslist,
                                     local_only=False)
        if not receivers:
            self.caller.msg('No valid targets found!')
            return
        senders = [self.caller]
        subject = self.rhs
        if not subject:
            self.caller.msg(
                'You must specify a subject. Try: mail/long someone=Hello, there!'
            )
            return

        # The load/save codes define what the editor shall do when wanting to
        # save the result of the editing. This should be a tuple with the first value as a
        # function, and the second value as a dictionary.

        # The save function will have the argument 'editor_result' which will contain a dictionary
        # the line editor sends back. This dictionary will contain 'buffer', the line editor's buffer,
        # and 'caller', the line editor's self.caller.

        # The load function will have the parameters defined by the dictionary in the tuple, as well as
        # an argument 'editor_result', a dictionary which will contain the element 'caller', which holds
        # self.caller.

        # The save function should return a true value if successful, and a false one if it failed.

        loadcode = (lambda **args: '', {})  # Just need an empty string.

        savecode = (self.send_buffer, {
            'subject': subject,
            'senders': [self.caller],
            'receivers': receivers
        })

        editor_key = "mail_message"

        # Start the line editor
        LineEditor(self.caller,
                   loadcode=loadcode,
                   savecode=savecode,
                   key=editor_key)
Esempio n. 8
0
 def main_handler(self):
     """
         Handles arguments if there are no switches. Intended to do the
     'most obvious' action for different arguments.
     """
     MESSAGE = 0
     READ = 2
     if not self.rhs and not self.lhs:
         self.list_mail()
         return
     if self.lhs and not self.rhs:
         try:
             choice = int(self.lhs)
         except ValueError:
             self.caller.msg("'%s' is not a mail message number. Did you mean to send a message to '%s'? If so, try: mail %s=Your message here." % \
                 (self.lhs, self.lhs, self.lhs))
             return
         try:
             # Display numbers are offset.
             message = self.caller.db.mail[choice - 1]
             self.display_mail(message[MESSAGE])
             message[READ] = True
             return
         except (TypeError, IndexError):
             self.caller.msg(
                 'No such message number. To check your mail, type: mail')
             return
     if self.rhs and not self.lhs:
         self.caller.msg('You must specify someone to send mail to.')
         return
     receivers = validate_targets(self.caller,
                                  self.lhslist,
                                  local_only=False)
     if not receivers:
         self.caller.msg('No valid targets found!')
         return
     senders = [self.caller]
     subject = '( Quickmail )'
     body = self.rhs
     sent, status = send_message(senders,
                                 subject,
                                 body,
                                 receivers,
                                 send_email=True)
     self.benediction(sent, status)
Esempio n. 9
0
 def func(self):
     """
     Determine whether we're sensing someone or something, or setting a sense.
     """
     self.switches = [ switch.lower() for switch in self.switches ]
     if 'set' in self.switches:
         self.set_sense_handler()
         return
     if 'here' in self.switches:
         targets = check_ignores(self.caller, self.caller.location.contents)
     else:
         if not self.args:
             self.caller.msg('You must specify a scent to set on yourself or a target and scent.')
             return
         targets = validate_targets(self.caller, self.arglist)
     prefix = len(targets) > 1
     for target in targets:
         self.get_sense(target, prefix=prefix)
Esempio n. 10
0
 def remove_from_list(self, propname, success, redundant):
     """
         Add a user to a list, letting them know if the work is redundant.
     If announce_online is true, lets the user know if the target is
     currently online.
     """
     object_list = getattr(self.caller.db, propname)
     if not object_list:
         object_list = []
     removing_list = validate_targets(self.caller, self.arglist, ignores=False, local_only=False)
     net_list = []
     for item in removing_list:
         if item not in object_list:
             self.caller.msg(ALERT % "%s %s." % (redundant, item.name))
         else:
             net_list.append(item)
     for item in net_list:
         self.caller.msg(ALERT % "%s %s." % (success, item.name))
     cleaned_list = [ item for item in object_list if item not in net_list ]
     setattr(self.caller.db, propname, cleaned_list)
Esempio n. 11
0
 def switch_processor(self):
     """
     Handle command arguments.
     """
     if 'r' in self.switches:
         if self.caller.ndb.page_recent:
             self.targets = check_sleepers(self.caller, self.caller.ndb.page_recent)
         else:
             self.caller.msg("No one has paged you recently.")
         self.message = self.args
         return True
     if self.rhs:
         self.message = self.rhs
     else:
         self.caller.msg("You must specify a message to send. Did you forget the = sign?")
         return False
     if self.lhslist:
         self.targets = check_sleepers(self.caller, validate_targets(self.caller, self.lhslist, local_only=self.local_only))
     else:
         self.caller.msg("You must specify people to send the message to.")
     return True
Esempio n. 12
0
 def add_to_list(self, propname, success, redundant, announce_online=False):
     """
         Add a user to a list, letting them know if the work is redundant.
     If announce_online is true, lets the user know if the target is
     currently online.
     """
     object_list = getattr(self.caller.db, propname)
     if not object_list:
         object_list = []
     adding_list = validate_targets(self.caller, self.arglist, ignores=False, local_only=False)
     net_list = []
     for item in adding_list:
         if item in object_list:
             self.caller.msg(ALERT % "%s %s." % (redundant, item.name))
         else:
             net_list.append(item)
     for item in net_list:
         if announce_online and item.sessions and check_ignores(self.caller, [item], silent=True) and check_hiding(self.caller, [item]):
             self.caller.msg(ALERT % "%s is currently online." % item.name)
         self.caller.msg(ALERT % "%s %s." % (success, item.name))
         object_list.extend(net_list)
     setattr(self.caller.db, propname, object_list)
Esempio n. 13
0
 def main_handler(self):
     """
         Handles arguments if there are no switches. Intended to do the
     'most obvious' action for different arguments.
     """
     MESSAGE = 0
     READ = 2
     if not self.rhs and not self.lhs:
         self.list_mail()
         return
     if self.lhs and not self.rhs:
         try:
             choice = int(self.lhs)
         except ValueError:
             self.caller.msg("'%s' is not a mail message number. Did you mean to send a message to '%s'? If so, try: mail %s=Your message here." % \
                 (self.lhs, self.lhs, self.lhs))
             return
         try:
             # Display numbers are offset.
             message = self.caller.db.mail[choice - 1]
             self.display_mail(message[MESSAGE])
             message[READ] = True
             return
         except (TypeError, IndexError):
             self.caller.msg('No such message number. To check your mail, type: mail')
             return
     if self.rhs and not self.lhs:
         self.caller.msg('You must specify someone to send mail to.')
         return
     receivers = validate_targets(self.caller, self.lhslist, local_only=False)
     if not receivers:
         self.caller.msg('No valid targets found!')
         return
     senders = [self.caller]
     subject = '( Quickmail )'
     body = self.rhs
     sent, status = send_message(senders, subject, body, receivers, send_email=True)
     self.benediction(sent, status)
Esempio n. 14
0
 def remove_from_list(self, propname, success, redundant):
     """
         Add a user to a list, letting them know if the work is redundant.
     If announce_online is true, lets the user know if the target is
     currently online.
     """
     object_list = getattr(self.caller.db, propname)
     if not object_list:
         object_list = []
     removing_list = validate_targets(self.caller,
                                      self.arglist,
                                      ignores=False,
                                      local_only=False)
     net_list = []
     for item in removing_list:
         if item not in object_list:
             self.caller.msg(ALERT % "%s %s." % (redundant, item.name))
         else:
             net_list.append(item)
     for item in net_list:
         self.caller.msg(ALERT % "%s %s." % (success, item.name))
     cleaned_list = [item for item in object_list if item not in net_list]
     setattr(self.caller.db, propname, cleaned_list)
Esempio n. 15
0
    def long_handler(self):
        """
        Handles a long form message by calling a line editor.
        """
        receivers = validate_targets(self.caller, self.lhslist, local_only=False)
        if not receivers:
            self.caller.msg('No valid targets found!')
            return
        senders = [self.caller]
        subject = self.rhs
        if not subject:
            self.caller.msg('You must specify a subject. Try: mail/long someone=Hello, there!')
            return

        # The load/save codes define what the editor shall do when wanting to
        # save the result of the editing. This should be a tuple with the first value as a
        # function, and the second value as a dictionary.

        # The save function will have the argument 'editor_result' which will contain a dictionary
        # the line editor sends back. This dictionary will contain 'buffer', the line editor's buffer,
        # and 'caller', the line editor's self.caller.

        # The load function will have the parameters defined by the dictionary in the tuple, as well as
        # an argument 'editor_result', a dictionary which will contain the element 'caller', which holds
        # self.caller.

        # The save function should return a true value if successful, and a false one if it failed.

        loadcode = (lambda **args: '', {}) # Just need an empty string.

        savecode = (self.send_buffer, {'subject': subject, 'senders' : [self.caller], 'receivers' : receivers})

        editor_key = "mail_message"

        # Start the line editor
        LineEditor(self.caller, loadcode=loadcode, savecode=savecode, key=editor_key)
Esempio n. 16
0
def character_extras(obj, prop_list, prop_dict):
    spirit = obj.db.spirit
    spirit.db._last_puppet = obj
    spirit.db._playable_characters = [ obj ]
    qual_dict = {}
    qualities = obj.get_attribute("qualities")
    if qualities:
        qualities = qualities.split('\n')

        for quality in qualities:
            if quality:
                key, value = quality.split(":",1)
                qual_dict[key.strip()] = value.strip()
    obj.set_attribute("qualities", qual_dict)
    obj.get_attribute_obj('qualities').locks.add('attrread: perm(Wizards) or perm(Immortals) or id(#%s);attredit: perm(Immortals)' % obj.dbobj.id)
    obj.locks.add("puppet:id(%i) or pid(%i) or perm(Immortals) or pperm(Immortals)" % (obj.id, spirit.id))

    stats_dict = { 'Body': 0, 'Soul': 0, 'Expression': 0, 'Mind': 0, 'Focus': 0 }
    for stat in stats_dict.iterkeys():
        try:
            stats_dict[stat] = prop_dict['~wo/' + stat.lower()]["propval"]
        except KeyError:
            pass
    obj.db.stats = stats_dict

    # Join player to public channel, if they are not there already.
    pchanneldef = settings.CHANNEL_PUBLIC
    if pchanneldef:
        pchannel = Channel.objects.get_channel(pchanneldef[0])
        if not pchannel.has_connection(spirit):
            if not pchannel.connect_to(spirit):
                string = "New player '%s' could not connect to public channel!" % new_player.key
                print string

    # Import applause.
    applause = { 'unsorted' : [], 'sorted' : [], 'archived': [], 'upgrades' : 0 }

    applause['unsorted'] = get_applause_list(prop_dict, '@wo/currentapplause')
    keys = prop_dict.keys()

    if '@wo/tonextlevel' in prop_dict:
        applause['upgrades'] = (int(prop_dict['@wo/tonextlevel']['propval']) - 10) / 5

    for applause_type in [ {'base' : '@wo/sortedapplause/', 'category': 'sorted'}, { 'base' : '@wo/archivedapplause/', 'category' : 'archived' } ]:
        applause_type_categories = get_subdirs(prop_dict, applause_type['base'], list_prop=True)
        sorted = []
        for category in applause_type_categories:
            sorted.append({ category : get_applause_list(prop_dict, applause_type['base'] + category)})
        applause[applause_type['category']] = sorted
    obj.set_attribute('applause', applause)
    obj.get_attribute_obj('applause').locks.add('attrread: perm(Wizards) or perm(Immortals);attredit: perm(Immortals)')



    # Import senses.
    sense_dict = {}
    for sense in [ 'smell', 'taste', 'feel' ]:
         sensation = getattr(obj.db, sense)
         if sensation:
             sense_dict[sense] = sensation
             delattr(obj.db, sense)
    obj.db.senses = sense_dict
    obj.get_attribute_obj('senses').locks.add('attrread: all();attredit: id(%s) or perm(Wizards)' % obj.dbobj.id)

    # Import email prefs.
    email_prefs = {}
    for pref in [ 'admin_off', 'applause_off', 'board_off', 'mail_off', 'newsletter_off' ]:
         preference = getattr(obj.db, pref)
         if preference:
             email_prefs[pref] = True
             delattr(obj.db, pref)
    obj.db.email_prefs = email_prefs
    if obj.db.email_disabled:
        obj.db.email_disabled = True
    obj.get_attribute_obj('email_prefs').locks.add('attrread: perm(Immortals) or id(%s);attredit: id(%s) or perm(Immortals)' % (obj.dbobj.id, obj.dbobj.id))

    # Convert watchfor to more sane version.
    watching_list = []
    watching = obj.db.watching
    print "Old watchfor list: %s" % watching
    if watching:
        matches = validate_targets(obj, watching.split(), silent=True, ignores=False, local_only=False)
        print "Target validation: %s" % matches
        watching_list = matches
        print "New Friends: %s" % watching_list
    obj.db.watching = watching_list

    hiding_list = []
    hiding_from = obj.db.hiding_from
    print "Old hidefrom list: %s" % hiding_from
    if hiding_from:
        if '#all' in [ cop.lower() for cop in hiding_from ]:
            obj.db.hiding = True
            print "You'll never find me!"
        hiding_list = validate_targets(obj, hiding_from.split(), silent=True, ignores=False, local_only=False)
        print "Target validation: %s" % hiding_list
    obj.db.hiding_from = hiding_list

    # Set email for users.
    email = obj.db.email
    if email:
        spirit.email = email
        del obj.db.email

    # Set activation for users.
    if obj.db.verified:
        spirit.is_active = True
        spirit.save()
    else:
        spirit.is_active = False

    # Clean up Background and desc for Markdown.
    if obj.db.desc:
        obj.db.desc = markdown_clean(obj.db.desc)
    if obj.db.background:
        obj.db.background = markdown_clean(obj.db.background)

    NAME = 0
    CATEGORY = 2

    # Set up rp tags
    if obj.db.rp_tags:
        rp_tags = [tag.lower() for tag in obj.db.rp_tags.split() if tag.lower() in tags_dict ]
        for tag in rp_tags:
            print "Setting tag for '%s'..." % tag
            tag = tags_dict[tag]
            print tag
            obj.tags.add(tag[NAME], category=tag[CATEGORY])

    timestamp = obj.db.submit_time
    approvers = validate_targets(obj, str(obj.db.approvers).split(), silent=True, ignores=False, local_only=False)
    if timestamp or approvers:
        if not timestamp:
            timestamp = 0
        timestamp = float(timestamp)
        local_tz = pytz.timezone("America/Chicago")
        utc_dt = datetime.utcfromtimestamp(timestamp).replace(tzinfo=pytz.utc)
        obj.db.submit_time = utc_dt
        obj.db.approvers = approvers