use remember_web cookie instead of pterodactyl_session
This commit is contained in:
parent
38863a92cc
commit
c895dc7627
6
bot.py
6
bot.py
@ -15,7 +15,9 @@ import heavynode
|
|||||||
DISCORD_TOKEN = os.environ['discord_token']
|
DISCORD_TOKEN = os.environ['discord_token']
|
||||||
DISCORD_SERVER_ID = 530446700058509323
|
DISCORD_SERVER_ID = 530446700058509323
|
||||||
HEAVYNODE_TOKEN = os.environ['heavynode_token']
|
HEAVYNODE_TOKEN = os.environ['heavynode_token']
|
||||||
SESSION_COOKIE = os.environ['pterodactyl_session_cookie']
|
# SESSION_COOKIE = os.environ['pterodactyl_session_cookie']
|
||||||
|
COOKIE_NAME = 'remember_web_59ba36addc2b2f9401580f014c7f58ea4e30989d'
|
||||||
|
COOKIE_VALUE = os.environ[COOKIE_NAME]
|
||||||
|
|
||||||
|
|
||||||
logging.basicConfig()
|
logging.basicConfig()
|
||||||
@ -24,7 +26,7 @@ intents = discord.Intents.default()
|
|||||||
intents.members = True
|
intents.members = True
|
||||||
bot = lib.MineBot(command_prefix='!', intents=intents)
|
bot = lib.MineBot(command_prefix='!', intents=intents)
|
||||||
|
|
||||||
hn = heavynode.Client(HEAVYNODE_TOKEN, SESSION_COOKIE)
|
hn = heavynode.Client(HEAVYNODE_TOKEN, COOKIE_NAME, COOKIE_VALUE)
|
||||||
bot.add_cleanup(hn.shutdown)
|
bot.add_cleanup(hn.shutdown)
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,9 +78,10 @@ class Socket:
|
|||||||
|
|
||||||
|
|
||||||
class Client:
|
class Client:
|
||||||
def __init__(self, token, session_cookie):
|
def __init__(self, token, cookie_name, cookie_value):
|
||||||
self.token = token
|
self.token = token
|
||||||
self.session_cookie = session_cookie
|
self.cookie_name = cookie_name
|
||||||
|
self.cookie_value = cookie_value
|
||||||
self.baseurl = 'https://control.heavynode.com/api'
|
self.baseurl = 'https://control.heavynode.com/api'
|
||||||
self.stats = []
|
self.stats = []
|
||||||
# global state is icky, but it sure is convenient
|
# global state is icky, but it sure is convenient
|
||||||
@ -148,7 +149,7 @@ class Client:
|
|||||||
await self.socket.connect_socket()
|
await self.socket.connect_socket()
|
||||||
|
|
||||||
async def fetch_daemon_secret(self):
|
async def fetch_daemon_secret(self):
|
||||||
cookie = {'pterodactyl_session': self.session_cookie}
|
cookie = {self.cookie_name: self.cookie_value}
|
||||||
async with aiohttp.ClientSession(cookies=cookie) as session:
|
async with aiohttp.ClientSession(cookies=cookie) as session:
|
||||||
r = await session.get('https://control.heavynode.com/server/' + self.server['identifier'])
|
r = await session.get('https://control.heavynode.com/server/' + self.server['identifier'])
|
||||||
m = re.search('"daemonSecret"\s?:\s?"([^"]*)"', await r.text())
|
m = re.search('"daemonSecret"\s?:\s?"([^"]*)"', await r.text())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user