forked from a-moss/PoGoAccountCheck
/
banned.py
executable file
·132 lines (106 loc) · 3.89 KB
/
banned.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""banned.py - Check multiple PTC accounts ban status with Pokemon Go."""
from pgoapi import PGoApi
from pgoapi.exceptions import ServerSideRequestThrottlingException
from pgoapi.exceptions import NotLoggedInException
from pgoapi.exceptions import BannedAccountException
import time
import sys
import os
import argparse
import re
def parse_arguments(args):
"""Parse the command line arguments for the console commands.
Args:
args (List[str]): List of string arguments to be parsed.
Returns:
Namespace: Namespace with the parsed arguments.
"""
parser = argparse.ArgumentParser(
description='Pokemon Trainer Club Banned Account Checker'
)
parser.add_argument(
'-f', '--file', type=str, default=None, required=True,
help='File of accounts to check (RocketMap csv format).'
)
parser.add_argument(
'-l', '--location', type=str, default="40.7127837 -74.005941",
required=False,
help='Location to use when checking if the accounts are banned.'
)
parser.add_argument(
'-hk', '--hash-key', type=str, default=None, required=True,
help='Key for hash server.'
)
return parser.parse_args(args)
def check_account(provider, username, password, location, api):
api.set_position(location[0], location[1], 0.0)
try:
if not api.login(provider, username, password):
__accountFailed(username)
return False
except BannedAccountException:
# Banned :(
__accountBanned(username)
return False
time.sleep(1)
req = api.create_request()
req.get_inventory()
response = req.call()
# For some reason occasionally api.login lets fake ptc accounts slip
# through.. this will block em
if type(response) is NotLoggedInException:
__accountFailed(username)
return False
if response['status_code'] == 3:
__accountBanned(username)
return False
else:
print('{} is not banned...'.format(username))
return True
def __accountBanned(username):
print('Account banned: {}.'.format(username))
appendFile(username, 'banned.txt')
def __accountFailed(username):
print('Failed to login with: {}.'.format(username))
appendFile(username, 'failed.txt')
def appendFile(text, filename):
if os.path.exists(filename):
f = open('./' + filename, 'a+b')
else:
f = open('./' + filename, 'w+b')
f.write("%s\n" % (text))
f.close()
def entry():
args = parse_arguments(sys.argv[1:])
api = PGoApi()
prog = re.compile("^(\-?\d+\.\d+),?\s?(\-?\d+\.\d+)$")
res = prog.match(args.location)
if res:
print('Using the following coordinates: {}'.format(args.location))
position = (float(res.group(1)), float(res.group(2)), 0)
else:
print(('Failed to parse the supplied coordinates ({}).'
+ ' Please try again.').format(args.location))
return
if args.hash_key:
print "Using hash key: {}.".format(args.hash_key)
api.activate_hash_server(args.hash_key)
with open(str(args.file)) as f:
credentials = [x.strip().split(',')[0:] for x in f.readlines()]
for provider, username, password in credentials:
try:
if check_account(provider, username, password, position, api):
# Success!
csv_format = provider + ',' + username + ',' + password
appendFile(csv_format, 'working.csv')
except ServerSideRequestThrottlingException:
print('Server side throttling, waiting for 10 seconds.')
time.sleep(10)
check_account(provider, username, password, position, api)
except NotLoggedInException:
print('Could not login, waiting for 10 seconds.')
time.sleep(10)
check_account(provider, username, password, position, api)
entry()