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)
def func(self): """ Contructs the desired loop based on switches. """ construction = [ self.get_name, self.get_online_time, self.get_idle_time, self.get_status, self.get_location ] self.switches = [ switch.lower() for switch in self.switches ] if not getattr(self.caller, 'locks', None) or not \ ('wiz' in self.switches and self.caller.locks.check_lockstring(self.caller, 'admin:perm(Immortals)')): self.admin = False # This is a session, not a player. construction.append(self.get_doing) else: construction.append(self.get_host) self.admin = True header = '' separator = ' ' for function in construction: header += '%s%s{n' % (function.color, function.title) padding = function.spacing - len(function.title) header += separator * padding self.caller.msg(header) users = [ [session, ''] for session in SESSIONS.get_sessions() if check_ignores(self.caller, [session.get_character()], silent=True) ] if not self.admin: users = [ user for user in users if user[Who.SESSION].get_character() ] for user in users: for function in construction: user[Who.STRING] += function.color + "%%-%ss" % function.spacing % function(user[Who.SESSION]) + '{n' self.caller.msg(user[Who.STRING])
def check_list(self, target, listname, ignores=True): """ Checks to see if target is in one of the character's personal lists. """ list_to_check = getattr(self.db, listname) if not list_to_check: return False if target in list_to_check: if ignores: if not check_ignores(target, [self], silent=True): return False return True return False
def display_watching(self): watching_list = self.caller.db.watching if not watching_list: self.caller.msg(ALERT % "You are not watching anyone. If you find someone interesting, or meet a friend, be sure to watch them with: watch {yYourFriend'sNameHere{n") return watching_list = check_ignores(self.caller, watching_list, silent=True) watching_list = check_sleepers(self.caller, watching_list, silent=True) watching_list = check_hiding(self.caller, watching_list) ROW_LENGTH = 4 watching_list = [watching_list[i:i+ROW_LENGTH] for i in range(0, len(watching_list), ROW_LENGTH)] if not watching_list: self.caller.msg("{cNo one you are watching is online.{n") return self.caller.msg("{cPeople online that you are watching:{n") for group in watching_list: self.caller.msg("%-20s"*len(group) % tuple(group))
def send_buffer(self, senders, subject, receivers, editor_result): """ This function is called by the line editor when its work is complete. """ # If we're not quitting, we're not doing anything. if not editor_result['quitting']: self.caller.msg('Saving a draft is not yet supported. Use :wq to send the message, or :q! to abort.') return False # If you're typing out a really long mail, you may have annoyed someone in the interim. body = editor_result['buffer'] receivers = check_ignores(self.caller, receivers) if not receivers: self.caller.msg('No valid recipients found!') return False sent, status = send_message(senders, subject, body, receivers, send_email=True) return self.benediction(sent, status)
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)
def func(self): """ Contructs the desired loop based on switches. """ construction = [ self.get_name, self.get_online_time, self.get_idle_time, self.get_status, self.get_location ] self.switches = [switch.lower() for switch in self.switches] if not getattr(self.caller, 'locks', None) or not \ ('wiz' in self.switches and self.caller.locks.check_lockstring(self.caller, 'admin:perm(Immortals)')): self.admin = False # This is a session, not a player. construction.append(self.get_doing) else: construction.append(self.get_host) self.admin = True header = '' separator = ' ' for function in construction: header += '%s%s{n' % (function.color, function.title) padding = function.spacing - len(function.title) header += separator * padding self.caller.msg(header) users = [[session, ''] for session in SESSIONS.get_sessions() if check_ignores(self.caller, [session.get_character()], silent=True)] if not self.admin: users = [ user for user in users if user[Who.SESSION].get_character() ] for user in users: for function in construction: user[ Who. STRING] += function.color + "%%-%ss" % function.spacing % function( user[Who.SESSION]) + '{n' self.caller.msg(user[Who.STRING])
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)
def display_watching(self): watching_list = self.caller.db.watching if not watching_list: self.caller.msg( ALERT % "You are not watching anyone. If you find someone interesting, or meet a friend, be sure to watch them with: watch {yYourFriend'sNameHere{n" ) return watching_list = check_ignores(self.caller, watching_list, silent=True) watching_list = check_sleepers(self.caller, watching_list, silent=True) watching_list = check_hiding(self.caller, watching_list) ROW_LENGTH = 4 watching_list = [ watching_list[i:i + ROW_LENGTH] for i in range(0, len(watching_list), ROW_LENGTH) ] if not watching_list: self.caller.msg("{cNo one you are watching is online.{n") return self.caller.msg("{cPeople online that you are watching:{n") for group in watching_list: self.caller.msg("%-20s" * len(group) % tuple(group))
def send_buffer(self, senders, subject, receivers, editor_result): """ This function is called by the line editor when its work is complete. """ # If we're not quitting, we're not doing anything. if not editor_result['quitting']: self.caller.msg( 'Saving a draft is not yet supported. Use :wq to send the message, or :q! to abort.' ) return False # If you're typing out a really long mail, you may have annoyed someone in the interim. body = editor_result['buffer'] receivers = check_ignores(self.caller, receivers) if not receivers: caller.msg('No valid recipients found!') return False sent, status = send_message(senders, subject, body, receivers, send_email=True) return self.benediction(sent, status)
def announce_message(self, user, target, message, message_key, must_be_online=False): """ Sends an announcement to other characters. message is a string to send. message_key is a label for the type of message being sent. An announcement that a user is connection might have this as "connection". must_be_online makes the message cancel if the user disconnects before the targets receive it. """ if (must_be_online and not self.sessions) or (not check_hiding(user, [target])) or (not check_ignores(target, [self], silent=True) ) \ or self.db.hiding or message_key in ignored_notifications(target): return target.msg(message)