Ghost-Proxy / Voluspa

Ghost Proxy Proto-Warmind AI
MIT License
2 stars 1 forks source link

Pending Member join notification #49

Open RecursiveHook opened 4 years ago

RecursiveHook commented 4 years ago

image

Three parts to the feature:

  1. use a discord py background task firing every ~18 hrs https://discordpy.readthedocs.io/en/latest/ext/tasks/

  2. which then uses an async request to hit the bungie endpoint https://bungie-net.github.io/#GroupV2.GetPendingMemberships

  3. if returned list is not empty send a message to vanguard-warmind channel.

(There should be patterns already for the async bungie request, there is a nice bungie request conv func, and the parsing should be straightforward. The bg async task does not exist yet, but the link above to the API docs has examples)

RecursiveHook commented 4 years ago

Example of using the Bungie request handler: https://github.com/Ghost-Proxy/Voluspa/blob/develop/cogs/members.py#L149-L157

RecursiveHook commented 4 years ago

And then let's create a new cog called roster_reminder.py and go with the below pattern for now. :+1:

from discord.ext import tasks, commands

class RosterReminder(commands.Cog):
    def __init__(self):
        self.index = 0
        self.printer.start()

    def cog_unload(self):
        self.printer.cancel()

    @tasks.loop(hours=18.0)
    async def printer(self):
        print(self.index)
        self.index += 1