-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into dev
- Loading branch information
Showing
15 changed files
with
510 additions
and
410 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ venv/ | |
__pycache__ | ||
*.spec | ||
build | ||
dist | ||
dist | ||
*.zip |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import os | ||
import shutil | ||
import zipfile | ||
|
||
from _version import __version__ | ||
|
||
|
||
def remove_dir_if_exists(path): | ||
if os.path.isdir(path): | ||
shutil.rmtree(path) | ||
|
||
|
||
def remove_file_if_exists(path): | ||
if os.path.isfile(path): | ||
os.remove(path) | ||
|
||
|
||
def build_zip(): | ||
os.system('pyinstaller --onefile --paths venv main.py') | ||
with zipfile.ZipFile(f'tele2-profit@{__version__}.zip', 'w', | ||
zipfile.ZIP_DEFLATED) as zip_file: | ||
zip_file.write('dist/main.exe', 'main.exe') | ||
|
||
|
||
if __name__ == '__main__': | ||
remove_file_if_exists(f'tele2-profit@{__version__}.zip') | ||
build_zip() | ||
remove_dir_if_exists('dist') | ||
remove_dir_if_exists('build') | ||
remove_dir_if_exists('__pycache__') | ||
remove_file_if_exists('main.spec') |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__version__ = '2.0.0' |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from colorama import Fore | ||
|
||
from app.api import Tele2Api | ||
|
||
|
||
async def print_balance(api): | ||
balance = await api.get_balance() | ||
print(Fore.YELLOW + 'Balance: ' + Fore.MAGENTA + f'{balance} rub.') | ||
|
||
|
||
async def print_rests(api: Tele2Api): | ||
print('Checking your rests...') | ||
print( | ||
Fore.CYAN + 'note: only plan (not market-bought ones nor transferred)' | ||
' rests can be sold') | ||
rests = await api.get_rests() | ||
print(Fore.WHITE + 'You have') | ||
print(Fore.YELLOW + f'\t{rests["voice"]} min') | ||
print(Fore.GREEN + f'\t{rests["data"]} gb') | ||
print(Fore.WHITE + '\t\tavailable to sell.') | ||
return rests |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import json | ||
import re | ||
from colorama import Fore | ||
|
||
from app.api import Tele2Api | ||
|
||
|
||
def input_phone_number(): | ||
while True: | ||
user_input = input( | ||
Fore.CYAN + | ||
f'Input your Tele2 phone number (leave empty to cancel): ' | ||
) | ||
if re.match(r'^7\d{10}?$', user_input): | ||
return user_input | ||
elif user_input == '': | ||
exit() | ||
else: | ||
print(Fore.RED + 'Incorrect number format. Correct - 7xxxxxxxxxx') | ||
|
||
|
||
async def get_tokens(api: Tele2Api, phone_number: str): | ||
await api.send_sms_code() | ||
while True: | ||
try: | ||
sms_code = input(Fore.LIGHTCYAN_EX + 'SMS code: ') | ||
return await api.auth_with_code(phone_number, sms_code) | ||
except KeyError: | ||
print(Fore.RED + 'Invalid SMS-сode. Try again') | ||
|
||
|
||
def write_config_to_file(phone_number: str, access_token: str, | ||
refresh_token: str): | ||
with open('config.json', 'w') as f: | ||
json.dump({ | ||
'x-p': phone_number, | ||
'x-at': access_token, | ||
'x-rt': refresh_token, | ||
}, f, indent=2) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
SECURITY_BYPASS_HEADERS = { | ||
'Connection': 'keep-alive', | ||
'Tele2-User-Agent': '"mytele2-app/3.17.0"; "unknown"; "Android/9"; "Build/12998710"', | ||
'X-API-Version': '1', | ||
'User-Agent': 'okhttp/4.2.0' | ||
} | ||
|
||
MAIN_API = 'https://my.tele2.ru/api/subscribers/' | ||
SMS_VALIDATION_API = 'https://my.tele2.ru/api/validation/number/' | ||
TOKEN_API = 'https://my.tele2.ru/auth/realms/tele2-b2c/protocol/openid-connect/token/' |
Oops, something went wrong.