發布 V1.0.2:排行榜、手動換日、設定改用 md 格式、新預設值
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
9286b64518
commit
f5a3b91783
8 files changed
+169
-29
No files matched your search
@@ -78,6 +78,30 @@ def get_points(guild_id: int, user_id: int) -> int:
|
||||
return row["points"] if row else 0
|
||||
|
||||
|
||||
def reset_signin_day(guild_id: int, today: str) -> int:
|
||||
"""手動換日:讓這個伺服器今天簽過的人可以再簽一次,回傳人數"""
|
||||
cur = conn.execute(
|
||||
"UPDATE members SET last_signin = NULL WHERE guild_id = ? AND last_signin = ?",
|
||||
(guild_id, today),
|
||||
)
|
||||
return cur.rowcount
|
||||
|
||||
|
||||
# ===== 排行榜 =====
|
||||
def get_ranking(guild_id: int) -> list[tuple[int, int, int]]:
|
||||
"""依點數排序的 (名次, user_id, 點數),同分同名次;同分時依 user_id 排,順序才固定"""
|
||||
rows = conn.execute(
|
||||
"SELECT user_id, points FROM members WHERE guild_id = ? ORDER BY points DESC, user_id",
|
||||
(guild_id,),
|
||||
).fetchall()
|
||||
ranking = []
|
||||
for i, row in enumerate(rows):
|
||||
if i == 0 or row["points"] != rows[i - 1]["points"]:
|
||||
rank = i + 1
|
||||
ranking.append((rank, row["user_id"], row["points"]))
|
||||
return ranking
|
||||
|
||||
|
||||
# ===== 私人包廂 =====
|
||||
def add_room(channel_id: int):
|
||||
conn.execute("INSERT OR IGNORE INTO voice_rooms (channel_id) VALUES (?)", (channel_id,))
|
||||
|
||||
Reference in new issue
Block a user