修复了一些bug

This commit is contained in:
zayac 2025-01-09 03:41:01 +08:00
parent b39a6e5925
commit c9bc2307fd
7 changed files with 63 additions and 42 deletions

View File

@ -9,4 +9,4 @@ if __name__ == '__main__':
app.setStyleSheet(qdarkstyle.load_stylesheet(qt_api='pyqt6'))
main_win = Application()
main_win.show()
sys.exit(app.exec())
sys.exit(app.exec())

View File

@ -2,8 +2,8 @@
;username = zayac
;password = 123456
[Credentials]
username = luffy
password = luffy230505
username = zayac_remote
password = 123456
[Minimum]
minimum = True

View File

@ -20,7 +20,7 @@ COPY ./health_check.sh .
# 确保健康检查脚本有执行权限
RUN chmod +x /app/health_check.sh
sed -i 's/\r$//' health_check.sh
RUN sed -i 's/\r$//' health_check.sh
# 设置环境变量
ENV RABBITMQ_USER=bot

View File

@ -17,7 +17,7 @@ logger.remove()
# 添加新的日志处理器,设置日志级别为 DEBUG
logger.add(sys.stderr, level="INFO")
MAX_MESSAGE_LENGTH = 4096 # Telegram 消息的最大长度
class RateLimiter:
def __init__(self, rate, per):
@ -39,39 +39,56 @@ class RateLimiter:
else:
self.allowance -= 1.0
return True
def split_message(message, max_length=MAX_MESSAGE_LENGTH):
"""
将超长消息分割成小段
"""
parts = []
while len(message) > max_length:
# 找到最后一个换行符,尽量避免在单词中间截断
split_index = message[:max_length].rfind('\n')
if split_index == -1: # 如果没有换行符,直接截断
split_index = max_length
parts.append(message[:split_index])
message = message[split_index:]
parts.append(message)
return parts
async def _send_message_to_user(bot_token, target_id, message, rate_limiter, session):
if not rate_limiter.can_send():
await asyncio.sleep(1)
return await _send_message_to_user(bot_token, target_id, message, rate_limiter, session)
# 分割超长消息
message_parts = split_message(message)
parse_mode = determine_parse_mode(message)
for part in message_parts:
if not rate_limiter.can_send():
await asyncio.sleep(1)
continue
base_url = f"https://api.telegram.org/bot{bot_token}/sendMessage"
params = {
"chat_id": target_id,
"text": message,
"parse_mode": parse_mode
}
parse_mode = determine_parse_mode(part)
base_url = f"https://api.telegram.org/bot{bot_token}/sendMessage"
params = {
"chat_id": target_id,
"text": part,
"parse_mode": parse_mode
}
max_retry = 3
retry_count = 0
while retry_count < max_retry:
try:
async with session.post(base_url, params=params) as response:
if response.status == 200:
logger.debug(f'消息发送成功: {message}')
return
else:
logger.debug('消息发送失败,重试中...')
logger.error(f'{params},发送失败,返回值:{await response.text()}')
except aiohttp.ClientError as e:
logger.error(f'网络异常,重试中... 错误详情: {e}')
await asyncio.sleep(10)
retry_count += 1
max_retry = 3
retry_count = 0
while retry_count < max_retry:
try:
async with session.post(base_url, params=params) as response:
if response.status == 200:
logger.debug(f'消息发送成功: {part}')
break
else:
logger.debug('消息发送失败,重试中...')
logger.error(f'{params},发送失败,返回值:{await response.text()}')
except aiohttp.ClientError as e:
logger.error(f'网络异常,重试中... 错误详情: {e}')
await asyncio.sleep(10)
retry_count += 1
logger.debug('消息发送失败')
if retry_count == max_retry:
logger.debug(f'消息发送失败,已跳过: {part}')
def determine_parse_mode(message_text):

View File

@ -15,6 +15,7 @@ class AccountType(Enum):
hth = 1
jy = 2
aty = 3 #爱体育
ly = 4
@dataclass

View File

@ -25,28 +25,31 @@ class BaseMember:
netAmount: str
betAmount: str
changeLog: str
venueNetAmountList: list
venueProfitList: list
isChange: int
vipGrade: int
vipGradeStr: str
firstPayAt: str
remark: str
firstPayAt:str
# tagsIds:list
# tagsInfo:str
remark:str
status:str
@dataclass
class MemberList(BaseMember):
venueNetAmountList: str
tagsIds: str
tagsIds: list
tagsInfo: str
status: Optional[int] = field(default=None)
@dataclass
class MemberDetail(BaseMember):
venueNetAmountList: list
lotteryOddsCommission: str
lotteryOddsCommison:str
tags: str
lastBetTime: str
status: Optional[int] = field(default=None)
def get_first_pay_datetime(self) -> datetime:
return datetime.strptime(self.firstPayAt, "%Y-%m-%d %H:%M:%S")

View File

@ -61,7 +61,7 @@ def get_latest_deposit_user(account: Account, count: int):
# 提取所有用户名,并确保在指定时间内
now = datetime.now()
unique_names_within_time = {
item.name for item in pay_record_list if util.get_difference(item.createdAt, now) < 7200
item.name for item in pay_record_list if util.get_difference(item.createdAt, now) < 720000
}
logger.debug(f"获取到{len(unique_names_within_time)}个成功存款人数")
@ -298,6 +298,6 @@ def get_pay_failed_by_telegram_id(telegram_id: int) -> Optional[str]:
if __name__ == '__main__':
deposit_results = '\n'.join(
[f"用户: `{member.name}`, 首存金额: *{member.deposit}*" for member in
get_pay_record_list(get_user_by_username_and_password('zayac', '123456').accounts[2], "2024-04-23")])
[f"首存金额: *{member.deposit}*" for member in
get_latest_deposit_user(get_user_by_username_and_password('zayac_remote', '123456').accounts[3], 1)])
print(deposit_results)