mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-25 02:43:45 +03:00
Revert "Fixed logging out, added a proper function to list sessions"
This reverts commit 87969745f5
.
The main purpose is to get rid of the JSON encoding (useless)
This commit is contained in:
parent
b68772aab5
commit
4d5e11f4af
|
@ -192,16 +192,6 @@ class MtProtoSender:
|
||||||
if code == 0xa7eff811: # bad_msg_notification
|
if code == 0xa7eff811: # bad_msg_notification
|
||||||
return self.handle_bad_msg_notification(msg_id, sequence, reader)
|
return self.handle_bad_msg_notification(msg_id, sequence, reader)
|
||||||
|
|
||||||
if code == 0x62d6b459: # msgs_ack, it may handle the request we wanted
|
|
||||||
ack = reader.tgread_object()
|
|
||||||
for message_id in ack.msg_ids:
|
|
||||||
if message_id in self.need_confirmation:
|
|
||||||
self.need_confirmation.remove(message_id)
|
|
||||||
|
|
||||||
if request and request.msg_id in ack.msg_ids:
|
|
||||||
request.confirm_received = True
|
|
||||||
return False
|
|
||||||
|
|
||||||
# If the code is not parsed manually, then it was parsed by the code generator!
|
# If the code is not parsed manually, then it was parsed by the code generator!
|
||||||
# In this case, we will simply treat the incoming TLObject as an Update,
|
# In this case, we will simply treat the incoming TLObject as an Update,
|
||||||
# if we can first find a matching TLObject
|
# if we can first find a matching TLObject
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import platform
|
import platform
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from hashlib import md5
|
from hashlib import md5
|
||||||
from os import path, listdir
|
from os import path
|
||||||
from mimetypes import guess_extension, guess_type
|
from mimetypes import guess_extension, guess_type
|
||||||
|
|
||||||
# For sending and receiving requests
|
# For sending and receiving requests
|
||||||
|
@ -35,7 +35,7 @@ from telethon.tl.all_tlobjects import layer
|
||||||
class TelegramClient:
|
class TelegramClient:
|
||||||
|
|
||||||
# Current TelegramClient version
|
# Current TelegramClient version
|
||||||
__version__ = '0.6'
|
__version__ = '0.5'
|
||||||
|
|
||||||
# region Initialization
|
# region Initialization
|
||||||
|
|
||||||
|
@ -182,7 +182,8 @@ class TelegramClient:
|
||||||
def log_out(self):
|
def log_out(self):
|
||||||
"""Logs out and deletes the current session. Returns True if everything went OK"""
|
"""Logs out and deletes the current session. Returns True if everything went OK"""
|
||||||
try:
|
try:
|
||||||
self.invoke(LogOutRequest())
|
# This request is a bit special. Nothing is received after
|
||||||
|
self.sender.send(LogOutRequest())
|
||||||
if not self.session.delete():
|
if not self.session.delete():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -190,13 +191,6 @@ class TelegramClient:
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def list_sessions():
|
|
||||||
"""Lists all the sessions of the users who have ever connected
|
|
||||||
using this client and never logged out"""
|
|
||||||
return [path.splitext(path.basename(f))[0] # splitext = split ext (not spli text!)
|
|
||||||
for f in listdir('.') if f.endswith('.session')]
|
|
||||||
|
|
||||||
# endregion
|
# endregion
|
||||||
|
|
||||||
# region Dialogs ("chats") requests
|
# region Dialogs ("chats") requests
|
||||||
|
|
Loading…
Reference in New Issue
Block a user