Move sessionfile to .config/tttc
This commit is contained in:
parent
445bcf422c
commit
232d43310c
@ -45,7 +45,7 @@ def handle():
|
|||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
api_id, api_hash = tttcutils.assert_environment()
|
api_id, api_hash = tttcutils.assert_environment()
|
||||||
client = TelegramClient("tttc", api_id, api_hash)
|
client = TelegramClient(tttcutils.sessionfile(), api_id, api_hash)
|
||||||
debug("Connecting...", file=sys.stderr)
|
debug("Connecting...", file=sys.stderr)
|
||||||
client.connect()
|
client.connect()
|
||||||
debug("Connected.", file=sys.stderr)
|
debug("Connected.", file=sys.stderr)
|
||||||
|
@ -4,7 +4,7 @@ import os
|
|||||||
|
|
||||||
api_id, api_hash = tttcutils.assert_environment()
|
api_id, api_hash = tttcutils.assert_environment()
|
||||||
|
|
||||||
client = TelegramClient("tttc", api_id, api_hash)
|
client = TelegramClient(tttcutils.sessionfile(), api_id, api_hash)
|
||||||
client.connect()
|
client.connect()
|
||||||
chats = client.get_dialogs()
|
chats = client.get_dialogs()
|
||||||
print("client: TelegramClient chats: [Dialog]")
|
print("client: TelegramClient chats: [Dialog]")
|
||||||
|
2
tttc.py
2
tttc.py
@ -22,7 +22,7 @@ class Display:
|
|||||||
def __init__(self, loop):
|
def __init__(self, loop):
|
||||||
self.loop = loop
|
self.loop = loop
|
||||||
api_id, api_hash = tttcutils.assert_environment()
|
api_id, api_hash = tttcutils.assert_environment()
|
||||||
self.client = TelegramClient("tttc", api_id, api_hash, loop=self.loop)
|
self.client = TelegramClient(tttcutils.sessionfile(), api_id, api_hash, loop=self.loop)
|
||||||
|
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
|
@ -17,3 +17,8 @@ def assert_environment():
|
|||||||
print("Please consult https://core.telegram.org/api/obtaining_api_id on how to get your own API id and hash.")
|
print("Please consult https://core.telegram.org/api/obtaining_api_id on how to get your own API id and hash.")
|
||||||
exit(1)
|
exit(1)
|
||||||
return os.environ["TTTC_API_ID"], os.environ["TTTC_API_HASH"]
|
return os.environ["TTTC_API_ID"], os.environ["TTTC_API_HASH"]
|
||||||
|
|
||||||
|
def sessionfile():
|
||||||
|
if not os.path.exists(os.path.expanduser("~/.config/tttc")):
|
||||||
|
os.makedirs(os.path.expanduser("~/.config/tttc/"))
|
||||||
|
return os.path.expanduser("~/.config/tttc/tttc")
|
||||||
|
Loading…
Reference in New Issue
Block a user