Example #1
0
    async def handle(self, params, message, mentioned_user, client):
        partialName = " ".join(params)
        clansearch = []
        for clanid in clanids:
            returnjson = await getJSONfromURL(
                f"https://www.bungie.net/Platform/GroupV2/{clanid}/Members?nameSearch={partialName}"
            )
            clansearch.append(returnjson)

        embed = embed_message(f'Possible matches for {partialName}')

        for result in clansearch:
            resp = result['Response']
            if not resp['results']:
                await message.channel.send(embed=embed_message(
                    f'Possible matches for {partialName}', "No matches found"))
                return

            i = 0
            for guy in resp['results']:
                i += 1
                steam_name = guy['destinyUserInfo']['LastSeenDisplayName']
                bungie_name = guy['bungieNetUserInfo']['displayName']
                destinyID = guy['destinyUserInfo']['membershipId']
                discordID = lookupDiscordID(destinyID)
                embed.add_field(
                    name=f"Option {i}",
                    value=
                    f"Discord - <@{discordID}>\nSteamName - {steam_name}\nBungieName - {bungie_name}",
                    inline=False)

        await message.channel.send(embed=embed)
Example #2
0
def neriapi(destinyid):
    if not sha256(
            bytes(request.headers.get('x-neriapi-key', 'missing'), 'utf-8'),
            encoder=HexEncoder
    ) == b'e3143238a43d9f1c12f47314a8c858a5589f1b2f5c174d391a0e361f869b1427':
        return jsonify(status=500, error='Wrong api key')
    discordID = loop.run_until_complete(lookupDiscordID(destinyid))
    if not discordID:
        return jsonify(status=500, error='Unknown destiny id')
    token = loop.run_until_complete(getToken(discordID))
    refresh_token = loop.run_until_complete(getRefreshToken(discordID))
    if not token:
        return jsonify(status=500, error='Token not found')
    return jsonify(status=200, token=token, refresh_token=refresh_token)
    async def handle(self, params, message, mentioned_user, client):

        for clanid, name in clanids.items():
            await message.channel.send(f'matching members for clan {name}')
            clanmap = await getNameAndCrossaveNameToHashMapByClanid(clanid)
            successfulMatches = []
            unsuccessfulMatches = []
            for userid, (steamname, crosssavename) in clanmap.items():
                discordID = lookupDiscordID(userid)
                if discordID:
                    # user could be matched
                    guy = client.get_user(discordID)
                    if guy:
                        successfulMatches.append(
                            (steamname, crosssavename, guy.name))
                    else:
                        await message.channel.send(
                            f'[ERROR] {steamname}/{crosssavename} with destinyID {userid} has discordID {discordID} but it is faulty'
                        )
                else:
                    # user not found
                    unsuccessfulMatches.append(
                        (steamname, crosssavename, userid))

            await message.channel.send('SUCCESSFUL MATCHES:')
            sortedSuccessfulMatches = sorted(successfulMatches,
                                             key=lambda pair: pair[2].lower())
            successfulMessage = ''
            for (steamname, crosssavename,
                 username) in sortedSuccessfulMatches:
                successfulMessage += f'{username:<30} - {steamname} / {crosssavename}\n'

            if len(successfulMessage) < 2000:
                await message.channel.send(successfulMessage)
            else:
                remainingMessage = successfulMessage
                while curMessage := remainingMessage[:1900]:
                    await message.channel.send(curMessage)
                    remainingMessage = remainingMessage[1900:]
            await message.channel.send('FAILED MATCHES:')
            unsuccessfulMessage = ''
            for (steamname, crosssavename, userid) in unsuccessfulMatches:
                unsuccessfulMessage += f'{steamname} / {crosssavename} (Steam-ID {userid}) could not be found in Discord \n'

            if unsuccessfulMessage:
                await message.channel.send(unsuccessfulMessage)
            else:
                await message.channel.send(
                    'No unsuccessful matches <:PogU:670369128237760522>')
 async def handle(self, params, message, mentioned_user, client):
     naughtylist = []
     for clanid, name in clanids.items():
         await message.channel.send(f'checking clan {name}')
         clanmap = await getNameToHashMapByClanid(clanid)
         for username, userid in clanmap.items():
             discordID = lookupDiscordID(userid)
             if discordID:  #if the matching exists in the DB, check whether the discordID is valid and in the server
                 guy = client.get_user(discordID)
                 if not guy:  #TODO implement actual 'present in server'-check
                     await message.channel.send(
                         f'[ERROR] {username} with destinyID {userid} has discordID {discordID} registered, but it is faulty or user left the server'
                     )
                     continue
                 #await message.channel.send(f'{username} is in Discord with name {user.name}')
             else:
                 naughtylist.append(username)
                 await message.channel.send(
                     f'{username} with ID {userid} is not in Discord (or not recognized by the bot)'
                 )
     await message.channel.send(f'users to check: {", ".join(naughtylist)}')
Example #5
0
    async def handle(self, params, message, mentioned_user, client):
        # get all clan members discordID
        memberlist = []
        for member in (await getJSONfromURL(
                f"https://www.bungie.net/Platform/GroupV2/{CLANID}/Members/")
                       )["Response"]["results"]:
            destinyID = int(member["destinyUserInfo"]["membershipId"])
            memberlist.append(destinyID)

        not_in_discord_or_registered = []  # list of destinyID
        no_token = []  # list of guild.member.mention
        not_accepted_rules = []  # list of guild.member.mention

        # loop through all members and check requirements
        for destinyID in memberlist:
            # check if in discord or still having the old force registration
            discordID = lookupDiscordID(destinyID)
            if discordID is None:
                not_in_discord_or_registered.append(str(destinyID))
                continue
            member = message.guild.get_member(discordID)
            if member is None:
                not_in_discord_or_registered.append(str(destinyID))
                continue

            # check if no token
            if not getToken(discordID):
                no_token.append(member.mention)

            # check if accepted rules
            if member.pending:
                not_accepted_rules.append(member.mention)

        if not_in_discord_or_registered:
            textstr = ", ".join(not_in_discord_or_registered)
            while tempstr := textstr[:1900]:
                await message.channel.send(
                    "**These destinyIDs are not in discord, or have not registered with the bot**\n"
                    + tempstr)
                textstr = textstr[1900:]
Example #6
0
    async def handle(self, params, message, mentioned_user, client):
        # check if user has permission to use this command
        if not await hasAdminOrDevPermissions(message):
            return

        # if disord info is given
        if mentioned_user is not message.author:
            discordID = mentioned_user.id
            destinyID = lookupDestinyID(discordID)

        # if destinyID is given
        else:
            destinyID = params[0]
            discordID = lookupDiscordID(destinyID)
            mentioned_user = client.get_user(discordID)
            if not mentioned_user:
                await message.reply(
                    f"I don't know a user with the destinyID `{destinyID}`")

        await message.reply(embed=embed_message(
            f'DB infos for {mentioned_user.name}',
            f"""DiscordID - `{discordID}` \nDestinyID: `{destinyID}` \nSystem - `{lookupSystem(destinyID)}` \nSteamName - `{(await getProfile(destinyID, 100))["profile"]["data"]["userInfo"]["displayName"]}` \nHasToken - `{bool((await handleAndReturnToken(discordID))["result"])}`"""
        ))