mirror of
https://github.com/norohind/jubilant-system.git
synced 2025-04-12 04:40:02 +03:00
init
This commit is contained in:
commit
174ba3c6d4
267
available.json
Normal file
267
available.json
Normal file
@ -0,0 +1,267 @@
|
||||
{
|
||||
"SquadronTagData":{
|
||||
"SquadronTagCollections":[
|
||||
{
|
||||
"localisedCollectionName":"Activities",
|
||||
"SquadronTags":[
|
||||
{
|
||||
"ServerUniqueId":0,
|
||||
"LocalisedString":"Anti-Xeno Activists",
|
||||
"ServerString":"Activities_AntiXenoActivists"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":1,
|
||||
"LocalisedString":"Bounty Hunters",
|
||||
"ServerString":"Activities_BountyHunters"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":2,
|
||||
"LocalisedString":"Explorers",
|
||||
"ServerString":"Activities_Explorers"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":3,
|
||||
"LocalisedString":"Faction Supporters",
|
||||
"ServerString":"Activities_FactionSupporters"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":4,
|
||||
"LocalisedString":"Humanitarian Aid Providers",
|
||||
"ServerString":"Activities_Humanitarian"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":5,
|
||||
"LocalisedString":"Pirates",
|
||||
"ServerString":"Activities_Pirates"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":6,
|
||||
"LocalisedString":"Power Supporters",
|
||||
"ServerString":"Activities_PowerSupporters"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":7,
|
||||
"LocalisedString":"Traders and Miners",
|
||||
"ServerString":"Activities_TradersMiners"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":47,
|
||||
"LocalisedString":"Mentoring",
|
||||
"ServerString":"Activities_Mentoring"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"localisedCollectionName":"Attitude",
|
||||
"SquadronTags":[
|
||||
{
|
||||
"ServerUniqueId":9,
|
||||
"LocalisedString":"Relaxed",
|
||||
"ServerString":"GameMode_Relaxed"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":10,
|
||||
"LocalisedString":"Family",
|
||||
"ServerString":"GameMode_Family"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":11,
|
||||
"LocalisedString":"Devoted",
|
||||
"ServerString":"GameMode_Devoted"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"localisedCollectionName":"Languages",
|
||||
"SquadronTags":[
|
||||
{
|
||||
"ServerUniqueId":12,
|
||||
"LocalisedString":"English",
|
||||
"ServerString":"Languages_English",
|
||||
"LanguageTagIdentifier":"english"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":13,
|
||||
"LocalisedString":"Portuguese",
|
||||
"ServerString":"Languages_Portuguese",
|
||||
"LanguageTagIdentifier":"portuguese"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":14,
|
||||
"LocalisedString":"German",
|
||||
"ServerString":"Languages_German",
|
||||
"LanguageTagIdentifier":"german"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":15,
|
||||
"LocalisedString":"French",
|
||||
"ServerString":"Languages_French",
|
||||
"LanguageTagIdentifier":"french"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":31,
|
||||
"LocalisedString":"Spanish",
|
||||
"ServerString":"Languages_Spanish",
|
||||
"LanguageTagIdentifier":"spanish"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":32,
|
||||
"LocalisedString":"Russian",
|
||||
"ServerString":"Languages_Russian",
|
||||
"LanguageTagIdentifier":"russian"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"localisedCollectionName":"Time Zone",
|
||||
"SquadronTags":[
|
||||
{
|
||||
"ServerUniqueId":16,
|
||||
"LocalisedString":"UTC-9 -> UTC-7",
|
||||
"ServerString":"TimeZone_UTCM9toM7"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":17,
|
||||
"LocalisedString":"UTC-6 -> UTC-3",
|
||||
"ServerString":"TimeZone_UTCM6toM3"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":18,
|
||||
"LocalisedString":"UTC-1 -> UTC+2",
|
||||
"ServerString":"TimeZone_UTCM1toP2"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":19,
|
||||
"LocalisedString":"UTC+3 -> UTC+7",
|
||||
"ServerString":"TimeZone_UTCP3toP7"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":33,
|
||||
"LocalisedString":"UTC+8 -> UTC+12",
|
||||
"ServerString":"TimeZone_UTCP8toP12"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"localisedCollectionName":"Game Mode",
|
||||
"SquadronTags":[
|
||||
{
|
||||
"ServerUniqueId":20,
|
||||
"LocalisedString":"Solo",
|
||||
"ServerString":"Attitude_Solo"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":21,
|
||||
"LocalisedString":"Open",
|
||||
"ServerString":"Attitude_Open"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":22,
|
||||
"LocalisedString":"Private",
|
||||
"ServerString":"Attitude_Private"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"localisedCollectionName":"Availability",
|
||||
"SquadronTags":[
|
||||
{
|
||||
"ServerUniqueId":24,
|
||||
"LocalisedString":"Occasional",
|
||||
"ServerString":"Availability_Occasional"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":25,
|
||||
"LocalisedString":"Weekdays",
|
||||
"ServerString":"Availability_Weekdays"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":26,
|
||||
"LocalisedString":"Weekends",
|
||||
"ServerString":"Availability_Weekends"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"localisedCollectionName":"Play Style",
|
||||
"SquadronTags":[
|
||||
{
|
||||
"ServerUniqueId":28,
|
||||
"LocalisedString":"PVE",
|
||||
"ServerString":"PlayStyle_PVE"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":29,
|
||||
"LocalisedString":"PVP",
|
||||
"ServerString":"PlayStyle_PVP"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":30,
|
||||
"LocalisedString":"Roleplay",
|
||||
"ServerString":"PlayStyle_RP"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"localisedCollectionName":"Powerplay Characters",
|
||||
"SquadronTags":[
|
||||
{
|
||||
"ServerUniqueId":34,
|
||||
"LocalisedString":"Aisling Duval",
|
||||
"ServerString":"PowerPlay_AislingDuval"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":36,
|
||||
"LocalisedString":"Arissa Lavigny-Duval",
|
||||
"ServerString":"PowerPlay_ArissaLavignyDuval"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":37,
|
||||
"LocalisedString":"Denton Patreus",
|
||||
"ServerString":"PowerPlay_DentonPatreus"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":39,
|
||||
"LocalisedString":"Li Yong-Rui",
|
||||
"ServerString":"PowerPlay_LiYongRui"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":40,
|
||||
"LocalisedString":"Pranav Antal",
|
||||
"ServerString":"PowerPlay_SimguruPranavAntal"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":41,
|
||||
"LocalisedString":"Felicia Winters",
|
||||
"ServerString":"PowerPlay_FeliciaWinters"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":42,
|
||||
"LocalisedString":"Edmund Mahon",
|
||||
"ServerString":"PowerPlay_EdmundMahon"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":43,
|
||||
"LocalisedString":"Zachary Hudson",
|
||||
"ServerString":"PowerPlay_ZacharyHudson"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":44,
|
||||
"LocalisedString":"Archon Delaine",
|
||||
"ServerString":"PowerPlay_ArchonDelaine"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":45,
|
||||
"LocalisedString":"Zemina Torval",
|
||||
"ServerString":"PowerPlay_ZeminaTorval"
|
||||
},
|
||||
{
|
||||
"ServerUniqueId":46,
|
||||
"LocalisedString":"Yuri Grom",
|
||||
"ServerString":"PowerPlay_YuriGrom"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
95
main.py
Normal file
95
main.py
Normal file
@ -0,0 +1,95 @@
|
||||
# import json
|
||||
import requests
|
||||
import sqlite3
|
||||
import time
|
||||
import datetime
|
||||
|
||||
"""
|
||||
request bearer token from capi.demb.design
|
||||
if there is no token -> exit
|
||||
loop:
|
||||
make request for latest known squadron + 1
|
||||
if +1 squad exists -> write it to db
|
||||
if new squad have appropriate tags -> report it
|
||||
goto loop
|
||||
|
||||
|
||||
what to store?
|
||||
1. History of squadrons changes
|
||||
2. Current squadrons state
|
||||
|
||||
"""
|
||||
db = sqlite3.connect('db.sqlite')
|
||||
|
||||
# SquadronTagCollections = json.load(open('available.json', 'r'))['SquadronTagData']['SquadronTagCollections']
|
||||
ruTag: int = 32
|
||||
|
||||
hookURL = 'https://discord.com/api/webhooks/896514472280211477/LIKgbgNIr9Nvuc-1-FfylAIY1YV-a7RMjBlyBsVDellMbnokXLYKyBztY1P9Q0mabI6o' # noqa: E501
|
||||
|
||||
# let's get bearer token
|
||||
# https://api.orerve.net/2.0/website/squadron/info?platform=PC&squadronId=68879
|
||||
r = requests.get(url='https://capi.demb.design/users/InIMJmAy9I7XFHDoclQfxAwmPC9xbIwKPOzvGrrRA50=').json()
|
||||
bearer = r['access_token']
|
||||
|
||||
db.execute('create table if not exists squads (ownername text, id int, platform text, created text, created_ts '
|
||||
'text, tag text, '
|
||||
'inserted text, usertags text, name text, owner_id text);')
|
||||
|
||||
try:
|
||||
max_known_id: int = db.execute('select id from squads order by id desc limit 1').fetchone()[0]
|
||||
except TypeError:
|
||||
max_known_id: int = 68862
|
||||
|
||||
first_retry: bool = True
|
||||
|
||||
next_id = max_known_id + 1
|
||||
# print(f'continuing from {next_id}')
|
||||
while True:
|
||||
r = requests.get(
|
||||
url='https://api.orerve.net/2.0/website/squadron/info',
|
||||
params={'squadronId': next_id},
|
||||
headers={'Authorization': f'Bearer {bearer}'})
|
||||
|
||||
if r.status_code != 200:
|
||||
if not first_retry:
|
||||
break
|
||||
|
||||
else:
|
||||
first_retry = False
|
||||
next_id = next_id + 1
|
||||
time.sleep(3)
|
||||
continue
|
||||
|
||||
squad = r.json()['squadron']
|
||||
|
||||
squad['ownerName'] = bytes.fromhex(squad['ownerName']).decode('utf-8')
|
||||
|
||||
inserted = datetime.datetime.now(tz=datetime.timezone.utc).strftime('%Y-%m-%d %H:%M:%S') # in utc
|
||||
db.execute('insert into squads '
|
||||
'(id, platform, created, created_ts, tag, inserted, usertags, name, ownername, owner_id) values'
|
||||
'(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', (squad['id'],
|
||||
squad['platform'],
|
||||
squad['created'],
|
||||
squad['created_ts'],
|
||||
squad['tag'],
|
||||
inserted,
|
||||
str(squad['userTags']),
|
||||
squad['name'],
|
||||
squad['ownerName'],
|
||||
squad['ownerId']))
|
||||
db.commit()
|
||||
print(squad)
|
||||
|
||||
if ruTag in squad['userTags']:
|
||||
message = f"New RU squad: {squad['name']}\ntag: {squad['tag']}\ncreated: {squad['created']}\nplatform: " \
|
||||
f"{squad['platform']}\nowner name: {squad['ownerName']}\nmembers count: {squad['memberCount']}"
|
||||
message = requests.utils.quote(message)
|
||||
r2 = requests.post(url=hookURL, data=f'content={message}'.encode('utf-8'),
|
||||
headers={'Content-Type': 'application/x-www-form-urlencoded'})
|
||||
|
||||
if r2.status_code != 204:
|
||||
print('send failed')
|
||||
|
||||
next_id = next_id + 1
|
||||
first_retry = True
|
||||
time.sleep(3)
|
Loading…
x
Reference in New Issue
Block a user