def info_task(source: CommandSource, title: str, headline_override: Union[None, str, RTextBase] = None) -> None: # Get task instance try: target_task = GlobalVariables.task_manager[title] except TaskNotFound: task_not_found(source) if DEBUG_MODE: raise return # Task detail text headline = tr("info_task_title") if isinstance(headline_override, str): headline = tr(headline_override) if isinstance(headline_override, RTextBase): headline = headline_override headline.set_color(RColor.green).set_styles(RStyle.bold) task_title_text = title_text(target_task, display_full_path=True, with_edit_button=True) info_desc = info_elements(target_task) info_ddl = info_elements(target_task, EditButtonType.deadline) info_priority = info_elements(target_task, EditButtonType.priority) info_res = info_responsibles(target_task) info_sub = info_sub_tasks(target_task) # Show task text source.reply( RText.join('\n', [ headline, task_title_text, info_desc, info_ddl, info_priority, info_res, info_sub ]))
def task_timed_out(server: PluginServerInterface, player: str, player_tasks: List[Task]): text = tr("on_player_joined", len(player_tasks)).set_color(RColor.red).set_styles(RStyle.bold) for t in player_tasks: text.append( '\n', title_text(t, display_full_path=True, display_not_empty_mark=True)) server.tell(player, text)
def list_task(source: CommandSource): headline = tr('list_task_title').set_styles(RStyle.bold).set_color( RColor.green) + ' ' + add_task_button() task_list_text = [] for task in GlobalVariables.task_manager.sorted_sub_tasks: task_list_text.append(title_text(task, display_not_empty_mark=True)) task_list_text = RTextBase.join('\n', task_list_text) text = [headline, task_list_text] source.reply(RText.join('\n', text))
def task_overview(source: CommandSource): GlobalVariables.debug('Running overview...') headline = tr('overview_headline').set_styles(RStyle.bold).set_color( RColor.green) + ' ' + add_task_button() # Get task instances deadline_approaching = GlobalVariables.task_manager.seek_for_item_with_deadline_approaching( ) GlobalVariables.debug(deadline_approaching) max_length = GlobalVariables.config.overview_maximum_task_amount priority_amount = max_length - len(deadline_approaching) with_priorities = [] if priority_amount > 0: with_priorities = GlobalVariables.task_manager.seek_for_item_with_priority( ) # Found no matched task handle if len(deadline_approaching) == 0 and len(with_priorities) == 0: task_text = tr('no_priority').set_color(RColor.yellow) # Organize task texts else: task_texts = {} for task in deadline_approaching: if len(task_texts ) >= GlobalVariables.config.overview_maximum_task_amount: break task_texts[task.titles] = RText('[!] ', RColor.red).h( tr('date_approaching', formatted_time( task.deadline))) + title_text(task, display_full_path=True) for task in with_priorities: if len(task_texts ) >= GlobalVariables.config.overview_maximum_task_amount: break if task.title not in task_texts.keys(): task_texts[task.titles] = RText('[!] ', RColor.gold).h( tr('has_a_high_priority', task.priority)) + title_text( task, display_full_path=True) task_text = RTextBase.join('\n', task_texts.values()) help_message = tr('overview_help', PREFIX).set_translator(GlobalVariables.htr) source.reply(RTextBase.join('\n', [headline, task_text, help_message]))
def all_tasks_detail(source: CommandSource): task_details = [ tr("detailed_info_task_title").set_color(RColor.green).set_styles( RStyle.bold) + ' ' + add_task_button() ] for task in GlobalVariables.task_manager.sorted_sub_tasks: task_details.append( title_text(task, include_sub=False, display_not_empty_mark=True)) if len(task.sub_tasks) > 0: task_details.append(sub_task_title_text(task, indent=8)) source.reply(RTextBase.join('\n', task_details))
def info_player(source: CommandSource, name: str) -> None: tasks = list(GlobalVariables.task_manager.responsible_manager[name]) text = [ tr("player_tasks_title", name, str(len(tasks))).set_color(RColor.green).set_styles(RStyle.bold), ] for task in tasks: text.append( title_text(task, display_full_path=True, display_not_empty_mark=True)) source.reply(RText.join('\n', text))