37 lines
1.4 KiB
Python
37 lines
1.4 KiB
Python
from cm_bot_hal import CM_BOT_HAL
|
|
import logging, time, requests, json
|
|
from concurrent.futures import ThreadPoolExecutor
|
|
from datetime import datetime
|
|
from tqdm import tqdm
|
|
|
|
logging.basicConfig(
|
|
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO
|
|
)
|
|
logging.getLogger("httpx").setLevel(logging.WARNING)
|
|
|
|
logger = logging.getLogger(__name__)
|
|
api_url = 'https://api.luckytown888.net'
|
|
max_threading = 1
|
|
|
|
def transfer(data: dict):
|
|
bot = CM_BOT_HAL()
|
|
logger.info(f'[Start] Transfer Credit from {data['f_username']} to {data['t_username']}')
|
|
bot.transfer_credit_api(data['f_username'], data['f_password'], data['t_username'], data['t_password'])
|
|
logger.info(f'[DONE] {data['f_username']} transfer done!')
|
|
del bot
|
|
time.sleep(0.5)
|
|
|
|
while True:
|
|
weekday = int(datetime.now().strftime("%w"))
|
|
hour = int(datetime.now().strftime("%H"))
|
|
minutes = int(datetime.now().strftime("%M"))
|
|
if weekday == 3 and (hour >= 21 and hour < 22) and minutes >= 32:
|
|
response = requests.get(f'{api_url}/user')
|
|
items = json.loads(response.text)
|
|
total_items = len(items) if isinstance(items, list) else 0
|
|
if total_items == 0:
|
|
logger.info("No items to process.")
|
|
else:
|
|
with ThreadPoolExecutor(max_workers=max_threading) as executor:
|
|
list(tqdm(executor.map(transfer, items), total=total_items, desc="Processing data"))
|
|
time.sleep(1) |