Skip to content

Commit

Permalink
feat: 支持关闭获取对话记录功能
Browse files Browse the repository at this point in the history
  • Loading branch information
hanxi committed Jan 1, 2025
1 parent a28c65f commit bf2d297
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions xiaomusic/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ class Config:
os.getenv("XIAOMUSIC_CONTINUE_PLAY", "false").lower() == "true"
)
pull_ask_sec: int = int(os.getenv("XIAOMUSIC_PULL_ASK_SEC", "1"))
enable_pull_ask: bool = (
os.getenv("XIAOMUSIC_ENABLE_PULL_ASK", "true").lower() == "true"
)
crontab_json: str = os.getenv("XIAOMUSIC_CRONTAB_JSON", "") # 定时任务
enable_yt_dlp_cookies: bool = (
os.getenv("XIAOMUSIC_ENABLE_YT_DLP_COOKIES", "false").lower() == "true"
Expand Down
6 changes: 6 additions & 0 deletions xiaomusic/static/default/setting.html
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ <h2>小爱音箱设置面板
<option value="false" selected>false</option>
</select>

<label for="enable_pull_ask">获取对话记录:</label>
<select id="enable_pull_ask">
<option value="true" selected>true</option>
<option value="false">false</option>
</select>

<label for="pull_ask_sec">获取对话记录间隔(秒):</label>
<input id="pull_ask_sec" type="number" value="1" />

Expand Down
5 changes: 5 additions & 0 deletions xiaomusic/xiaomusic.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ def setup_logger(self):
async def poll_latest_ask(self):
async with ClientSession() as session:
while True:
if not self.config.enable_pull_ask:
self.log.debug("Listening new message disabled")
await asyncio.sleep(5)
continue

self.log.debug(
f"Listening new message, timestamp: {self.last_timestamp}"
)
Expand Down

0 comments on commit bf2d297

Please sign in to comment.