+ Add thread info
+ Remove N/A from web view when result is empty
This commit is contained in:
parent
3b71b87887
commit
42b86a78d2
@ -1,8 +1,8 @@
|
|||||||
from cm_bot_hal import CM_BOT_HAL
|
import logging, time, requests, json, os, threading
|
||||||
import logging, time, requests, json
|
|
||||||
from concurrent.futures import ThreadPoolExecutor
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import os
|
|
||||||
|
from cm_bot_hal import CM_BOT_HAL
|
||||||
|
|
||||||
# Suppress httpx logs
|
# Suppress httpx logs
|
||||||
logging.getLogger("httpx").setLevel(logging.WARNING)
|
logging.getLogger("httpx").setLevel(logging.WARNING)
|
||||||
@ -14,16 +14,17 @@ if not os.path.exists(logs_dir):
|
|||||||
|
|
||||||
# api_url = 'https://api.luckytown888.net'
|
# api_url = 'https://api.luckytown888.net'
|
||||||
api_url = 'http://api-server:3000'
|
api_url = 'http://api-server:3000'
|
||||||
max_threading = 1
|
max_threading = 5
|
||||||
|
|
||||||
def transfer(data: dict, local_logger):
|
def transfer(data: dict, local_logger):
|
||||||
bot = CM_BOT_HAL()
|
bot = CM_BOT_HAL()
|
||||||
local_logger.info(f"[Start] Transfer Credit from {data['f_username']} to {data['t_username']}")
|
thread_name = threading.current_thread().name
|
||||||
|
local_logger.info(f"[Thread-{thread_name}] [Start] Transfer Credit from {data['f_username']} to {data['t_username']}")
|
||||||
result = bot.transfer_credit_api(data['f_username'], data['f_password'], data['t_username'], data['t_password'])
|
result = bot.transfer_credit_api(data['f_username'], data['f_password'], data['t_username'], data['t_password'])
|
||||||
local_logger.info(result)
|
local_logger.info(f"[Thread-{thread_name}] {result}")
|
||||||
local_logger.info(f"[Done] {data['f_username']} transfer done!")
|
local_logger.info(f"[Thread-{thread_name}] [Done] {data['f_username']} transfer done!")
|
||||||
del bot
|
del bot
|
||||||
time.sleep(0.5)
|
time.sleep(1)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
weekday = int(datetime.now().strftime("%w"))
|
weekday = int(datetime.now().strftime("%w"))
|
||||||
@ -54,4 +55,4 @@ while True:
|
|||||||
with ThreadPoolExecutor(max_workers=max_threading) as executor:
|
with ThreadPoolExecutor(max_workers=max_threading) as executor:
|
||||||
results = list(executor.map(lambda item: transfer(item, local_logger), items))
|
results = list(executor.map(lambda item: transfer(item, local_logger), items))
|
||||||
local_logger.info(f"Completed processing {total_items} transfer items.")
|
local_logger.info(f"Completed processing {total_items} transfer items.")
|
||||||
time.sleep(1)
|
time.sleep(5 * 60)
|
||||||
|
|||||||
@ -457,17 +457,17 @@ HTML_TEMPLATE = """
|
|||||||
<tbody>
|
<tbody>
|
||||||
${sortedData.map((acc, index) => `
|
${sortedData.map((acc, index) => `
|
||||||
<tr>
|
<tr>
|
||||||
<td><strong>${acc.username || 'N/A'}</strong></td>
|
<td><strong>${acc.username}</strong></td>
|
||||||
<td class="editable" onclick="startEdit(this, 'password', 'acc', ${accData.findIndex(a => a.username === acc.username)})">
|
<td class="editable" onclick="startEdit(this, 'password', 'acc', ${accData.findIndex(a => a.username === acc.username)})">
|
||||||
${acc.password || 'N/A'}
|
${acc.password || ''}
|
||||||
</td>
|
</td>
|
||||||
<td class="editable" onclick="startEdit(this, 'status', 'acc', ${accData.findIndex(a => a.username === acc.username)})">
|
<td class="editable" onclick="startEdit(this, 'status', 'acc', ${accData.findIndex(a => a.username === acc.username)})">
|
||||||
<span class="status-badge ${acc.status === 'active' ? 'status-active' : 'status-inactive'}">
|
<span class="status-badge ${acc.status === 'active' ? 'status-active' : 'status-inactive'}">
|
||||||
${acc.status || 'N/A'}
|
${acc.status || ''}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td class="editable" onclick="startEdit(this, 'link', 'acc', ${accData.findIndex(a => a.username === acc.username)})">
|
<td class="editable" onclick="startEdit(this, 'link', 'acc', ${accData.findIndex(a => a.username === acc.username)})">
|
||||||
${acc.link || 'N/A'}
|
${acc.link || ''}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
`).join('')}
|
`).join('')}
|
||||||
@ -505,17 +505,17 @@ HTML_TEMPLATE = """
|
|||||||
<tbody>
|
<tbody>
|
||||||
${sortedData.map((user, index) => `
|
${sortedData.map((user, index) => `
|
||||||
<tr>
|
<tr>
|
||||||
<td><strong>${user.f_username || 'N/A'}</strong></td>
|
<td><strong>${user.f_username}</strong></td>
|
||||||
<td class="editable" onclick="startEdit(this, 'f_password', 'user', ${userData.findIndex(u => u.f_username === user.f_username)})">
|
<td class="editable" onclick="startEdit(this, 'f_password', 'user', ${userData.findIndex(u => u.f_username === user.f_username)})">
|
||||||
${user.f_password || 'N/A'}
|
${user.f_password || ''}
|
||||||
</td>
|
</td>
|
||||||
<td class="editable" onclick="startEdit(this, 't_username', 'user', ${userData.findIndex(u => u.f_username === user.f_username)})">
|
<td class="editable" onclick="startEdit(this, 't_username', 'user', ${userData.findIndex(u => u.f_username === user.f_username)})">
|
||||||
<strong>${user.t_username || 'N/A'}</strong>
|
<strong>${user.t_username || ''}</strong>
|
||||||
</td>
|
</td>
|
||||||
<td class="editable" onclick="startEdit(this, 't_password', 'user', ${userData.findIndex(u => u.f_username === user.f_username)})">
|
<td class="editable" onclick="startEdit(this, 't_password', 'user', ${userData.findIndex(u => u.f_username === user.f_username)})">
|
||||||
${user.t_password || 'N/A'}
|
${user.t_password || ''}
|
||||||
</td>
|
</td>
|
||||||
<td>${user.last_update_time || 'N/A'}</td>
|
<td>${user.last_update_time || 'No record'}</td>
|
||||||
</tr>
|
</tr>
|
||||||
`).join('')}
|
`).join('')}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user