def disp_rumors(self, caller, rumors, add_heard=True): table = evtable.EvTable("{w#{n", "{w%s{n" % self.key.capitalize(), border="cells", width=78, align="l", justify=True) x = 0 heard_rumors = caller.ndb.heard_rumors or [] week = get_week() for rumor in rumors: now = time_now() if (now - rumor.db_date_created).days > RUMOR_LIFETIME: continue x += 1 table.add_row(x, rumor.db_message) if add_heard and rumor not in heard_rumors: heard_rumors.append(rumor) if add_heard: caller.ndb.heard_rumors = heard_rumors msg = "{w%s{n" % self.key.capitalize().center(78) msg += "\n" msg += str(table) stories = AssignedTask.objects.filter(finished=True, week__gte=week-3, observer_text__isnull=False) if stories: msg += "\n" msg += "{wOther Rumors{n".center(78) msg += "\n" table = evtable.EvTable("{wRumored Story #{n", "{wWeek{n", border="cells", width=78) for story in stories: table.add_row(story.id, story.week) msg += str(table) return arx_more.msg(caller, msg, justify_kwargs=False)
def start_event(self, event, location=None): # see if this was called from callLater, and if so, remove reference to it if event.id in self.db.pending_start: del self.db.pending_start[event.id] # if we've already started, do nothing. Can happen due to queue if event.id in self.db.active_events: return # announce event start if location: loc = location else: loc = self.get_event_location(event) if loc: # set up event logging, tag room loc.start_event_logging(event) start_str = "%s has started at %s." % (event.name, loc.name) if loc != event.location: event.location = loc event.save() else: start_str = "%s has started." % event.name border = "{w***********************************************************{n\n" if event.public_event: SESSIONS.announce_all(border) SESSIONS.announce_all(start_str) SESSIONS.announce_all(border) elif event.location: try: event.location.msg_contents(start_str, options={'box': True}) except Exception: pass self.db.active_events.append(event.id) self.db.idle_events[event.id] = 0 now = time_now() if now < event.date: # if we were forced to start early, update our date event.date = now event.save() # set up log for event # noinspection PyBroadException try: log = open(self.get_log_path(event.id), 'a+') gmlog = open(self.get_gmlog_path(event.id), 'a+') open_logs = self.ndb.open_logs or [] open_logs.append(log) self.ndb.open_logs = open_logs open_gm_logs = self.ndb.open_gm_logs or [] open_gm_logs.append(gmlog) self.ndb.open_gm_logs = open_gm_logs except Exception: traceback.print_exc()