Example #1
0
async def check_tomorrow(ctx, resort_key):
    logger.debug(
        f'async def check_tomorrow: Command ("!checktomorrow {resort_key}"): Author ({ctx.author}): Channel: ({ctx.channel})'
    )

    guild_id = bot.get_guild(int(748917163313725704))
    role = guild_id.get_role(int(800907308887572521))
    member = guild_id.get_member(ctx.author.id)

    dmchannel = await ctx.author.create_dm()

    # Checks if the user is a member, if they are, it executes it.
    if role in member.roles:
        logger.debug(
            f'async def check_tomorrow: {ctx.author} role authorization successful'
        )

        if resort_key in snow_report.RESORT_KEYS:
            logger.debug(
                f'async def check_tomorrow: Sending requested information')

            resort_object = snow_report.Resort(resort_key)
            resort_object.request_96hr()
            resort_temp_tomorrow = resort_object.get_tomorrow_temp()
            resort_feelslike_tomorrow = resort_object.get_tomorrow_feelslike()
            resort_precipitation_tomorrow = resort_object.get_tomorrow_precipitation(
            )
            resort_precipitation_type_tomorrow = resort_object.get_tomorrow_precipitation_type(
            )

            await ctx.send(
                f'Checking the weather for tomorrow at {resort_object.name}... please check your DM'
            )
            await dmchannel.send(
                f'<{resort_object.name}> Temperature: {resort_temp_tomorrow} degrees C'
            )
            await dmchannel.send(
                f'<{resort_object.name}> Feels like: {resort_feelslike_tomorrow} degrees C'
            )
            await dmchannel.send(
                f'<{resort_object.name}> Total precipitation tomorrow: {resort_precipitation_tomorrow} mm'
            )
            await dmchannel.send(
                f'<{resort_object.name}> Precipitation types: {resort_precipitation_type_tomorrow}'
            )

        else:
            logger.debug(
                f'async def check_tomorrow: Error, cannot find {resort_key}')
            await ctx.send(f'Checking weather.. please check your DM')
            await dmchannel.send(
                f'Error, I cannot find the key "{resort_key}" in my database, please check the key and try again.'
            )

# Checks if the user is a member, if not, it asks the users to !accept the rules
    else:
        logger.debug(
            f'async def check_tomorrow: Author {ctx.author} not part of Member role.'
        )
        await ctx.send('Invalid command, please !accept the rules.')
Example #2
0
async def USA_snow_report(ctx):
    logger.debug(
        f'async def USA_snow_report: Command ("!USAsnow"): Author ({ctx.author}): Channel: ({ctx.channel})'
    )

    guild_id = bot.get_guild(int(748917163313725704))
    role = guild_id.get_role(int(800907308887572521))
    member = guild_id.get_member(ctx.author.id)

    # Checks if the user is a member, if they are, it executes it.
    if role in member.roles:

        logger.debug(
            f'async def USA_snow_report: {ctx.author} role authorization successful'
        )
        logger.debug(
            f'async def USA_snow_report: Checking snow reports for USA resorts... sending to {ctx.author} DM'
        )
        await ctx.send(
            f'Checking snow reports for American resorts.... please note that 0mm total precipitation does not mean there is no snow, it just means that the snowfall is not significant.'
        )
        await ctx.send(f'Please check your DM')

        dmchannel = await ctx.author.create_dm()

        for resort_key in snow_report.USA_RESORTS:
            logger.debug(
                f'async def USA_snow_report: Sending data for resort {resort_key}'
            )
            resort_object = snow_report.Resort(resort_key)
            resort_object.request_96hr()
            # resort_temp = resort_object.get_temperature_96hr()
            resort_precipitation_type = resort_object.get_precipitation_type_96hr(
            )
            resort_precipitation = resort_object.get_precipitation_96hr()

            total_precipitation = 0
            for preciptation_value in resort_precipitation.values():
                total_precipitation = int(preciptation_value) + int(
                    total_precipitation)

            if 'snow' in resort_precipitation_type.values():
                await dmchannel.send(
                    f'{resort_object.name} is expecting snow in the next 4 days ({total_precipitation} mm)'
                )
            else:
                await dmchannel.send(
                    f'{resort_object.name} is not expecting snow in the next 4 days'
                )

        logger.debug(f'async def USA_snow_report: Completed command loop')
        await dmchannel.send(f'Complete')

# Checks if the user is a member, if not, it asks the users to !accept the rules
    else:
        logger.debug(f'Author {ctx.author} not part of Member role.')
        await ctx.send('Invalid command, please !accept the rules.')
Example #3
0
async def check_feelslike_now(ctx, resort_key):
    logger.debug(
        f'async def feelslike_now: Command ("!checkfeelslike {resort_key}"): Author ({ctx.author}): Channel: ({ctx.channel})'
    )

    guild_id = bot.get_guild(int(748917163313725704))
    role = guild_id.get_role(int(800907308887572521))
    member = guild_id.get_member(ctx.author.id)

    dmchannel = await ctx.author.create_dm()

    # Checks if the user is a member, if they are, it executes it.
    if role in member.roles:
        logger.debug(
            f'async def feelslike_now: {ctx.author} role authorization successful'
        )

        if resort_key in snow_report.RESORT_KEYS:
            logger.debug(
                f'async def check_feelslike_now: Sending requested information'
            )
            await ctx.send(
                f'Checking "feels like" temperature... please check your DM')

            resort_object = snow_report.Resort(resort_key)
            resort_object.request_now()
            resort_feelslike = resort_object.now_feelslike

            await dmchannel.send(
                f'It currently feels like {resort_feelslike} degrees C at {resort_object.name}'
            )

        else:
            logger.debug(
                f'async def feelslike_now: Error, cannot find {resort_key}')
            await ctx.send(
                f'Checking "feels like" temperature... please check your DM')
            await dmchannel.send(
                f'Error, I cannot find the key "{resort_key}" in my database, please check the key and try again.'
            )

# Checks if the user is a member, if not, it asks the users to !accept the rules
    else:
        logger.debug(
            f'async def check_feelslike_now: Author {ctx.author} not part of Member role.'
        )
        await ctx.send('Invalid command, please !accept the rules.')
Example #4
0
async def check_4day_snow(ctx, resort_key):
    logger.debug(
        f'async check_4day_snow: Command ("!checksnow {resort_key}"): Author ({ctx.author}): Channel: ({ctx.channel})'
    )

    guild_id = bot.get_guild(int(748917163313725704))
    role = guild_id.get_role(int(800907308887572521))
    member = guild_id.get_member(ctx.author.id)

    dmchannel = await ctx.author.create_dm()

    # Checks if the user is a member, if they are, it executes it.
    if role in member.roles:
        logger.debug(
            f'async def check_4day_snow: {ctx.author} role authorization successful'
        )

        if resort_key in snow_report.RESORT_KEYS:
            logger.debug(
                f'async def check_4day_snow: Checking if snow is in the forecast for requested resort'
            )
            await ctx.send(f'Checking forecast... please check your DM')
            await dmchannel.send(
                f'Checking for snow for resort key {resort_key}, please wait a few seconds for me to work....'
            )

            resort_object = snow_report.Resort(resort_key)
            resort_object.request_96hr()
            # resort_temp = resort_object.get_temperature_96hr()
            resort_precipitation_type = resort_object.get_precipitation_type_96hr(
            )
            resort_precipitation = resort_object.get_precipitation_96hr()

            total_precipitation = 0
            for preciptation_value in resort_precipitation.values():
                total_precipitation = int(preciptation_value) + int(
                    total_precipitation)

            logger.debug(
                f'async def check_4day_snow: Sending requested information')
            if 'snow' in resort_precipitation_type.values():
                await dmchannel.send(
                    f'{resort_object.name} is expecting snow in the next 4 days ({total_precipitation} mm)'
                )
            else:
                await dmchannel.send(
                    f'{resort_object.name} is not expecting snow in the next 4 days'
                )

        else:
            await ctx.send(f'Checking forecast... please check your DM')
            await dmchannel.send(
                f'Error, I cannot find the key "{resort_key}" in my database, please check the key and try again'
            )
            logger.debug(
                f'async def check_4day_snow: Error, cannot find {resort_key}')

# Checks if the user is a member, if not, it asks the users to !accept the rules
    else:
        logger.debug(
            f'async def check_4day_snow: Author {ctx.author} not part of Member role.'
        )
        await ctx.send('Invalid command, please !accept the rules.')