def get_timezone_info_text(state): name = state.get_value("timezone", DEFAULT_TIMEZONE) offset_seconds = state.offset_seconds text = FormattedText().normal("Timezone abbreviation: ").bold( name).newline() if offset_seconds is None: text.bold("No").normal(" offset set.") else: text.bold(offset_seconds).normal(" seconds of offset.") return text
def get_response_list(event, action_params, handler): text = FormattedText().normal("List of pole timezones:").newline() for alias in handler.get_timezones(): state = handler.get_timezone_state(alias) name = state.get_value("timezone", DEFAULT_TIMEZONE) text.bold(alias).normal(" → ").bold(name) offset_seconds = state.offset_seconds if offset_seconds is not None: text.normal(" (with ").bold(offset_seconds).normal( " seconds offset)") text.newline() return text.build_message()
def list_settings(settings): keys = settings.list() response = FormattedText().normal( "Settings status for this chat:").newline() for setting_name, value, default_value, is_set, is_supported in keys: response.newline() if not is_supported: response.code_inline(setting_name) elif is_set: response.bold(setting_name) else: response.normal(setting_name) response.normal(" → ").code_inline(value) if is_set and is_supported: response.normal(" (default: ").code_inline( default_value).normal(")") return response.build_message()
def _add_info(self, label: str, value, separator: str = ":", additional_text: str = ""): info = FormattedText()\ .normal("{label}{separator} {value}")\ .start_format()\ .normal(label=label)\ .normal(separator=separator) if isinstance(value, FormattedText): info.concat(value=value) else: info.bold(value=value) info = info.end_format() if additional_text: info.normal(" ").normal(additional_text) self._add(info)