Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ff42c04

Browse files
committed
Add fetchStats() function, fix session not found
1 parent e9f728c commit ff42c04

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ You don't need to add any code to initalize. KeyAuth will initalize when the ins
7272
## **Display application information**
7373

7474
```py
75+
keyauthapp.fetchStats()
7576
print(f"""
7677
App data:
7778
Number of users: {keyauthapp.app_data.numUsers}

keyauth.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ def init(self):
9696

9797
self.sessionid = json["sessionid"]
9898
self.initialized = True
99-
self.__load_app_data(json["appinfo"])
99+
100+
if json["newSession"]:
101+
time.sleep(0.1)
100102

101103
def register(self, user, password, license, hwid=None):
102104
self.checkinit()
@@ -408,7 +410,24 @@ def fetchOnline(self):
408410
return json["users"]
409411
else:
410412
return None
413+
414+
def fetchStats(self):
415+
self.checkinit()
411416

417+
post_data = {
418+
"type": "fetchStats",
419+
"sessionid": self.sessionid,
420+
"name": self.name,
421+
"ownerid": self.ownerid
422+
}
423+
424+
response = self.__do_request(post_data)
425+
426+
json = jsond.loads(response)
427+
428+
if json["success"]:
429+
self.__load_app_data(json["appinfo"])
430+
412431
def chatGet(self, channel):
413432
self.checkinit()
414433

main.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,13 @@ def getchecksum():
4646

4747

4848
keyauthapp = api(
49-
name = "", #App name (Manage Applications --> Application name)
50-
ownerid = "", #Owner ID (Account-Settings --> OwnerID)
51-
secret = "", #App secret(Manage Applications --> App credentials code)
49+
name = "",
50+
ownerid = "",
51+
secret = "",
5252
version = "1.0",
5353
hash_to_check = getchecksum()
5454
)
5555

56-
print(f"""
57-
App data:
58-
Number of users: {keyauthapp.app_data.numUsers}
59-
Number of online users: {keyauthapp.app_data.onlineUsers}
60-
Number of keys: {keyauthapp.app_data.numKeys}
61-
Application Version: {keyauthapp.app_data.app_ver}
62-
Customer panel link: {keyauthapp.app_data.customer_panel}
63-
""")
64-
6556
def answer():
6657
try:
6758
print("""1.Login

0 commit comments

Comments
 (0)