Skip to content
This repository has been archived by the owner on Oct 16, 2023. It is now read-only.

Commit

Permalink
Worldhalla can now run 24/7
Browse files Browse the repository at this point in the history
  • Loading branch information
CrossyChainsaw committed Sep 26, 2022
1 parent cec2b8f commit a2ee99d
Show file tree
Hide file tree
Showing 8,755 changed files with 280,951 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
3 changes: 3 additions & 0 deletions .breakpoints
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"files": {}
}
105 changes: 105 additions & 0 deletions .replit
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# The command that runs the program. If the interpreter field is set, it will have priority and this run command will do nothing
run = "python3 main.py"

# The primary language of the repl. There can be others, though!
language = "python3"
entrypoint = "main.py"
# A list of globs that specify which files and directories should
# be hidden in the workspace.
hidden = ["venv", ".config", "**/__pycache__", "**/.mypy_cache", "**/*.pyc"]

# Specifies which nix channel to use when building the environment.
[nix]
channel = "stable-21_11"

# The command to start the interpreter.
[interpreter]
[interpreter.command]
args = [
"stderred",
"--",
"prybar-python3",
"-q",
"--ps1",
"\u0001\u001b[33m\u0002\u0001\u001b[00m\u0002 ",
"-i",
]
env = { LD_LIBRARY_PATH = "$PYTHON_LD_LIBRARY_PATH" }

[env]
VIRTUAL_ENV = "/home/runner/${REPL_SLUG}/venv"
PATH = "${VIRTUAL_ENV}/bin"
PYTHONPATH = "${VIRTUAL_ENV}/lib/python3.10/site-packages"
REPLIT_POETRY_PYPI_REPOSITORY = "https://package-proxy.replit.com/pypi/"
MPLBACKEND = "TkAgg"
POETRY_CACHE_DIR = "${HOME}/${REPL_SLUG}/.cache/pypoetry"

# Enable unit tests. This is only supported for a few languages.
[unitTest]
language = "python3"

# Add a debugger!
[debugger]
support = true

# How to start the debugger.
[debugger.interactive]
transport = "localhost:0"
startCommand = ["dap-python", "main.py"]

# How to communicate with the debugger.
[debugger.interactive.integratedAdapter]
dapTcpAddress = "localhost:0"

# How to tell the debugger to start a debugging session.
[debugger.interactive.initializeMessage]
command = "initialize"
type = "request"

[debugger.interactive.initializeMessage.arguments]
adapterID = "debugpy"
clientID = "replit"
clientName = "replit.com"
columnsStartAt1 = true
linesStartAt1 = true
locale = "en-us"
pathFormat = "path"
supportsInvalidatedEvent = true
supportsProgressReporting = true
supportsRunInTerminalRequest = true
supportsVariablePaging = true
supportsVariableType = true

# How to tell the debugger to start the debuggee application.
[debugger.interactive.launchMessage]
command = "attach"
type = "request"

[debugger.interactive.launchMessage.arguments]
logging = {}

# Configures the packager.
[packager]
language = "python3"
ignoredPackages = ["unit_tests"]

[packager.features]
enabledForHosting = false
# Enable searching packages from the sidebar.
packageSearch = true
# Enable guessing what packages are needed from the code.
guessImports = true

# These are the files that need to be preserved when this
# language template is used as the base language template
# for Python repos imported from GitHub
[gitHubImport]
requiredFiles = [".replit", "replit.nix", ".config", "venv"]

[languages]

[languages.python3]
pattern = "**/*.py"

[languages.python3.languageServer]
start = "pylsp"
Binary file added __pycache__/api3.cpython-38.pyc
Binary file not shown.
Binary file added __pycache__/get_clans.cpython-38.pyc
Binary file not shown.
Binary file added __pycache__/keep_alive.cpython-38.pyc
Binary file not shown.
Binary file added __pycache__/transport_data.cpython-38.pyc
Binary file not shown.
8 changes: 8 additions & 0 deletions api3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import requests
import time
import os


def clan_request(id):
time.sleep(7) # 0.10 might be possible
return requests.get("https://api.brawlhalla.com/clan/" + str(id) + "/?api_key=" + os.environ['API_KEY'])
1 change: 1 addition & 0 deletions clans(1-1168).json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions clans(1468700+).json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions clans(80000-80012).json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"clan_name": "PanzLGaming", "clan_id": 80000},{"clan_name": "clan souls of light", "clan_id": 80001}, {"clan_name": "Army of Leda", "clan_id": 80004}, {"clan_name": "JBOA", "clan_id": 80006}, {"clan_name": "Kajla", "clan_id": 80007}, {"clan_name": "Epatraktor", "clan_id": 80008}, {"clan_name": "SUPERDIOCANE", "clan_id": 80009}, {"clan_name": "TeKniTy", "clan_id": 80012}]
1 change: 1 addition & 0 deletions clans.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
31 changes: 31 additions & 0 deletions get_clans.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import json
from api3 import clan_request

class Clan:
def __init__(self, name, id):
self.clan_name = name
self.clan_id = id


def get_clans(json_file, n):
print("Start getting data, starting from " + str(n))
# load data
with open(json_file) as data:
all_clans_data = json.load(data)

# if empty start getting data
if (len(all_clans_data) == 0):
while n < 10000000:
try:
with open(json_file) as data:
all_clans_data = json.load(data)
clan_data = json.loads(clan_request(n).content)
name = clan_data["clan_name"]
id = clan_data["clan_id"]
all_clans_data.append(Clan(name, id).__dict__)
with open(json_file, 'w') as f:
all_clans_data = json.dump(all_clans_data, f)
except:
print(str(n) + " doesn't exist")

n += 1
18 changes: 18 additions & 0 deletions keep_alive.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from flask import Flask
from threading import Thread

app = Flask('')


@app.route('/')
def home():
return "Hello. I am alive! ~ Queen Spy"


def run():
app.run(host='0.0.0.0', port=1000)


def keep_alive():
t = Thread(target=run)
t.start()
49 changes: 49 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import json
from api3 import clan_request
from keep_alive import keep_alive
from transport_data import transport_data
from get_clans import get_clans

# started 17 sep 2022

# VARIABLES
global start_id
start_id = 0
json_file = 'clans' + '.json'
target_file = 'clans(1468700+)' + '.json'

# get data a
with open(json_file) as data_a:
data_a = json.load(data_a)
# transport data if not empty
if len(data_a) > 0:
transport_data(json_file, target_file)

# get data b
with open(target_file) as data_b:
data_b = json.load(data_b)
# new starting point if theres already data
if len(data_b) > 0:
last_saved_id = data_b[-1]['clan_id']
start_id = last_saved_id + 1
print('Set id to ' + str(start_id))

# get data
get_clans(json_file, start_id)
















keep_alive()
Loading

0 comments on commit a2ee99d

Please sign in to comment.