更新了一系列文件

This commit is contained in:
zayac 2024-07-05 23:45:26 +08:00
parent c8a93cf96a
commit 37136d2410
9 changed files with 48 additions and 51 deletions

View File

@ -1,6 +1,8 @@
# 使用官方 Python 3.11 镜像
FROM python:3.11-slim
# 安装 pgrep 所需的 procps 包
RUN apt-get update && apt-get install -y procps && rm -rf /var/lib/apt/lists/*
# 设置工作目录
WORKDIR /app
@ -9,13 +11,14 @@ WORKDIR /app
COPY . /app
COPY requirements.txt /app/requirements.txt
# 安装 Python 依赖
RUN pip install -r requirements.txt
RUN chmod +x /app/start.sh
# 设置容器启动时执行的命令
CMD ["python", "change_url_bot.py"]
CMD ["/bin/sh", "/app/start.sh"]
# 设置健康检查
HEALTHCHECK --interval=30s --timeout=30s --retries=3 \
CMD pgrep -f change_url_bot.py || exit 1
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD pgrep -f change_url_bot.py || exit 1

View File

@ -5,7 +5,7 @@ from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
from pydantic import BaseModel, constr
from src.change_url.change_url import change_url
from change_url import change_url
app = FastAPI()

View File

@ -5,7 +5,7 @@ import portalocker
from loguru import logger
try:
engine = create_engine("mysql+mysqlconnector://ky_tools:HJQY35seXen8patn@1panel.stupidpz.com:3306/ky_tools")
engine = create_engine("mysql+mysqlconnector://zayac_admin:2hMtBRzZrDAkRynX@45.89.233.228:3306/zayac_admin")
connection = engine.connect()
logger.debug('链接成功')
except:
@ -146,7 +146,7 @@ def update_agent_url(url_list, url_type):
if "代理web" in context.replace(" ", "").lower():
try:
with engine.connect() as connection:
update_stmt = sql_text("UPDATE ky_tools.ky_account SET url = :url WHERE type = :url_type")
update_stmt = sql_text("UPDATE sys_platform SET url = :url WHERE nickname = :url_type")
connection.execute(update_stmt, {"url": url, "url_type": url_type})
connection.commit()
logger.debug(f"{url_type}后台链接更新成功")

View File

@ -17,27 +17,6 @@ hth = ['YYZBH②拒绝私聊', '3-信息同步频道']
@bot.message_handler(func=lambda message: message.forward_date is not None)
def handle_forwarded_message(message):
# if message.forward_from:
# # 直接获取转发来源用户信息
# user = message.forward_from
# user_id = user.id
# user_first_name = user.first_name
# user_username = user.username if user.username else "No username"
#
# response = f"消息转发自 ID: {user_id}, 名字: {user_first_name}, 用户名: {user_username}"
# logger.debug(response)
# elif message.forward_from_chat:
# # 获取转发来源频道信息
# channel = message.forward_from_chat
# channel_id = channel.id
# channel_title = channel.title
#
# response = f"消息转发自频道 ID: {channel_id}, 名称: {channel_title}"
# logger.debug(response)
# else:
# # 处理无法识别的转发
# user_info = message.forward_origin
# response = f"这是一条转发的消息。{user_info}"
try:
res = requests.post(API_URL, json={'text': message.text})
if res.status_code == 200:

11
src/change_url/start.sh Normal file
View File

@ -0,0 +1,11 @@
#!/bin/sh
# 启动 change_url_bot.py 脚本
python /app/change_url_bot.py &
# 启动 FastAPI 应用
uvicorn app:app --host 127.0.0.1 --port 8080 &
# 等待所有后台进程结束
wait

View File

@ -26,6 +26,7 @@ ENV RABBITMQ_PASSWORD=xiaomi@123
ENV RABBITMQ_HOST=mq.stupidpz.com
ENV RABBITMQ_PORT=5672
ENV TELEGRAM_BOT_TOKEN=<your_telegram_bot_token>
ENV TZ=Asia/Shanghai
# 配置健康检查
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 CMD ["sh", "/app/health_check.sh"]

View File

@ -35,10 +35,10 @@ def perform_login(playwright, account: Account, request_container: dict, respons
# 填充基本的元素
fill_form_common(page, account)
if account.type == AccountType.jy:
handle_jy_captcha(page, account)
else:
handle_generic_account(page, response_container)
# if account.type == AccountType.jy:
# handle_jy_captcha(page, account)
# else:
handle_generic_account(page, response_container)
# 处理 'banner' 请求并获取响应头
handle_banner_request(page, request_container)

View File

@ -39,20 +39,23 @@ def query_net_win(user, date):
if __name__ == '__main__':
logger.info('Starting scheduled tasks')
# Get credentials from environment variables
username = os.getenv('MY_APP_USERNAME', 'default_username')
password = os.getenv('MY_APP_PASSWORD', 'default_password')
times = ['10:50', '14:40', '17:40', '20:40', '21:40', '23:59']
for time_str in times:
schedule.every().day.at(time_str).do(execute_task, job_count, username, password)
schedule.every().day.at(time_str).do(execute_task, query_net_win, username, password)
schedule.every().day.at('23:59').do(execute_task, query_failed_deposit, username, password)
while True:
schedule.run_pending()
time.sleep(10)
# logger.info('Starting scheduled tasks')
#
# # Get credentials from environment variables
# username = os.getenv('MY_APP_USERNAME', 'default_username')
# password = os.getenv('MY_APP_PASSWORD', 'default_password')
#
# times = ['10:50', '14:40', '17:40', '20:40', '21:40', '23:59']
#
# for time_str in times:
# schedule.every().day.at(time_str).do(execute_task, job_count, username, password)
# schedule.every().day.at(time_str).do(execute_task, query_net_win, username, password)
#
# schedule.every().day.at('23:59').do(execute_task, query_failed_deposit, username, password)
#
# while True:
# schedule.run_pending()
# time.sleep(10)
username = os.getenv('MY_APP_USERNAME', 'zayac')
password = os.getenv('MY_APP_PASSWORD', '123456')
execute_task(query_failed_deposit, username, password)

View File

@ -59,5 +59,5 @@ class Database:
session.commit()
# db = Database('mysql+mysqlconnector://ky_tools:HJQY35seXen8patn@1panel.stupidpz.com:3306/ky_tools')
db = Database('mysql+mysqlconnector://www_luffy_tool:GrCDtSynbK5MHb48@110.40.20.148:3306/www_luffy_tool')
db = Database('mysql+mysqlconnector://ky_tools:HJQY35seXen8patn@1panel.stupidpz.com:3306/ky_tools')
#db = Database('mysql+mysqlconnector://www_luffy_tool:GrCDtSynbK5MHb48@110.40.20.148:3306/www_luffy_tool')