修复了一些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')) app.setStyleSheet(qdarkstyle.load_stylesheet(qt_api='pyqt6'))
main_win = Application() main_win = Application()
main_win.show() main_win.show()
sys.exit(app.exec()) sys.exit(app.exec())

View File

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

View File

@ -20,7 +20,7 @@ COPY ./health_check.sh .
# 确保健康检查脚本有执行权限 # 确保健康检查脚本有执行权限
RUN chmod +x /app/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 ENV RABBITMQ_USER=bot

View File

@ -17,7 +17,7 @@ logger.remove()
# 添加新的日志处理器,设置日志级别为 DEBUG # 添加新的日志处理器,设置日志级别为 DEBUG
logger.add(sys.stderr, level="INFO") logger.add(sys.stderr, level="INFO")
MAX_MESSAGE_LENGTH = 4096 # Telegram 消息的最大长度
class RateLimiter: class RateLimiter:
def __init__(self, rate, per): def __init__(self, rate, per):
@ -39,39 +39,56 @@ class RateLimiter:
else: else:
self.allowance -= 1.0 self.allowance -= 1.0
return True 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): async def _send_message_to_user(bot_token, target_id, message, rate_limiter, session):
if not rate_limiter.can_send(): # 分割超长消息
await asyncio.sleep(1) message_parts = split_message(message)
return await _send_message_to_user(bot_token, target_id, message, rate_limiter, session)
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" parse_mode = determine_parse_mode(part)
params = { base_url = f"https://api.telegram.org/bot{bot_token}/sendMessage"
"chat_id": target_id, params = {
"text": message, "chat_id": target_id,
"parse_mode": parse_mode "text": part,
} "parse_mode": parse_mode
}
max_retry = 3 max_retry = 3
retry_count = 0 retry_count = 0
while retry_count < max_retry: while retry_count < max_retry:
try: try:
async with session.post(base_url, params=params) as response: async with session.post(base_url, params=params) as response:
if response.status == 200: if response.status == 200:
logger.debug(f'消息发送成功: {message}') logger.debug(f'消息发送成功: {part}')
return break
else: else:
logger.debug('消息发送失败,重试中...') logger.debug('消息发送失败,重试中...')
logger.error(f'{params},发送失败,返回值:{await response.text()}') logger.error(f'{params},发送失败,返回值:{await response.text()}')
except aiohttp.ClientError as e: except aiohttp.ClientError as e:
logger.error(f'网络异常,重试中... 错误详情: {e}') logger.error(f'网络异常,重试中... 错误详情: {e}')
await asyncio.sleep(10) await asyncio.sleep(10)
retry_count += 1 retry_count += 1
logger.debug('消息发送失败') if retry_count == max_retry:
logger.debug(f'消息发送失败,已跳过: {part}')
def determine_parse_mode(message_text): def determine_parse_mode(message_text):

View File

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

View File

@ -25,28 +25,31 @@ class BaseMember:
netAmount: str netAmount: str
betAmount: str betAmount: str
changeLog: str changeLog: str
venueNetAmountList: list
venueProfitList: list venueProfitList: list
isChange: int isChange: int
vipGrade: int vipGrade: int
vipGradeStr: str vipGradeStr: str
firstPayAt: str firstPayAt:str
remark: str # tagsIds:list
# tagsInfo:str
remark:str
status:str
@dataclass @dataclass
class MemberList(BaseMember): class MemberList(BaseMember):
venueNetAmountList: str tagsIds: list
tagsIds: str
tagsInfo: str tagsInfo: str
status: Optional[int] = field(default=None)
@dataclass @dataclass
class MemberDetail(BaseMember): class MemberDetail(BaseMember):
venueNetAmountList: list lotteryOddsCommission: str
lotteryOddsCommison:str
tags: str tags: str
lastBetTime: str lastBetTime: str
status: Optional[int] = field(default=None)
def get_first_pay_datetime(self) -> datetime: def get_first_pay_datetime(self) -> datetime:
return datetime.strptime(self.firstPayAt, "%Y-%m-%d %H:%M:%S") 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() now = datetime.now()
unique_names_within_time = { 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)}个成功存款人数") 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__': if __name__ == '__main__':
deposit_results = '\n'.join( deposit_results = '\n'.join(
[f"用户: `{member.name}`, 首存金额: *{member.deposit}*" for member in [f"首存金额: *{member.deposit}*" for member in
get_pay_record_list(get_user_by_username_and_password('zayac', '123456').accounts[2], "2024-04-23")]) get_latest_deposit_user(get_user_by_username_and_password('zayac_remote', '123456').accounts[3], 1)])
print(deposit_results) print(deposit_results)