def embed_tourney_start(start_date, utc_now, colour=None): fields = [] currently_running = is_tourney_running(start_date, utc_now) starts = get_start_string(currently_running) start_date_formatted = util.get_formatted_date(start_date, True, False) tourney_month = start_date.strftime('%B') delta_start = start_date - utc_now delta_start_formatted = util.get_formatted_timedelta(delta_start) delta_start_txt = f'{delta_start_formatted} ({start_date_formatted})' if currently_running: fields.append( util.get_embed_field_def(starts.capitalize(), start_date_formatted, True)) else: fields.append( util.get_embed_field_def(starts.capitalize(), delta_start_txt, True)) if currently_running: end_date = util.get_first_of_following_month(start_date) delta_end = end_date - utc_now delta_end_formatted = util.get_formatted_timedelta(delta_end, False) fields.append( util.get_embed_field_def('Ends', delta_end_formatted, True)) result = util.create_embed(f'{tourney_month} tournament', None, colour, fields) return result
def format_tourney_start(start_date, utc_now): currently_running = is_tourney_running(start_date, utc_now) starts = get_start_string(currently_running) start_date_formatted = util.get_formatted_date(start_date, True, False) tourney_month = start_date.strftime('%B') delta_start = start_date - utc_now delta_start_formatted = util.get_formatted_timedelta(delta_start) delta_start_txt = f'**{delta_start_formatted}** ({start_date_formatted})' delta_end_txt = '' if currently_running: end_date = util.get_first_of_following_month(start_date) end_date_formatted = util.get_formatted_date(end_date, True, False) delta_end = end_date - utc_now delta_end_formatted = util.get_formatted_timedelta(delta_end, False) delta_end_txt = f' and goes on for another **{delta_end_formatted}** (until {end_date_formatted})' result = f'Tournament in **{tourney_month}** {starts} {delta_start_txt}{delta_end_txt}' return result
def _get_news_details_as_text(news_info: dict) -> list: news_title = news_info['Title'] title = f'__{news_title}__' description = util.escape_escape_sequences(news_info['Description']) while '\n\n' in description: description = description.replace('\n\n', '\n') news_modify_date = util.parse_pss_datetime(news_info['UpdateDate']) if news_modify_date: modify_date = util.get_formatted_date(news_modify_date) title = f'{title} ({modify_date})' link = news_info['Link'].strip() result = [f'**{title}**', description] if link: result.append(f'<{link}>') return result