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

Skip to content

Commit 968ad2a

Browse files
authored
Add logout() function
1 parent ff42c04 commit 968ad2a

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

keyauth.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,30 @@ def changeUsername(self, username):
495495
else:
496496
print(json["message"])
497497
time.sleep(3)
498-
os._exit(1)
498+
os._exit(1)
499+
500+
def logout(self):
501+
self.checkinit()
502+
503+
post_data = {
504+
"type": "logout",
505+
"sessionid": self.sessionid,
506+
"name": self.name,
507+
"ownerid": self.ownerid
508+
}
509+
510+
response = self.__do_request(post_data)
511+
512+
json = jsond.loads(response)
513+
514+
if json["success"]:
515+
print("Successfully logged out")
516+
time.sleep(3)
517+
os._exit(1)
518+
else:
519+
print(json["message"])
520+
time.sleep(3)
521+
os._exit(1)
499522

500523
def __do_request(self, post_data):
501524
try:

0 commit comments

Comments
 (0)