Last active
May 10, 2018 17:48
-
-
Save JosXa/4cf4e0eec1c0887034a26514892d714b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pyrogram import Client | |
from tests.bots import get_userbot, get_bot | |
""" | |
Run this file with python3.5+ in order to log in to Pyrogram with a Telegram user account | |
interactively, creating a Pyrogram "session" file (json) in the process. | |
It will try to log into the provided account like every regular Telegram client does, | |
and you will be prompted for the login code. | |
Once the session is generated, you will be able to run the integration tests. | |
The configuration can be found in tests/bots.py and may be set via environment variables: | |
- API_ID=12345 | |
- API_HASH=abcdefghijklmnopqrstuvwxyz123456 | |
- PHONE_NUMBER=+49123456789 | |
Read here about how to obtain the values for API_ID and API_HASH: | |
https://docs.pyrogram.ml/start/ProjectSetup#api-keys | |
It is okay to use the provided defaults for API_ID and API_HASH, but you should use your own | |
(or a spare) Telegram account's PHONE_NUMBER. | |
""" | |
if __name__ == '__main__': | |
userbot_info = get_userbot() | |
bot_info = get_bot() | |
# Create a Pyrogram client | |
client = Client( | |
session_name=userbot_info['session_name'], | |
api_id=userbot_info['api_id'], | |
api_hash=userbot_info['api_hash'], | |
phone_number=userbot_info['phone_number'] | |
) | |
client.start() | |
# Send an initial message to the bot to register it as a known peer | |
client.send_message(bot_info['username'], "Hi, I'll be your testing buddy for today.") | |
print("Initialized successfully. You are now set up and ready to run the tests.") | |
client.stop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment