Пример #1
0
def id_64(value):
    if is_a_URL(value):
        finale_id = steamid.steam64_from_url(value, http_timeout=30)

    else:
        if isinstance(value, str):
            if "STEAM" in value:
                accountID = steamid.steam2_to_tuple(value)[0]
                Steam_Id = steamid.SteamID(accountID)
                finale_id = Steam_Id.as_64

            elif "[U" in value:
                accountID = steamid.steam3_to_tuple(value)[0]
                Steam_Id = steamid.SteamID(accountID)
                finale_id = Steam_Id.as_64

            else:
                possible_URL = 'https://steamcommunity.com/id/{}/'.format(
                    value)
                finale_id = steamid.steam64_from_url(possible_URL,
                                                     http_timeout=30)

        elif isinstance(value, int):
            finale_id = value

    return finale_id
Пример #2
0
    def test_steam64_from_url_timeout(self, mrs_mock):
        mm = mrs_mock.return_value = mock.MagicMock()

        mm.get.side_effect = requests.exceptions.ConnectTimeout('test')
        self.assertIsNone(steamid.steam64_from_url("https://steamcommunity.com/id/timeout_me"))

        mm.get.reset_mock()
        mm.get.side_effect = requests.exceptions.ReadTimeout('test')
        self.assertIsNone(steamid.steam64_from_url("https://steamcommunity.com/id/timeout_me"))
Пример #3
0
    def test_steam64_from_url_timeout(self, mrs_mock):
        mm = mrs_mock.return_value = mock.MagicMock()

        mm.get.side_effect = requests.exceptions.ConnectTimeout('test')
        self.assertIsNone(steamid.steam64_from_url("https://steamcommunity.com/id/timeout_me"))

        mm.get.reset_mock()
        mm.get.side_effect = requests.exceptions.ReadTimeout('test')
        self.assertIsNone(steamid.steam64_from_url("https://steamcommunity.com/id/timeout_me"))
Пример #4
0
    def test_steam64_from_url(self):
        # invalid urls return None
        self.assertIsNone(steamid.steam64_from_url("asdasd"))
        self.assertIsNone(steamid.steam64_from_url("https://steamcommunity.com/gid/0"))

        # try profile urls
        sid = steamid.steam64_from_url('https://steamcommunity.com/profiles/[U:1:12]')
        self.assertEqual(sid, 76561197960265740)

        sid = steamid.steam64_from_url('https://steamcommunity.com/profiles/76561197960265740')
        self.assertEqual(sid, 76561197960265740)

        sid = steamid.steam64_from_url('https://steamcommunity.com/id/johnc')
        self.assertEqual(sid, 76561197960265740)


        # try group urls
        sid = steamid.steam64_from_url('https://steamcommunity.com/gid/[g:1:4]')
        self.assertEqual(sid, 103582791429521412)

        sid = steamid.steam64_from_url('https://steamcommunity.com/gid/103582791429521412')
        self.assertEqual(sid, 103582791429521412)

        sid = steamid.steam64_from_url('https://steamcommunity.com/groups/Valve')
        self.assertEqual(sid, 103582791429521412)
Пример #5
0
    def test_steam64_from_url(self):
        # invalid urls return None
        self.assertIsNone(steamid.steam64_from_url("asdasd"))
        self.assertIsNone(
            steamid.steam64_from_url("https://steamcommunity.com/gid/0"))

        # try profile urls
        sid = steamid.steam64_from_url(
            'https://steamcommunity.com/profiles/[U:1:12]')
        self.assertEqual(sid, '76561197960265740')

        sid = steamid.steam64_from_url(
            'https://steamcommunity.com/profiles/76561197960265740')
        self.assertEqual(sid, '76561197960265740')

        sid = steamid.steam64_from_url('https://steamcommunity.com/id/johnc')
        self.assertEqual(sid, '76561197960265740')

        # try group urls
        sid = steamid.steam64_from_url(
            'https://steamcommunity.com/gid/[g:1:4]')
        self.assertEqual(sid, '103582791429521412')

        sid = steamid.steam64_from_url(
            'https://steamcommunity.com/gid/103582791429521412')
        self.assertEqual(sid, '103582791429521412')

        sid = steamid.steam64_from_url(
            'https://steamcommunity.com/groups/Valve')
        self.assertEqual(sid, '103582791429521412')
Пример #6
0
    def test_steam64_from_url(self):
        def scrub_req(r):
            r.headers.pop('Cookie', None)
            r.headers.pop('date', None)
            return r

        def scrub_resp(r):
            r['headers'].pop('set-cookie', None)
            r['headers'].pop('date', None)
            return r

        with vcr.use_cassette(
                'vcr/steamid_community_urls.yaml',
                mode='once',
                serializer='yaml',
                filter_query_parameters=['nocache'],
                decode_compressed_response=False,
                before_record_request=scrub_req,
                before_record_response=scrub_resp,
        ):
            # invalid urls return None
            self.assertIsNone(steamid.steam64_from_url("asdasd"))
            self.assertIsNone(
                steamid.steam64_from_url("https://steamcommunity.com/gid/0"))

            # try profile urls
            sid = steamid.steam64_from_url(
                'https://steamcommunity.com/profiles/[U:1:12]')
            self.assertEqual(sid, 76561197960265740)

            sid = steamid.steam64_from_url(
                'https://steamcommunity.com/profiles/76561197960265740')
            self.assertEqual(sid, 76561197960265740)

            sid = steamid.steam64_from_url(
                'https://steamcommunity.com/id/johnc')
            self.assertEqual(sid, 76561197960265740)

            sid = steamid.steam64_from_url('https://steamcommunity.com/user/r')
            self.assertEqual(sid, 76561197960265740)

            # try group urls
            sid = steamid.steam64_from_url(
                'https://steamcommunity.com/gid/[g:1:4]')
            self.assertEqual(sid, 103582791429521412)

            sid = steamid.steam64_from_url(
                'https://steamcommunity.com/gid/103582791429521412')
            self.assertEqual(sid, 103582791429521412)

            sid = steamid.steam64_from_url(
                'https://steamcommunity.com/groups/Valve')
            self.assertEqual(sid, 103582791429521412)
Пример #7
0
    async def handle_steam(self, message, link=None):
        """Handle a found steam link."""
        matches = link or re.findall(steamcommunity, message.content)
        steamids = [str(steam64_from_url(m)) for m in matches]

        if not steamids:
            return

        content = 'Here are their permanent counterparts:\n' if not link else ''
        content += '\n'.join(
            f'<https://www.steamcommunity.com/profiles/{id_}/>'
            for id_ in steamids if id_)

        await message.channel.send(content)
Пример #8
0
 async def steam(self, ctx, *args):
     """Link your Steam and Discord accounts for server configuration."""
     args = list(args)
     mentions = parsing.get_all_mentions_in_order(ctx, args)
     if len(mentions) == 1:
         user = mentions[0]
     else:
         user = ctx.author
     if len(args) == 1:
         profile_url = args[0]
         steam64_id = steamid.steam64_from_url(profile_url)
         await ctx.bot.db.users.add_steam64_id(user.id, steam64_id)
         await ctx.send(f"Linked {user.mention} to <{profile_url}>")
     else:
         steam64_id = await ctx.bot.db.users.get_steam64_id(user.id)
         if steam64_id is not None:
             await ctx.send(f"{user.mention}'s steam64_id is {steam64_id}")
         else:
             await ctx.send(f"No steam64_id stored for {user.mention}")
Пример #9
0
    async def _gather_evidence(self, channel, record):
        """Find all attachments and links in a channel"""
        transcript = f"report-{record['id']}.txt"
        attachments, found_links = [], []  # Short for declaring two lists

        with open(transcript, 'a+') as f:
            f.write(
                """Transcript of report {0} opened by user {1}:\n""".format(
                    record['id'], record['author_id']))

            async for message in channel.history(limit=None,
                                                 oldest_first=True):
                f.write("[{0}] {1.author} ({1.author.id}){2}: {1.content}\n".
                        format(
                            message.created_at.strftime('%Y %b %d %H:%M:%S'),
                            message,
                            ' (attachment)' if message.attachments else '',
                        ))

                # Make sure the regex doesn't end with a )
                found_links.extend(
                    m[:-1] if m.endswith(')') else m
                    for m in re.findall(re_link, message.content))
                attachments.extend(message.attachments)

        steamids, links = set(), []
        for link in found_links:
            if 'steamcommunity' not in link:
                links.append(link)
            else:
                # We're gonna handle these later
                steamids.add(steam64_from_url(link))

        for steamid in steamids:
            if steamid is None:
                continue

            links.append(f'https://www.steamcommunity.com/profiles/{steamid}/')

        return transcript, attachments, links
Пример #10
0
def main():

    player_url = input("[+] Player's URL: ")
    player_id = steamid.steam64_from_url(player_url)

    if player_id is None:
        print("[-] Invalid URL.")
    else:
        print("[-] Found ID: {}".format(player_id))

    group = getPlayerInfo(player_id)

    POSSIBLE_GROUP = group

    print("[-] Possible group: {}".format(POSSIBLE_GROUP))

    check_friends = input("Check group members? (Y/N) ")

    if check_friends is not "Y":
        print("[+] Ending.")
        return

    friend_groups = {}

    for username, userid in POSSIBLE_GROUP.items():

        print("[+] Checking userid: {}".format(userid))
        friend_group = getPlayerInfo(userid)

        try:
            friend_groups = {**friend_groups, **friend_group}
        except:
            print("[-] Could not get friend's info.")
            continue

    main_group = {**POSSIBLE_GROUP, **friend_groups}

    print("[-] Final possible group: {}".format(main_group))
Пример #11
0
    def checkBan(self, player_profile):

        player_steam_url = player_profile

        # pull steamid from profile link

        player_steamid = steamid.steam64_from_url(player_steam_url)

        # request etf2l data

        response = requests.get(
            f'https://api.etf2l.org/player/{player_steamid}.json')
        player_bans = response.json()['player']['bans']
        player_bans_out = []
        player_name = response.json()['player']['name']

        #ban check
        if player_bans:
            for ban in player_bans:
                player_bans_out.append(ban['reason'])
            bans = ";".join(player_bans_out)
            return f"{player_name}'s bans: " + bans
        else:
            return f"{player_name} is clean on ETF2L"