Last active
January 3, 2016 07:19
-
-
Save Celeo/8428919 to your computer and use it in GitHub Desktop.
Uses the character's notification system to determine if there are any new applications to their corporation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import eveapi | |
from datetime import datetime | |
api = eveapi.EVEAPIConnection() | |
def main(): | |
auth = api.auth(keyID=raw_input('keyID: '), vCode=raw_input('vCode: ')) | |
characterID = raw_input("Your Director/CEO's character name: ") | |
notifications = auth.char.Notifications(characterID=characterID) | |
applicants = [] | |
for n in notifications.notifications: | |
if n.typeID == 16: | |
applicants.append(Applicant(notification_id=n.notificationID, char_id=n.senderID, \ | |
char_name=get_character_name(n.senderID), date=format_date(n.sentDate), read=True if n.read == 1 else False)) | |
ids = [n.notification_id for n in applicants] | |
notification_text = auth.char.NotificationTexts(characterID=characterID, IDs=ids) | |
for count, n in enumerate(notification_text.notifications): | |
applicants[count].text = parse_notification_text(n.data) | |
print applicants[count] | |
class Applicant: | |
def __init__(self, char_id=1, char_name='', date=1, text='', read=False, notification_id=1): | |
self.char_id = char_id | |
self.char_name = char_name | |
self.date = date | |
self.text = text | |
self.read = read | |
self.notification_id = notification_id | |
def __repr__(self): | |
return '\n%s applied to the corp on %s: %s' % (self.char_name, self.date, self.text) | |
parse_notification_text = lambda text: text.split('charID: ')[0].split(': ')[1].replace('\n', '') | |
get_character_name = lambda charid: api.eve.CharacterName(IDs=charid).characters[0].name | |
format_date = lambda timestamp: datetime.fromtimestamp(timestamp).strftime('%Y-%m-%d %H:%M:%S') | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment