|
1 | 1 | import sqlite3 |
2 | 2 | import time |
3 | 3 | from astrbot.core.db.po import Platform, Stats |
4 | | -from typing import Tuple, List, Dict, Any |
| 4 | +from typing import Any |
5 | 5 | from dataclasses import dataclass |
6 | 6 |
|
7 | 7 |
|
@@ -126,7 +126,7 @@ def _get_conn(self, db_path: str) -> sqlite3.Connection: |
126 | 126 | conn.text_factory = str |
127 | 127 | return conn |
128 | 128 |
|
129 | | - def _exec_sql(self, sql: str, params: Tuple = None): |
| 129 | + def _exec_sql(self, sql: str, params: tuple = None): |
130 | 130 | conn = self.conn |
131 | 131 | try: |
132 | 132 | c = self.conn.cursor() |
@@ -257,7 +257,7 @@ def new_conversation(self, user_id: str, cid: str): |
257 | 257 | (user_id, cid, history, updated_at, created_at), |
258 | 258 | ) |
259 | 259 |
|
260 | | - def get_conversations(self, user_id: str) -> Tuple: |
| 260 | + def get_conversations(self, user_id: str) -> tuple: |
261 | 261 | try: |
262 | 262 | c = self.conn.cursor() |
263 | 263 | except sqlite3.ProgrammingError: |
@@ -320,7 +320,7 @@ def delete_conversation(self, user_id: str, cid: str): |
320 | 320 |
|
321 | 321 | def get_all_conversations( |
322 | 322 | self, page: int = 1, page_size: int = 20 |
323 | | - ) -> Tuple[List[Dict[str, Any]], int]: |
| 323 | + ) -> tuple[list[dict[str, Any]], int]: |
324 | 324 | """获取所有对话,支持分页,按更新时间降序排序""" |
325 | 325 | try: |
326 | 326 | c = self.conn.cursor() |
@@ -381,12 +381,12 @@ def get_filtered_conversations( |
381 | 381 | self, |
382 | 382 | page: int = 1, |
383 | 383 | page_size: int = 20, |
384 | | - platforms: List[str] = None, |
385 | | - message_types: List[str] = None, |
| 384 | + platforms: list[str] = None, |
| 385 | + message_types: list[str] = None, |
386 | 386 | search_query: str = None, |
387 | | - exclude_ids: List[str] = None, |
388 | | - exclude_platforms: List[str] = None, |
389 | | - ) -> Tuple[List[Dict[str, Any]], int]: |
| 387 | + exclude_ids: list[str] = None, |
| 388 | + exclude_platforms: list[str] = None, |
| 389 | + ) -> tuple[list[dict[str, Any]], int]: |
390 | 390 | """获取筛选后的对话列表""" |
391 | 391 | try: |
392 | 392 | c = self.conn.cursor() |
|
0 commit comments