async def get_nextrace_displaytext(match_list: list) -> str: utcnow = pytz.utc.localize(datetime.datetime.utcnow()) if len(match_list) > 1: display_text = 'Upcoming matches: \n' else: display_text = 'Next match: \n' for match in match_list: # noinspection PyUnresolvedReferences display_text += '\N{BULLET} **{0}** - **{1}**'.format( match.racer_1.display_name, match.racer_2.display_name) if match.suggested_time is None: display_text += '\n' continue display_text += ': {0} \n'.format( timestr.timedelta_to_str(match.suggested_time - utcnow, punctuate=True)) match_cawmentator = await match.get_cawmentator() if match_cawmentator is not None: display_text += ' Cawmentary: <http://www.twitch.tv/{0}> \n'.format( match_cawmentator.twitch_name) elif match.racer_1.twitch_name is not None and match.racer_2.twitch_name is not None: display_text += ' Kadgar: {} \n'.format( rtmputil.kadgar_link(match.racer_1.twitch_name, match.racer_2.twitch_name)) # display_text += ' RTMP: {} \n'.format( # rtmputil.rtmp_link(match.racer_1.rtmp_name, match.racer_2.rtmp_name) # ) display_text += '\nFull schedule: <https://condor.host/schedule>' return display_text
async def get_nextrace_displaytext(match_list: list) -> str: utcnow = pytz.utc.localize(datetime.datetime.utcnow()) if len(match_list) > 1: display_text = 'Upcoming matches: \n' else: display_text = 'Next match: \n' for match in match_list: if match.league_tag in emotes.nd_emotes: display_text += '{2} **{0}** - **{1}**'.format( match.racer_1.display_name, match.racer_2.display_name, emotes.nd_emotes[match.league_tag]) else: display_text += '\N{BULLET} **{0}** - **{1}** ({2})'.format( match.racer_1.display_name, match.racer_2.display_name, match.format_str) if match.suggested_time is None: display_text += '\n' continue display_text += f': {timestr.discord_timestamp_for_match(match.suggested_time)} \n' match_cawmentator = await match.get_cawmentator() if match_cawmentator is not None: display_text += ' Cawmentary: <http://www.twitch.tv/{0}> \n'.format( match_cawmentator.twitch_name) elif match.racer_1.twitch_name is not None and match.racer_2.twitch_name is not None: display_text += ' Kadgar: {} \n'.format( rtmputil.kadgar_link(match.racer_1.twitch_name, match.racer_2.twitch_name)) display_text += '\nFull schedule: <https://condor.live/schedule>' return display_text
async def match_alert(self, match: Match) -> None: """Post an alert that the match is about to begin in the main channel Parameters ---------- match: Match """ alert_format_str = "The match **{racer_1}** - **{racer_2}** is scheduled to begin in {minutes} " \ "minutes. :timer: \n" \ "{stream}" minutes_until_match = int( (match.time_until_match.total_seconds() + 30) // 60) cawmentator = await match.get_cawmentator() if cawmentator is not None: stream = 'Commentary: <http://www.twitch.tv/{0}>'.format( cawmentator.twitch_name) else: stream = 'Kadgar: {}'.format( rtmputil.kadgar_link(match.racer_1.twitch_name, match.racer_2.twitch_name)) # stream = 'RTMP: {}'.format(rtmputil.rtmp_link(match.racer_1.rtmp_name, match.racer_2.rtmp_name)) await self._client.send_message( self._main_channel, alert_format_str.format(racer_1=match.racer_1.display_name, racer_2=match.racer_2.display_name, minutes=minutes_until_match, stream=stream))
async def _match_alert(self, match: Match) -> None: """Post an alert that the match is about to begin in the main channel Parameters ---------- match: Match """ alert_format_str = "The match {em}**{racer_1}** - **{racer_2}** is scheduled to begin {timestamp}. :timer: \n" \ "{stream}" cawmentator = await match.get_cawmentator() if cawmentator is not None: stream = 'Cawmentary: <http://www.twitch.tv/{0}>'.format(cawmentator.twitch_name) else: stream = 'Kadgar: {}'.format(rtmputil.kadgar_link(match.racer_1.twitch_name, match.racer_2.twitch_name)) await self._main_channel.send( alert_format_str.format( em=emotes.get_emote_str(match.league_tag), racer_1=match.racer_1.display_name, racer_2=match.racer_2.display_name, timestamp=match.discord_rel_timestamp, stream=stream ) ) matchroom = await matchchannelutil.get_match_room(match) # type: Optional[MatchRoom] if matchroom is not None: await matchroom.add_cawmentator_permissions()