forked from eve-val/nrds-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStandingsCheck.py
executable file
·80 lines (68 loc) · 2.38 KB
/
StandingsCheck.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
#!/usr/bin/python
from eveapi import eveapi
import ChatKosLookup
import sys
MAX_NPC_AGENT = 3020000
class StandingsChecker:
def __init__(self, keyID, vCode):
self.checker = ChatKosLookup.KosChecker()
self.eveapi = self.checker.eveapi.auth(keyID=keyID, vCode=vCode)
def check(self):
contacts = self.eveapi.char.ContactList()
print 'Personal'
self.check_internal(contacts.contactList)
print 'Corp'
self.check_internal(contacts.corporateContactList)
print 'Alliance'
self.check_internal(contacts.allianceContactList)
def check_internal(self, contacts):
entities = [(row.contactID, row.contactName, row.standing)
for row in contacts if row.contactID > MAX_NPC_AGENT]
alive_alliances = [row.allianceID for row in
self.checker.eveapi.eve.AllianceList(version=1).alliances]
remove = {}
demote = {}
promote = {}
for (eid, name, standing) in entities:
kos = self.checker.koscheck_internal(name)
if (not eid in alive_alliances and
not self.valid_corp(eid) and not self.valid_char(eid)):
remove[name] = standing
elif standing < 0 and (kos == False or kos == ChatKosLookup.NPC):
promote[name] = standing
elif (standing >= 0 and
kos != None and kos != ChatKosLookup.NPC and kos != False):
demote[name] = standing
if remove:
print 'Defunct and can be removed:'
for (name, standing) in sorted(remove.items()):
print '%3d > [?]: %s' % (standing, name)
print ''
if demote:
print 'KOS and should be < 0:'
for (name, standing) in sorted(demote.items()):
print '%3d > [-]: %s' % (standing, name)
print ''
if promote:
print 'Not KOS and should be >=0 or removed:'
for (name, standing) in sorted(promote.items()):
print '%3d > [+]: %s' % (standing, name)
print ''
print '---'
def valid_corp(self, eid):
try:
ret = self.checker.eveapi.corp.CorporationSheet(corporationID=eid)
return (ret.ceoID != 0)
except eveapi.Error:
return False
def valid_char(self, eid):
try:
self.checker.eveapi.eve.CharacterInfo(characterID=eid)
return True
except eveapi.Error:
return False
if __name__ == '__main__':
if len(sys.argv) > 2:
StandingsChecker(sys.argv[1], sys.argv[2]).check()
else:
print ('Usage: %s keyID vCode' % sys.argv[0])