mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-05 20:50:22 +03:00
Resolve merge conflict by incorporating incoming changes
This commit is contained in:
commit
661246d2f3
|
@ -50,9 +50,9 @@ Sessions and Heroku
|
||||||
-------------------
|
-------------------
|
||||||
|
|
||||||
You probably have a newer version of SQLite installed (>= 3.8.2). Heroku uses
|
You probably have a newer version of SQLite installed (>= 3.8.2). Heroku uses
|
||||||
SQLite 3.7.9 which does not support ``WITHOUT ROWID``. If you generated your
|
SQLite 3.7.9 which does not support ``WITHOUT ROWID``. So, if you generated
|
||||||
session file on a system with SQLite >= 3.8.2 your session file will not work
|
your session file on a system with SQLite >= 3.8.2 your session file will not
|
||||||
on Heroku's platform and will throw a corrupted schema error.
|
work on Heroku's platform and will throw a corrupted schema error.
|
||||||
|
|
||||||
There are multiple ways to solve this, the easiest of which is generating a
|
There are multiple ways to solve this, the easiest of which is generating a
|
||||||
session file on your Heroku dyno itself. The most complicated is creating
|
session file on your Heroku dyno itself. The most complicated is creating
|
||||||
|
@ -69,16 +69,18 @@ Generating a ession File on a Heroku Dyno
|
||||||
|
|
||||||
.. warning::
|
.. warning::
|
||||||
Do not restart your application Dyno at any point prior to retrieving your
|
Do not restart your application Dyno at any point prior to retrieving your
|
||||||
session file. Constantly creating new session files through Telegram's API
|
session file. Constantly creating new session files from Telegram's API
|
||||||
will result in a 24 hour rate limit ban.
|
will result in a 24 hour rate limit ban.
|
||||||
|
|
||||||
|
Due to Heroku's ephemeral filesystem all dynamically generated
|
||||||
|
files not part of your applications buildpack or codebase are destroyed upon
|
||||||
|
each restart.
|
||||||
|
|
||||||
Using this scaffolded code we can start the authentication process:
|
Using this scaffolded code we can start the authentication process:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
client = TelegramClient('login.session', api_id, api_hash,
|
client = TelegramClient('login.session', api_id, api_hash).start()
|
||||||
update_workers=1, spawn_read_thread=False)
|
|
||||||
client.start()
|
|
||||||
|
|
||||||
At this point your Dyno will crash because you cannot access stdin. Open your
|
At this point your Dyno will crash because you cannot access stdin. Open your
|
||||||
Dyno's control panel on the Heroku website and "Run console" from the "More"
|
Dyno's control panel on the Heroku website and "Run console" from the "More"
|
||||||
|
@ -89,25 +91,10 @@ So run your application ``python app.py`` and now you can complete the input
|
||||||
requests such as "what is your phone number" etc.
|
requests such as "what is your phone number" etc.
|
||||||
|
|
||||||
Once you're successfully authenticated exit your application script with
|
Once you're successfully authenticated exit your application script with
|
||||||
CTRL + C and ``ls`` to confirm ``login.session`` exists in your current directory.
|
CTRL + C and ``ls`` to confirm ``login.session`` exists in your current
|
||||||
Now you can create a git repo on your account and commit ``login.session`` to
|
directory. Now you can create a git repo on your account and commit
|
||||||
that repo.
|
``login.session`` to that repo.
|
||||||
|
|
||||||
You cannot ssh into your Dyno instance because it has crashed, so unless you
|
You cannot ``ssh`` into your Dyno instance because it has crashed, so unless
|
||||||
programatically upload this file to a server host this is the only way to get
|
you programatically upload this file to a server host this is the only way to
|
||||||
it off of your Dyno.
|
get it off of your Dyno.
|
||||||
|
|
||||||
You now have a session file compatible with SQLite <= 3.8.2. Now you can
|
|
||||||
programatically fetch this file from an external host (Firebase, S3 etc.)
|
|
||||||
and login to your session using the following scaffolded code:
|
|
||||||
|
|
||||||
.. code-block:: python
|
|
||||||
|
|
||||||
fileName, headers = urllib.request.urlretrieve(file_url, 'login.session')
|
|
||||||
client = TelegramClient(os.path.abspath(fileName), api_id, api_hash,
|
|
||||||
update_workers=1, spawn_read_thread=False)
|
|
||||||
client.start()
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
- ``urlretrieve`` will be depreciated, consider using ``requests``.
|
|
||||||
- ``file_url`` represents the location of your file.
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user