async def configuration(self): guild = discordbot.get_guild(590331405624410116) return TournamentConfig( guild=guild, racetime_category='sgl', racetime_goal="Beat the game", event_slug="sgl21alttpr", audit_channel=discordbot.get_channel(772351829022474260), commentary_channel=discordbot.get_channel(631564559018098698), coop=False)
async def configuration(self): guild = discordbot.get_guild(590331405624410116) return TournamentConfig( guild=guild, racetime_category='twwr', racetime_goal="Spoiler Log Race", event_slug="sgl21twwr", audit_channel=discordbot.get_channel(772351829022474260), commentary_channel=discordbot.get_channel(631564559018098698), coop=False, stream_delay=60, gsheet_id=os.environ.get("SGL_RESULTS_SHEET"))
async def configuration(self): guild = discordbot.get_guild(508335685044928540) return TournamentConfig( guild=guild, racetime_category='test', racetime_goal='Beat the game', event_slug="test", audit_channel=discordbot.get_channel(537469084527230976), commentary_channel=discordbot.get_channel(659307060499972096), scheduling_needs_channel=discordbot.get_channel( 835699086261747742), create_scheduled_events=True)
async def configuration(self): guild = discordbot.get_guild(590331405624410116) return TournamentConfig( guild=guild, racetime_category='sgl', racetime_goal="Minecraft 2v2", event_slug="sgl21minecraft2v2", audit_channel=discordbot.get_channel(772351829022474260), commentary_channel=discordbot.get_channel(631564559018098698), coop=True, gsheet_id=os.environ.get("SGL_RESULTS_SHEET"), auto_record=True)
async def configuration(self): guild = discordbot.get_guild(590331405624410116) return TournamentConfig( guild=guild, racetime_category='sgl', racetime_goal="Super Metroid Link to the Past Combo Randomizer", event_slug="sgl21smz3", audit_channel=discordbot.get_channel(772351829022474260), commentary_channel=discordbot.get_channel(631564559018098698), coop=False, gsheet_id=os.environ.get("SGL_RESULTS_SHEET"), auto_record=True)
async def configuration(self): guild = discordbot.get_guild(590331405624410116) return TournamentConfig( guild=guild, racetime_category='sgl', racetime_goal="Pokemon Mystery Dungeon Sky Randomizer", event_slug="sgl21pkmnredrando", audit_channel=discordbot.get_channel(772351829022474260), commentary_channel=discordbot.get_channel(631564559018098698), coop=False, gsheet_id=os.environ.get("SGL_RESULTS_SHEET"), auto_record=True)
async def configuration(self): guild = discordbot.get_guild(590331405624410116) return TournamentConfig( guild=guild, racetime_category='sgl', racetime_goal="Ocarina of Time Randomizer", event_slug="sgl21ootr", audit_channel=discordbot.get_channel(772351829022474260), commentary_channel=discordbot.get_channel(631564559018098698), coop=False, stream_delay=15, gsheet_id=os.environ.get("SGL_RESULTS_SHEET"), auto_record=True)
async def configuration(self): guild = discordbot.get_guild(470200169841950741) return TournamentConfig( guild=guild, racetime_category='alttpr', racetime_goal='Beat the game', event_slug="alttprfr", audit_channel=discordbot.get_channel(856581631241486346), commentary_channel=discordbot.get_channel(470202208261111818), helper_roles=[ guild.get_role(482266765137805333), guild.get_role(507932829527703554), ], lang='fr')
async def configuration(self): guild = discordbot.get_guild(469300113290821632) return TournamentConfig( guild=guild, racetime_category='alttpr', racetime_goal='Beat the game', event_slug="alttprcd", audit_channel=discordbot.get_channel(473668481011679234), commentary_channel=discordbot.get_channel(469317757331308555), helper_roles=[ guild.get_role(534030648713674765), guild.get_role(469300493542490112), guild.get_role(623071415129866240), ], lang='de')
async def configuration(self): guild = discordbot.get_guild(753727862229565612) return TournamentConfig( guild=guild, racetime_category='smw-hacks', racetime_goal='Any%', event_slug="smwde", audit_channel=discordbot.get_channel(826775494329499648), scheduling_needs_channel=discordbot.get_channel( 835946387065012275), helper_roles=[ guild.get_role(754845429773893782), guild.get_role(753742980820631562), ], lang='de', gsheet_id='1BrkmhNPnpjNUSUx5yGrnm09XbfAFhYDsi-7-fHp62qY', )
async def configuration(self): guild = discordbot.get_guild(460905692857892865) return TournamentConfig( guild=guild, racetime_category='smz3', racetime_goal='Beat the games', event_slug="smz3coop", audit_channel=discordbot.get_channel(516808047935619073), commentary_channel=discordbot.get_channel(687471466714890296), scheduling_needs_channel=discordbot.get_channel( 864249492370489404), scheduling_needs_tracker=True, helper_roles=[ guild.get_role(464497534631542795), ], coop=True, )
async def configuration(self): guild = discordbot.get_guild(535946014037901333) return TournamentConfig( guild=guild, racetime_category='alttpr', racetime_goal='Beat the game (glitched)', event_slug="alttprhmg", audit_channel=discordbot.get_channel(850226062864023583), commentary_channel=discordbot.get_channel(549709098015391764), scheduling_needs_channel=discordbot.get_channel( 863817206452977685), scheduling_needs_tracker=True, helper_roles=[ guild.get_role(549709214000480276), guild.get_role(535962854004883467), guild.get_role(535962802230132737), ])
async def configuration(self): guild = discordbot.get_guild(477850508368019486) return TournamentConfig( guild=guild, racetime_category='alttpr', racetime_goal='Beat the game', event_slug="alttpres", audit_channel=discordbot.get_channel(859058002426462211), commentary_channel=discordbot.get_channel(838011943000080395), scheduling_needs_channel=discordbot.get_channel( 863771537903714324), scheduling_needs_tracker=True, helper_roles=[ guild.get_role(479423657584754698), guild.get_role(477968190606016528), ], lang="es")
async def configuration(self): guild = discordbot.get_guild(469300113290821632) return TournamentConfig( guild=guild, racetime_category='alttpr', racetime_goal='Beat the game', event_slug="alttprmini", audit_channel=discordbot.get_channel(473668481011679234), commentary_channel=discordbot.get_channel(469317757331308555), helper_roles=[ guild.get_role(534030648713674765), guild.get_role(469300493542490112), guild.get_role(623071415129866240), ], lang='de', stream_delay=10, gsheet_id='1dWzbwxoErGQyO4K1tZ-EexX1bdnTGuxQhLJDnmfcaR4', )
async def configuration(self): guild = discordbot.get_guild(543577975032119296) return TournamentConfig( guild=guild, racetime_category='alttpr', racetime_goal='Beat the game', event_slug="invleague", audit_channel=discordbot.get_channel(546728638272241674), commentary_channel=discordbot.get_channel(611601587139510322), scheduling_needs_channel=discordbot.get_channel( 878075812996337744), scheduling_needs_tracker=True, helper_roles=[ guild.get_role(543596853871116288), guild.get_role(543597099649073162), guild.get_role(676530377812082706), guild.get_role(553295025190993930), guild.get_role(674109759179194398), ], stream_delay=10)
async def configuration(self): guild = discordbot.get_guild(334795604918272012) return TournamentConfig( guild=guild, racetime_category='alttpr', racetime_goal='Beat the game', event_slug="alttpr", audit_channel=discordbot.get_channel(647966639266201620), commentary_channel=discordbot.get_channel(408347983709470741), scheduling_needs_channel=discordbot.get_channel(434560353461075969), scheduling_needs_tracker=True, helper_roles=[ guild.get_role(334797023054397450), guild.get_role(435200206552694794), guild.get_role(482353483853332481), guild.get_role(426487540829388805), guild.get_role(613394561594687499), guild.get_role(334796844750209024) ] )
async def configuration(self): guild = discordbot.get_guild(155487315530088448) return TournamentConfig( guild=guild, racetime_category='sm', racetime_goal='Triple Bingo', event_slug="smbingo", audit_channel=discordbot.get_channel(871187586687856670), helper_roles=[ guild.get_role(404395533482983447), guild.get_role(338121128004288513), guild.get_role(173917459785449472), ])
async def configuration(self): guild = discordbot.get_guild(334795604918272012) return TournamentConfig( guild=guild, racetime_category='alttpr', racetime_goal='Beat the game', event_slug="alttpr", audit_channel=discordbot.get_channel(647966639266201620), commentary_channel=discordbot.get_channel(947095820673638400), scheduling_needs_channel=discordbot.get_channel( 434560353461075969), scheduling_needs_tracker=True, create_scheduled_events=True, stream_delay=10, gsheet_id='1epZRDXfe-O4BBerzOEZbFMOVCFrVXU6TCDNjp66P7ZI', helper_roles=[ guild.get_role(334797023054397450), guild.get_role(435200206552694794), guild.get_role(482353483853332481), guild.get_role(426487540829388805), guild.get_role(613394561594687499), guild.get_role(334796844750209024) ])
async def create_smm2_match_discord(episode_id, force): race = await sgl2020_tournament.get_tournament_race_by_episodeid(episode_id) if race and not force: return False sgl_race = await SGLiveRace.construct(episode_id=episode_id) await sgl_race.create_seed() smm2_category_id = int(await config.get(sgl_race.guild.id, 'SGLSMM2Category')) match_channel = await sgl_race.guild.create_text_channel( slugify(f"smm2-{episode_id}-{sgl_race.versus}"), category=discord.utils.get( sgl_race.guild.categories, id=smm2_category_id), topic=f"{sgl_race.event_name} - {sgl_race.versus} - {sgl_race.permalink}" ) audit_channel_id = await config.get(sgl_race.guild.id, 'SGLAuditChannel') audit_channel = discordbot.get_channel(int(audit_channel_id)) await audit_channel.send(f"SMM2 Match - Episode {sgl_race.episode_data['id']} - {match_channel.mention}") volunteer_channel_id = await config.get(sgl_race.guild.id, 'SGLVolunteerChannel') if volunteer_channel_id is not None: volunteer_channel = discordbot.get_channel(int(volunteer_channel_id)) await volunteer_channel.send(f"{sgl_race.event_name} - {sgl_race.versus} - Episode {sgl_race.episode_data['id']} - {match_channel.mention}") embed = discord.Embed( title=f"SMM2 Match Channel Opened - {sgl_race.event_name} - {sgl_race.versus}", description=f"Greetings! The discord channel {match_channel.mention} has been opened.\n\nGLHF!", color=discord.Colour.blue(), timestamp=datetime.datetime.now() ) if broadcast_channels := sgl_race.broadcast_channels: embed.insert_field_at( 0, name="Broadcast Channels", value=', '.join([f"[{a}](https://twitch.tv/{a})" for a in broadcast_channels]), inline=False)
async def race_recording_task(bo3=False): guild_id = await config.get(0, 'SGLAuditChannel') audit_channel_id = await config.get(guild_id, 'SGLAuditChannel') audit_channel = discordbot.get_channel(int(audit_channel_id)) if bo3: races = await sgl2020_tournament_bo3.get_unrecorded_races() else: races = await sgl2020_tournament.get_unrecorded_races() for race in races: print(race['episode_id']) try: await record_episode(race, bo3=bo3) except Exception as e: logging.exception( "Encountered a problem when attempting to record a race.") if audit_channel: await audit_channel.send( f"There was an error while automatically creating a race room for episode `{race['episode_id']}`.\n\n{str(e)}") print('done')
async def scan_sgl_schedule(): guild_id = await config.get(0, 'SGLAuditChannel') audit_channel_id = await config.get(guild_id, 'SGLAuditChannel') audit_channel = discordbot.get_channel(int(audit_channel_id)) if c.DEBUG: events = ['test'] else: events = EVENTS.keys() print("SGL - scanning SG schedule for races to create") for event in events: await asyncio.sleep(1) # this keeps SG's API from getting rekt try: delay = 0 if c.DEBUG else EVENTS[event]['delay']/60 episodes = await speedgaming.get_upcoming_episodes_by_event(event, hours_past=0.5, hours_future=.53+delay) except Exception as e: logging.exception( "Encountered a problem when attempting to retrieve SG schedule.") if audit_channel: await audit_channel.send( f"There was an error while trying to scan schedule for {event}`.\n\n{str(e)}") continue for episode in episodes: print(episode['id']) try: await create_sgl_match(episode) except Exception as e: logging.exception( "Encountered a problem when attempting to create RT.gg race room.") if audit_channel: await audit_channel.send( f"<@185198185990324225> There was an error while automatically creating a race room for episode `{episode['id']}`.\n\n{str(e)}", allowed_mentions=discord.AllowedMentions( everyone=True) ) print('done')
async def process_league_race(target, args, client): srl_id = srl.srl_race_id(target) srl_race = await srl.get_race(srl_id) if not srl_race['game']['abbrev'] == 'alttphacks': await client.message(target, "This must be an alttphacks race.") return await client.message(target, "Generating game, please wait. If nothing happens after a minute, contact Synack.") race = await srl_races.get_srl_race_by_id(srl_id) if race: await client.message(target, "There is already a game generated for this room. To cancel it, use the $cancel command.") return generated_league_race = await league_race(episodeid=args.episodeid, week=args.week) player_names = generated_league_race.get_player_names() player_discords = generated_league_race.get_player_discords() goal = f"ALTTPR League - {', '.join(player_names)} - {generated_league_race.friendly_name}" await client.message(target, f".setgoal {goal}") embed = await generated_league_race.seed.embed( name=goal, emojis=discordbot.emojis ) tournament_embed = await generated_league_race.seed.tournament_embed( name=goal, notes="The permalink for this seed was sent via direct message to each runner.", emojis=discordbot.emojis ) broadcast_channels = [a['name'] for a in generated_league_race.episode['channels'] if not a['name'] == 'No Stream'] for channel in broadcast_channels: await twitch_command_text.insert_command_text(channel.lower(), "mode", generated_league_race.twitch_mode_command) if len(broadcast_channels) > 0: tournament_embed.insert_field_at( 0, name="Broadcast Channels", value=', '.join([f"[{a}](https://twitch.tv/{a})" for a in broadcast_channels]), inline=False) embed.insert_field_at( 0, name="Broadcast Channels", value=', '.join([f"[{a}](https://twitch.tv/{a})" for a in broadcast_channels]), inline=False) audit_channel_id = await config.get(generated_league_race.guild.id, 'AlttprLeagueAuditChannel') if audit_channel_id is not None: audit_channel = discordbot.get_channel(int(audit_channel_id)) await audit_channel.send(embed=embed) commentary_channel_id = await config.get(generated_league_race.guild.id, 'AlttprLeagueCommentaryChannel') if commentary_channel_id is not None and len(broadcast_channels) > 0: commentary_channel = discordbot.get_channel(int(commentary_channel_id)) await commentary_channel.send(embed=tournament_embed) for player in player_discords: try: await player.send(embed=embed) except discord.HTTPException: if audit_channel is not None: await audit_channel.send(f"@here could not send DM to {player.name}#{player.discriminator}") if generated_league_race.type == 'spoiler': await spoiler_races.insert_spoiler_race(srl_id, generated_league_race.spoiler_log_url, generated_league_race.studyperiod) await srl_races.insert_srl_race(srl_id, generated_league_race.goal_after_start) await tournament_results.insert_tournament_race( srl_id=srl_id, episode_id=generated_league_race.episodeid, permalink=generated_league_race.seed.url, event='alttprleague', week=generated_league_race.week, spoiler=generated_league_race.spoiler_log_url if generated_league_race.spoiler_log_url else None ) await client.message(target, "Seed has been generated, you should have received a DM in Discord. Please contact a League Moderator if you haven't received the DM.")
async def check_race(srl_id): race = await srl.get_race(srl_id) # only report on alttphacks races for now, make this configurable in the future if not race['game']['abbrev'] == 'alttphacks': return configguilds = await config.get_all_parameters_by_name( 'AltHunterReportingChannel') for entrant in race['entrants']: try: pastraces = await srl.get_pastraces(game=race['game']['abbrev'], player=entrant, pagesize=0) except aiohttp.client_exceptions.ClientResponseError: print(f'could not get history of {entrant}, skipping...') continue if pastraces['count'] == 0: print(f'{entrant} is new') pastraces_all = await srl.get_pastraces(game=None, player=entrant, pagesize=0) if pastraces_all['count'] > 50: continue twitch_nick = race['entrants'][entrant]['twitch'] if twitch_nick == '': twitch_info = None else: try: twitch_info = await get_twitch_user(twitch_nick) except aiohttp.client_exceptions.ClientResponseError: print(f'could not find twitch info for {entrant}') twitch_info = None embed = discord.Embed( title="New Racer Detected!", description= f"A new racer named [{entrant}](http://www.speedrunslive.com/profiles/#!/{entrant}/1) began racing in [#srl-{race['id']}](http://www.speedrunslive.com/race/?id={race['id']})", color=discord.Colour.red(), timestamp=datetime.datetime.now()) if twitch_info is not None: created_at = datetime.datetime.strptime( twitch_info['created_at'], "%Y-%m-%dT%H:%M:%S.%fZ") embed.add_field( name='Twitch Nickname', value=f"[{twitch_nick}](https://twitch.tv/{twitch_nick})", inline=False) embed.add_field(name='Account Created Date', value=f"{created_at}", inline=False) embed.set_thumbnail(url=twitch_info['logo']) if pastraces_all['count'] > 0: embed.add_field( name= f"Total SRL Races (outside of {race['game']['abbrev']})", value=pastraces_all['count'], inline=False) for configguild in configguilds: channel = discordbot.get_channel(int(configguild['value'])) await channel.send(embed=embed)
def race_room_log_channel(self): return discordbot.get_channel(774336581808291863)
async def process_sgl_race(handler): bo3 = False await handler.send_message("Generating game, please wait. If nothing happens after a minute, contact Synack.") race_original = await sgl2020_tournament.get_active_tournament_race(handler.data.get('name')) race_bo3 = await sgl2020_tournament_bo3.get_tournament_race(handler.data.get('name')) if race_original: race = race_original elif race_bo3: race = race_bo3 bo3 = True else: raise Exception("This race should have an SG episode associated with it. Please contact a Tournament Admin for assistance.") episodeid = race.get('episode_id') try: sgl_race = await SGLiveRace.construct(episode_id=episodeid) except Exception as e: logging.exception("Problem creating SGL race.") await handler.send_message(f"Could not process league race: {str(e)}") return try: await sgl_race.create_seed() except Exception as e: logging.exception("Problem rolling SGL race.") await handler.send_message(f"Could not process league race: {str(e)}") return start_time = sgl_race.race_start_time.astimezone(pytz.timezone('US/Eastern')).strftime('%I:%M %p Eastern') await handler.set_raceinfo(f"{sgl_race.event_name} - {sgl_race.versus}{sgl_race.goal_postfix}{sgl_race.delay_info} - Scheduled race start at {start_time}", overwrite=True) await handler.send_message(sgl_race.permalink) if sgl_race.delay_minutes: await handler.send_message(f"This is a reminder this race has a {sgl_race.delay_minutes} minute stream delay in effect. Please ensure your delay is correct. If you need a stream override, please contact a SGL admin for help.") embed = discord.Embed( title=f"{sgl_race.event_name} - {sgl_race.versus}", color=discord.Colour.red(), timestamp=datetime.datetime.now() ) embed.add_field(name="Permalink", value=sgl_race.permalink, inline=False) if sgl_race.bingo_password: embed.add_field(name="Bingosync Password", value=sgl_race.bingo_password) embed.add_field( name="RT.gg", value=f"https://racetime.gg{handler.data['url']}", inline=False) audit_channel_id = await config.get(sgl_race.guild.id, 'SGLAuditChannel') audit_channel = discordbot.get_channel(int(audit_channel_id)) await audit_channel.send(embed=embed) if sgl_race.bingo_password and sgl_race.broadcast_channels: admin_channel_id = await config.get(sgl_race.guild.id, 'SGLAdminChannel') admin_channel = discordbot.get_channel(int(admin_channel_id)) await admin_channel.send(embed=embed) if bo3: await sgl2020_tournament_bo3.insert_tournament_race( room_name=handler.data.get('name'), episode_id=episodeid, permalink=sgl_race.permalink, seed=sgl_race.seed_id, password=sgl_race.bingo_password, event=sgl_race.episode_data['event']['slug'], platform='racetime' ) else: await sgl2020_tournament.insert_tournament_race( room_name=handler.data.get('name'), episode_id=episodeid, permalink=sgl_race.permalink, seed=sgl_race.seed_id, password=sgl_race.bingo_password, event=sgl_race.episode_data['event']['slug'], platform='racetime' ) await handler.send_message("Seed has been generated and should now be in the race info.") handler.seed_rolled = True
def race_room_log_channel(self): return discordbot.get_channel(678695059016646697)
def announce_channel(self): return discordbot.get_channel(307861467838021633)
def announce_channel(self): return discordbot.get_channel(508335685044928548)
) embed_tracker = discord.Embed( title=f"RT.gg Room Opened - {sgl_race.event_name} - {sgl_race.versus}", description=f"Greetings! This is a friendly reminder that a race you're assigned to track will be starting soon. Please be on the lookout for a DM from a volunteer.", color=discord.Colour.blue(), timestamp=datetime.datetime.now() ) if broadcast_channels := sgl_race.broadcast_channels: embed.insert_field_at( 0, name="Broadcast Channels", value=', '.join([f"[{a}](https://twitch.tv/{a})" for a in broadcast_channels]), inline=False) embed_tracker.insert_field_at( 0, name="Broadcast Channels", value=', '.join([f"[{a}](https://twitch.tv/{a})" for a in broadcast_channels]), inline=False) audit_channel_id = await config.get(sgl_race.guild.id, 'SGLAuditChannel') audit_channel = discordbot.get_channel(int(audit_channel_id)) await audit_channel.send(embed=embed) volunteer_channel_id = await config.get(sgl_race.guild.id, 'SGLVolunteerChannel') if volunteer_channel_id is not None: volunteer_channel = discordbot.get_channel(int(volunteer_channel_id)) await volunteer_channel.send(f"{sgl_race.event_name} - {sgl_race.versus} - Episode {sgl_race.episode_data['id']} - <https://racetime.gg{handler.data['url']}>") for name, player in sgl_race.player_discords: if player is None: await audit_channel.send(f'<@185198185990324225> Could not DM player named {name}', allowed_mentions=discord.AllowedMentions(everyone=True)) continue try: await player.send(embed=embed) except discord.HTTPException: await audit_channel.send(f'<@185198185990324225> Could not send room opening DM to player named {name}', allowed_mentions=discord.AllowedMentions(everyone=True))
embed.insert_field_at(0, name="Broadcast Channels", value=', '.join([ f"[{a}](https://twitch.tv/{a})" for a in broadcast_channels ]), inline=False) goal += f" - Restream(s) at {', '.join(broadcast_channels)}" await handler.set_raceinfo(goal, overwrite=True) audit_channel_id = await config.get(league_race.guild.id, 'AlttprLeagueAuditChannel') if audit_channel_id is not None: audit_channel = discordbot.get_channel(int(audit_channel_id)) await audit_channel.send(embed=embed) commentary_channel_id = await config.get( guild_id=league_race.guild.id, parameter='AlttprLeagueCommentaryChannel' if league_race.episode['event'].get('slug', 'invleague') == 'invleague' else 'AlttprLeagueOpenCommChannel') commentary_channel = discordbot.get_channel(int(commentary_channel_id)) if commentary_channel and len(broadcast_channels) > 0: await commentary_channel.send(embed=tournament_embed) for name, player in league_race.player_discords: if player is None: await audit_channel.send( f"@here could not send DM to {name}",