Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Endpoint: Current Mission Data #10

Open
chrislowcher opened this issue Oct 10, 2023 · 2 comments
Open

New Endpoint: Current Mission Data #10

chrislowcher opened this issue Oct 10, 2023 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@chrislowcher
Copy link

Really glad I stumbled upon this project, I have been hoping to find a DRG api for some time now.

Would be awesome to get an endpoint that returned the current active missions along with the mission modifiers, biome, etc. Not sure if there is something similar to the official GSG deepdive endpoint as I don't know much about it.

Is it possible to do something similar to how to deep dive data is pulled? Obviously it is much more frequent as the missions change every 30 mins.

@MoritzHayden MoritzHayden added enhancement New feature or request good first issue Good for newcomers labels Oct 13, 2023
@MoritzHayden
Copy link
Owner

I'm glad you're getting some use out of it! Thank you for your suggestion.

We could probably take advantage of @rolfosian's drgmissions mission data endpoint for this. Since the missions cycle every 30 minutes, it probably wouldn't make sense to cache the result in a JSON file like we're doing for the deep dives. Instead, we could simply call the drgmissions service and have Bosco return the result in a prettified embed.

@rolfosian
Copy link

I started on something like this for a discord bot to go with drgmissions a few weeks ago but lost interest and didn't continue as the website already exists and I think the homepage with the mission icons at https://doublexp.net/ does a better job to show everything than a bot could in any case. Here's what I had anyway without the config and the discord event decorators/30 min scheduler in case you're interested:

def fetch_missions_metadata(domain_url):    
    mission_data = requests.get(f'{domain_url}json?data=current').content
    mission_data = json.loads(mission_data)
    
    Biomes = {}
    for biome, missions in mission_data['Biomes'].items():
        Biomes[biome] = []
        for mission in missions:
            mission['icon_url'] = f'{domain_url}/png?img={biome.replace(" ", "-")}{str(mission["id"])}'
            Biomes[biome].append(mission)
    
    return Biomes

def create_mission_embed(biome, mission):
    embed = discord.Embed(title=biome, color=discord.Color.blue())
    embed.set_image(url=mission['icon_url'])
    return embed

def array_mission_embeds(Biomes):
    Biomes_Embeds = {}
    
    for biome, missions in Biomes.items():
        Biomes_Embeds[biome] = []
        for mission in missions:
            mission_embed = create_mission_embed(biome, mission['icon_url'])
            Biomes_Embeds[biome].append(mission_embed)
    
    return Biomes_Embeds

domain_url = 'https://doublexp.net/'
Biomes = fetch_missions_metadata(domain_url)
Biomes_Embeds = array_mission_embeds(Biomes)

async def send_to_channel(channel_id, Biomes_Embeds):
    pass
async def send_missions_icons(channels):
    coroutines = [send_to_channel(channel) for channel in channels]
    await asyncio.gather(*coroutines)
    pass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants