新增webhook url参数
This commit is contained in:
75
diagnose_checkin.py
Normal file
75
diagnose_checkin.py
Normal file
@@ -0,0 +1,75 @@
|
||||
#!/usr/bin/env python3
|
||||
"""签到问题诊断脚本"""
|
||||
import os
|
||||
import sys
|
||||
import sqlite3
|
||||
from pathlib import Path
|
||||
from datetime import datetime
|
||||
import time
|
||||
|
||||
def diagnose_checkin_issue():
|
||||
"""诊断签到问题"""
|
||||
print("=== 签到问题诊断 ===")
|
||||
|
||||
# 1. 检查数据库文件
|
||||
db_path = "data/bot.db"
|
||||
print(f"1. 数据库文件路径: {db_path}")
|
||||
print(f" 文件存在: {os.path.exists(db_path)}")
|
||||
|
||||
if os.path.exists(db_path):
|
||||
stat = os.stat(db_path)
|
||||
print(f" 文件大小: {stat.st_size} bytes")
|
||||
print(f" 文件权限: {oct(stat.st_mode)}")
|
||||
print(f" 最后修改: {datetime.fromtimestamp(stat.st_mtime)}")
|
||||
|
||||
# 2. 检查数据库目录
|
||||
db_dir = Path(db_path).parent
|
||||
print(f"2. 数据库目录: {db_dir}")
|
||||
print(f" 目录存在: {db_dir.exists()}")
|
||||
print(f" 目录可写: {os.access(db_dir, os.W_OK)}")
|
||||
|
||||
# 3. 测试数据库连接
|
||||
print("3. 测试数据库连接...")
|
||||
try:
|
||||
conn = sqlite3.connect(db_path, timeout=10.0)
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("SELECT name FROM sqlite_master WHERE type='table'")
|
||||
tables = cursor.fetchall()
|
||||
print(f" 数据库表: {[table[0] for table in tables]}")
|
||||
|
||||
# 检查用户积分表
|
||||
if ('user_points',) in tables:
|
||||
cursor.execute("SELECT COUNT(*) FROM user_points")
|
||||
count = cursor.fetchone()[0]
|
||||
print(f" 用户积分记录数: {count}")
|
||||
|
||||
if count > 0:
|
||||
cursor.execute("SELECT user_id, available_points FROM user_points LIMIT 3")
|
||||
users = cursor.fetchall()
|
||||
print(f" 示例用户积分: {users}")
|
||||
|
||||
conn.close()
|
||||
print(" 数据库连接: 成功")
|
||||
except Exception as e:
|
||||
print(f" 数据库连接: 失败 - {e}")
|
||||
|
||||
# 4. 检查磁盘空间
|
||||
print("4. 检查磁盘空间...")
|
||||
try:
|
||||
statvfs = os.statvfs(db_dir)
|
||||
free_space = statvfs.f_frsize * statvfs.f_bavail
|
||||
total_space = statvfs.f_frsize * statvfs.f_blocks
|
||||
print(f" 可用空间: {free_space / (1024*1024):.1f} MB")
|
||||
print(f" 总空间: {total_space / (1024*1024):.1f} MB")
|
||||
except Exception as e:
|
||||
print(f" 磁盘空间检查失败: {e}")
|
||||
|
||||
# 5. 检查进程权限
|
||||
print("5. 检查进程权限...")
|
||||
print(f" 当前用户: {os.getuid() if hasattr(os, 'getuid') else 'N/A'}")
|
||||
print(f" 当前组: {os.getgid() if hasattr(os, 'getgid') else 'N/A'}")
|
||||
|
||||
print("=== 诊断完成 ===")
|
||||
|
||||
if __name__ == "__main__":
|
||||
diagnose_checkin_issue()
|
||||
Reference in New Issue
Block a user