brunogge 0.1.5__py3-none-any.whl → 0.1.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- brunogge/__init__.py +4 -4
- brunogge/getconfig.py +1 -1
- brunogge/ggs_stuff.py +8 -7
- brunogge/just_funcs.py +50 -13
- {brunogge-0.1.5.dist-info → brunogge-0.1.6.dist-info}/METADATA +1 -1
- brunogge-0.1.6.dist-info/RECORD +11 -0
- brunogge-0.1.5.dist-info/RECORD +0 -11
- {brunogge-0.1.5.dist-info → brunogge-0.1.6.dist-info}/WHEEL +0 -0
- {brunogge-0.1.5.dist-info → brunogge-0.1.6.dist-info}/top_level.txt +0 -0
brunogge/__init__.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
from .get_ws import ggs_ws
|
2
|
-
from .ggs_stuff import
|
3
|
-
from .just_funcs import fakescanning
|
2
|
+
from .ggs_stuff import ggs_login, keeping
|
3
|
+
from .just_funcs import fakescanning, check_updates
|
4
4
|
from .getconfig import getconfig
|
5
|
-
__all__ = ["
|
6
|
-
__version__ = "0.1.
|
5
|
+
__all__ = [ "ggs_ws", "ggs_login", "fakescanning", "getconfig", "keeping", "check_updates" ]
|
6
|
+
__version__ = "0.1.6"
|
brunogge/getconfig.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
from configparser import ConfigParser
|
2
2
|
import json, os
|
3
|
-
def getconfig(type:str ,savename:str ,created:str = "y") -> dict:
|
3
|
+
def getconfig(type:str ,savename:str ,created: str | None = "y") -> dict:
|
4
4
|
if created == "y":
|
5
5
|
config = ConfigParser()
|
6
6
|
# Use the user’s home directory and create the config file path
|
brunogge/ggs_stuff.py
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
import websockets, asyncio, random, re
|
2
2
|
import json as json_module
|
3
3
|
from .just_funcs import getserver
|
4
|
-
async def ggs_login(ws, nick: str, pwrd: str, server: str, kid: int =
|
4
|
+
async def ggs_login(ws, nick: str, pwrd: str, server: str, kid: int | None = 0) -> tuple:
|
5
5
|
|
6
6
|
"""
|
7
|
-
Login
|
7
|
+
Login to your account and return the coordinates of your main castle.
|
8
8
|
"""
|
9
9
|
if ws.open:
|
10
10
|
await ws.send(f"""<msg t='sys'><body action='verChk' r='0'><ver v='166' /></body></msg>""")
|
@@ -46,7 +46,7 @@ async def ggs_login(ws, nick: str, pwrd: str, server: str, kid: int = "0") -> No
|
|
46
46
|
await ws.send(f"%xt%{server}%kli%1%{{}}%")
|
47
47
|
while ws.open:
|
48
48
|
try:
|
49
|
-
response = await asyncio.wait_for(ws.recv(), timeout=
|
49
|
+
response = await asyncio.wait_for(ws.recv(), timeout=4)
|
50
50
|
response = response.decode('utf-8')
|
51
51
|
if "%xt%jaa%1%0%" in response:
|
52
52
|
pattern = rf"\[{kid},(\d+),(\d+),(\d+),1"
|
@@ -61,7 +61,7 @@ async def ggs_login(ws, nick: str, pwrd: str, server: str, kid: int = "0") -> No
|
|
61
61
|
|
62
62
|
while ws.open:
|
63
63
|
try:
|
64
|
-
response = await asyncio.wait_for(ws.recv(), timeout=
|
64
|
+
response = await asyncio.wait_for(ws.recv(), timeout=5.5)
|
65
65
|
response = response.decode('utf-8')
|
66
66
|
if "%xt%ffi%1%0%" in response:
|
67
67
|
await ws.send(f"%xt%{server}%gcs%1%{{}}%")
|
@@ -75,7 +75,8 @@ async def ggs_login(ws, nick: str, pwrd: str, server: str, kid: int = "0") -> No
|
|
75
75
|
sy = int(sy)
|
76
76
|
return sx, sy, lids, cid
|
77
77
|
|
78
|
-
async def keeping(ws, server):
|
78
|
+
async def keeping(ws, server: str) -> None:
|
79
|
+
"""Keep the connection alive by sending periodic messages."""
|
79
80
|
while ws.open:
|
80
81
|
try:
|
81
82
|
await ws.send(f"%xt%{server}%pin%1%<RoundHouseKick>%")
|
@@ -85,7 +86,7 @@ async def keeping(ws, server):
|
|
85
86
|
print("Connection closed, stopping keep-alive")
|
86
87
|
break
|
87
88
|
|
88
|
-
async def ggs_account(ws, nick, pwrd, server) -> None:
|
89
|
+
async def ggs_account(ws, nick: str, pwrd: str, server: str) -> None:
|
89
90
|
"""Login to the account and trigger next functions."""
|
90
91
|
print("Logging in...")
|
91
92
|
try:
|
@@ -96,5 +97,5 @@ async def ggs_account(ws, nick, pwrd, server) -> None:
|
|
96
97
|
while ws.open:
|
97
98
|
await asyncio.sleep(100)
|
98
99
|
except websockets.exceptions.ConnectionClosedError:
|
99
|
-
print("Theoretically you should never see this. If you do,
|
100
|
+
print("Theoretically you should never see this. If you do, you may be banned, idk tho.")
|
100
101
|
|
brunogge/just_funcs.py
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
import asyncio, re
|
2
2
|
import json as json_module
|
3
3
|
from importlib.resources import files
|
4
|
-
|
5
|
-
|
4
|
+
import subprocess
|
5
|
+
import sys
|
6
|
+
import requests
|
7
|
+
from packaging import version
|
8
|
+
from importlib.metadata import version as get_installed_version, PackageNotFoundError
|
9
|
+
async def c2s_search_for(ws, c2s_code: str, waiting_time: float | None = 3) -> dict | int:
|
6
10
|
"""Phrase is made from 3 letters. Returns response json or error code."""
|
7
11
|
while True:
|
8
12
|
try:
|
@@ -19,28 +23,31 @@ async def c2s_search_for(ws, c2s_code: str, waiting_time: float):
|
|
19
23
|
return int(error_code)
|
20
24
|
except asyncio.TimeoutError:
|
21
25
|
return -1
|
22
|
-
|
23
|
-
def getserver(server, full: str = "full") -> str:
|
24
|
-
"""
|
25
|
-
Get the server URL and exname from the server list.
|
26
|
-
Full -> ws for wsuri <--> ex for empireex_xyz <--> full for both wsuri and exname"""
|
27
26
|
|
27
|
+
def getserver(server: str, option: str | None = "full") -> str:
|
28
|
+
''' Get the server URI and server prefix from the server list.
|
29
|
+
|
30
|
+
:option:
|
31
|
+
:full: returns both websocket uri and server prefix
|
32
|
+
:ex: returns server prefix only
|
33
|
+
:ws: returns websocket uri only
|
34
|
+
'''
|
28
35
|
data_path = files("brunogge").joinpath("server_list.json")
|
29
36
|
with data_path.open("r", encoding="utf-8") as f:
|
30
37
|
data = json_module.load(f)
|
31
38
|
wsuri = data["servers"][server]["wsuri"]
|
32
39
|
exname = data["servers"][server]["exname"]
|
33
|
-
if
|
40
|
+
if option == "full":
|
34
41
|
return wsuri, exname
|
35
|
-
elif
|
42
|
+
elif option == "ex":
|
36
43
|
return exname
|
37
|
-
elif
|
44
|
+
elif option == "ws":
|
38
45
|
return wsuri
|
39
46
|
|
40
47
|
async def fakescanning(ws, server: str) -> None:
|
41
48
|
"""
|
42
|
-
Fake scanning
|
43
|
-
|
49
|
+
Fake scanning the map while doing other things (only on green map)
|
50
|
+
|
44
51
|
"""
|
45
52
|
empireex = getserver(server, "ex")
|
46
53
|
delays = [6, 2, 4, 2]
|
@@ -53,4 +60,34 @@ async def fakescanning(ws, server: str) -> None:
|
|
53
60
|
await ws.send(f"""%xt%{empireex}%gaa%1%{{"KID":0,"AX1":1274,"AY1":13,"AX2":1286,"AY2":25}}%""")
|
54
61
|
await ws.send(f"""%xt%{empireex}%gaa%1%{{"KID":0,"AX1":0,"AY1":13,"AX2":12,"AY2":25}}%""")
|
55
62
|
await ws.send(f"""%xt%{empireex}%gaa%1%{{"KID":0,"AX1":13,"AY1":13,"AX2":25,"AY2":25}}%""")
|
56
|
-
await asyncio.sleep(delay * 60)
|
63
|
+
await asyncio.sleep(delay * 60)
|
64
|
+
|
65
|
+
import subprocess
|
66
|
+
import pkg_resources
|
67
|
+
import requests
|
68
|
+
|
69
|
+
def check_updates(package_name):
|
70
|
+
try:
|
71
|
+
# Get currently installed version
|
72
|
+
installed_version = get_installed_version(package_name)
|
73
|
+
print(f"Installed version: {installed_version}")
|
74
|
+
except PackageNotFoundError:
|
75
|
+
subprocess.check_call([sys.executable, "-m", "pip", "install", package_name])
|
76
|
+
return
|
77
|
+
|
78
|
+
try:
|
79
|
+
# Get latest version from PyPI
|
80
|
+
response = requests.get(f"https://pypi.org/pypi/{package_name}/json", timeout=5)
|
81
|
+
response.raise_for_status()
|
82
|
+
latest_version = response.json()['info']['version']
|
83
|
+
print(f"Latest version on PyPI: {latest_version}")
|
84
|
+
|
85
|
+
# Compare versions
|
86
|
+
if version.parse(latest_version) > version.parse(installed_version):
|
87
|
+
print(f"Updating to version {latest_version}...")
|
88
|
+
subprocess.check_call([sys.executable, "-m", "pip", "install", "--upgrade", package_name])
|
89
|
+
else:
|
90
|
+
return
|
91
|
+
|
92
|
+
except Exception as e:
|
93
|
+
print(f"Error checking or updating {package_name}: {e}")
|
@@ -0,0 +1,11 @@
|
|
1
|
+
brunogge/__init__.py,sha256=oN1NvcC60bbtO24YFFRSbnRmBIgK1LCsSDfx-lwZ2Q8,275
|
2
|
+
brunogge/barony.py,sha256=6Xm-i5AaXa8oVQ_kzX0_tDZucoBVplF7gYTGuad6djk,14891
|
3
|
+
brunogge/get_ws.py,sha256=nPsvNReq4DzflvOItHOd3WgajAV7f3ckeZr8qRADYsI,709
|
4
|
+
brunogge/getconfig.py,sha256=fnFnuAAUdffK2ywjOsDtFCvKbzWSzoKYFw2lSo-zccI,9761
|
5
|
+
brunogge/ggs_stuff.py,sha256=QCBgVxbzfkr_pz1IFD11SVtGxzbYb-lgYjuJJLZgkwU,4771
|
6
|
+
brunogge/just_funcs.py,sha256=KDKzWU7zJlF1iGae2Lx3GaXABQRa99VRd2eOKkmbh9s,3941
|
7
|
+
brunogge/server_list.json,sha256=5hZrlPH7tbFY7m1bqMMgsKiyHkGiPTnVMAW2B9WLabc,5084
|
8
|
+
brunogge-0.1.6.dist-info/METADATA,sha256=ixxRYxskYkvsjFkS-r6-vbRFhzDer8n90ftfSZbxzyA,328
|
9
|
+
brunogge-0.1.6.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
|
10
|
+
brunogge-0.1.6.dist-info/top_level.txt,sha256=oTTOxi0gm7TPhnipjl1nIXsYLRrnWnDzKKLCfRVhAjw,9
|
11
|
+
brunogge-0.1.6.dist-info/RECORD,,
|
brunogge-0.1.5.dist-info/RECORD
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
brunogge/__init__.py,sha256=MgU4caQhwriibT1fZZ0GIUMNHCa_vrqav_oQXnBFB2E,225
|
2
|
-
brunogge/barony.py,sha256=6Xm-i5AaXa8oVQ_kzX0_tDZucoBVplF7gYTGuad6djk,14891
|
3
|
-
brunogge/get_ws.py,sha256=nPsvNReq4DzflvOItHOd3WgajAV7f3ckeZr8qRADYsI,709
|
4
|
-
brunogge/getconfig.py,sha256=Ky0faOuQSdrjLQulgPZD1uMCx2crJr_NipmVC85AtQw,9753
|
5
|
-
brunogge/ggs_stuff.py,sha256=vV-blmi7lXPNh3ktmqGVb4NQO97-rHBt7hG5eN4F6go,4640
|
6
|
-
brunogge/just_funcs.py,sha256=eQz_XOjfLKU532jWf_JrpQjkq-d5nVoiXJTFumW6-VA,2573
|
7
|
-
brunogge/server_list.json,sha256=5hZrlPH7tbFY7m1bqMMgsKiyHkGiPTnVMAW2B9WLabc,5084
|
8
|
-
brunogge-0.1.5.dist-info/METADATA,sha256=Oa73Wh3z_xu4BsFflcOCF_Mk1erHLiS_ecpt1XvfK18,328
|
9
|
-
brunogge-0.1.5.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
|
10
|
-
brunogge-0.1.5.dist-info/top_level.txt,sha256=oTTOxi0gm7TPhnipjl1nIXsYLRrnWnDzKKLCfRVhAjw,9
|
11
|
-
brunogge-0.1.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|