Skip to content

Commit

Permalink
Merge branch 'release/1.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Archie committed Jan 5, 2021
2 parents 5a7d1fa + b2cc77c commit 3cbce15
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 9 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Timofei

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Tele2 Profit v1.2.2
# Tele2 Profit [![Release](https://img.shields.io/github/v/release/raritetmolodoy/tele2-profit?color=black&label=%20)](https://github.com/raritetmolodoy/tele2-profit/releases)

Console application that allows you to quickly sell your Tele2 data on their **Market**



## Disclaimer
_От автора:_
Я не несу ответственности за ваши номера (если они улетят в бан или еще чего по-хуже).
Expand All @@ -28,8 +30,8 @@ _От автора:_

## Installation (basic - *Windows x64 only [x32 work in progress]*)
#### Steps:
1. Go to [releases](https://github.com/raritetmolodoy/tele2-profit/releases) page
and download the latest **zip**-archive (tele2-profit@\<version\>.zip)
1. Go to [latest release](https://github.com/raritetmolodoy/tele2-profit/releases/latest)
and download **zip**-archive (tele2-profit@\<version\>.zip)
2. Unarchive wherever you want and run **exe**-files.
3. You are good to go!

Expand Down Expand Up @@ -89,6 +91,7 @@ When done leave input field empty (just hit enter) and you will jump to the next
Special thanks to my donators:
* Кирилл - 100 rub
* Alex - 300 rub
* Никита - 300 rub
* Никита - 300 rub
* Михаил - 200 rub

If you want to support my work - *79044979272* (qiwi, sber, tinkoff)
36 changes: 34 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json
import math
import re
import time
from datetime import datetime, timedelta

import inquirer as console
Expand Down Expand Up @@ -169,7 +170,7 @@ def prepare_old_lots(old_lots: list):
return lots


def print_lot_listing_status(lots: list):
def print_lot_listing_status(lots: any):
for lot in lots:
lot_status = lot['meta']['status']
if lot_status == 'OK':
Expand All @@ -190,7 +191,7 @@ async def sell_prepared_lots(api: Tele2Api, lots: list):
for lot in lots:
task = asyncio.ensure_future(api.sell_lot(lot))
tasks.append(task)
print('Listing...')
print(Fore.WHITE + 'Listing...')
lots = await asyncio.gather(*tasks)
print_lot_listing_status(lots)

Expand Down Expand Up @@ -224,6 +225,35 @@ async def print_balance(api):
print(Fore.YELLOW + 'Balance: ' + Fore.MAGENTA + f'{balance} rub.')


def input_auto_resell_interval():
while True:
user_input = input(
Fore.MAGENTA + 'Auto-resell interval (seconds): ')
try:
interval = int(user_input)
return interval
except ValueError:
print(Fore.RED + 'Interval value must be integer!')
continue


async def activate_timer_if_needed(api: Tele2Api):
if console.confirm('Activate lot auto-selling timer?', default=True):
interval = input_auto_resell_interval()
print(Fore.GREEN + f'Timer activated! Your lots will be relisted every '
f'{interval} sec.')
iteration = 1
while True:
time.sleep(interval)
print(Fore.CYAN + f'\nRelisting (iteration #{iteration})...\n')
deleted_lots = await delete_active_lots(api)
if not len(deleted_lots):
print(Fore.GREEN +
'All lots have been sold! Deactivating the timer...')
break
await menu_again_action(api, deleted_lots)


async def main():
access_token, date, phone_number = load_config()
async with Tele2Api(phone_number, access_token) as api:
Expand All @@ -249,6 +279,8 @@ async def main():
elif option == 'Exit':
pass

await activate_timer_if_needed(api)


if __name__ == '__main__':
run_main(main)
6 changes: 3 additions & 3 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
from colorama import Fore


def print_version():
print('tele2-profit v1.2.2')
def _print_version():
print('tele2-profit v1.3.0')


def run_main(main):
try:
print_version()
_print_version()
event_loop = asyncio.get_event_loop()
future = asyncio.ensure_future(main())
event_loop.run_until_complete(future)
Expand Down

0 comments on commit 3cbce15

Please sign in to comment.