Example #1
0
 def switch_rename(self, lhs, rhs):
     try:
         slot_name = valid_slot(lhs)
         new_name = valid_slot(rhs)
     except ValueError as err:
         self.error(unicode(err))
         return
     slot = self.character.radio.filter(key__istartswith=slot_name).first()
     if not slot:
         self.error("Radio slot not found.")
         return
     if self.character.radio.filter(key__iexact=new_name).exclude(id=slot.id).count():
         self.error("That name would conflict with another slot.")
         return
     slot.key = new_name
     slot.save()
     self.sys_msg("Slot renamed to: %s" % new_name)
Example #2
0
 def switch_broadcast(self, lhs, rhs):
     try:
         slot_name = valid_slot(lhs)
     except ValueError as err:
         self.error(unicode(err))
         return
     if not rhs:
         self.error("What will you say?")
         return
     slot = self.character.radio.filter(key__istartswith=slot_name).first()
     chan = slot.frequency.channel
     chan.msg(rhs, senders=self.character, slot=slot)
Example #3
0
 def switch_ungag(self, lhs, rhs):
     try:
         slot_name = valid_slot(lhs)
     except ValueError as err:
         self.error(unicode(err))
         return
     slot = self.character.radio.filter(key__istartswith=slot_name).first()
     if not slot:
         self.error("Radio slot not found.")
         return
     slot.ungag()
     self.sys_msg("Radio slot un-gagged.")
Example #4
0
 def switch_off(self, lhs, rhs):
     try:
         slot_name = valid_slot(lhs)
     except ValueError as err:
         self.error(unicode(err))
         return
     slot = self.character.radio.filter(key__istartswith=slot_name, on=True).first()
     if not slot:
         self.error("Radio slot not found. Are any of your slots on?")
         return
     slot.switch_off()
     self.sys_msg("Radio slot de-activated.")
Example #5
0
 def switch_freq(self, lhs, rhs):
     try:
         slot_name = valid_slot(lhs)
         freq_name = valid_freq(rhs)
     except ValueError as err:
         self.error(unicode(err))
         return
     slot = self.character.radio.filter(key__istartswith=slot_name).first()
     if not slot:
         self.error("Radio slot not found.")
         return
     freq, created = RadioFrequency.objects.get_or_create(key=freq_name)
     if created:
         freq.setup()
     slot.tune(freq)
     self.sys_msg("You have tuned into %s on Slot '%s'!" % (freq_name, slot_name))
Example #6
0
 def switch_init(self, lhs, rhs):
     try:
         slot_name = valid_slot(lhs)
         freq_name = valid_freq(rhs)
     except ValueError as err:
         self.error(unicode(err))
         return
     if self.character.radio.filter(key__iexact=freq_name):
         self.error("You already have a slot by that name. Use /rename if you wish to change its name or /freq to re-tune it.")
         return
     freq, created = RadioFrequency.objects.get_or_create(key=freq_name)
     if created:
         freq.setup()
     self.character.radio.create(key=slot_name, frequency=freq)
     freq.channel.connect(self.character)
     self.sys_msg("You have tuned into %s on Slot '%s'!" % (freq_name, slot_name))
Example #7
0
 def switch_title(self, lhs, rhs):
     try:
         slot_name = valid_slot(lhs)
     except ValueError as err:
         self.error(unicode(err))
         return
     slot = self.character.radio.filter(key__istartswith=slot_name).first()
     if not slot:
         self.error("Radio slot not found.")
         return
     if rhs:
         slot.title = sanitize_string(rhs)
         slot.save(update_fields=['title'])
         self.sys_msg("Title changed to: %s" % rhs)
     else:
         slot.title = None
         slot.save(update_fields=['title'])
         self.sys_msg("Title cleared.")
Example #8
0
 def switch_color(self, lhs, rhs):
     try:
         slot_name = valid_slot(lhs)
     except ValueError as err:
         self.error(unicode(err))
         return
     slot = self.character.radio.filter(key__istartswith=slot_name).first()
     if not slot:
         self.error("Radio slot not found.")
         return
     if rhs:
         if len(ANSIString('|%s' % rhs)) != 0:
             self.error("That is not a valid color code.")
             return
         slot.color = sanitize_string(rhs)
         slot.save(update_fields=['color'])
         self.sys_msg("Color changed to: %s" % rhs)
     else:
         slot.color = None
         slot.save(update_fields=['color'])
         self.sys_msg("Color cleared.")
Example #9
0
 def switch_codename(self, lhs, rhs):
     try:
         slot_name = valid_slot(lhs)
     except ValueError as err:
         self.error(unicode(err))
         return
     slot = self.character.radio.filter(key__istartswith=slot_name).first()
     if not slot:
         self.error("Radio slot not found.")
         return
     if rhs:
         if Character.objects.filter_family(db_key__iexact=rhs).count():
             self.error("Cannot set your codename to an existing character's name.")
             return
         slot.codename = sanitize_string(rhs)
         slot.save(update_fields=['codename'])
         self.sys_msg("Codename changed to: %s" % rhs)
     else:
         slot.codename = None
         slot.save(update_fields=['codename'])
         self.sys_msg("Codename cleared.")