Add request timeout and cap output; point instance at Roomsoverview Project space; v1.0.4
This commit is contained in:
parent
f860229cf4
commit
6cf0255f01
3 changed files with 9 additions and 3 deletions
|
|
@ -1,6 +1,6 @@
|
|||
maubot: 0.1.0
|
||||
id: nl.roomsoverview
|
||||
version: 1.0.3
|
||||
version: 1.0.4
|
||||
license: MIT
|
||||
modules:
|
||||
- roomsoverview
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -2,10 +2,14 @@ import asyncio
|
|||
from typing import Any, Dict, List, Optional, Tuple
|
||||
from urllib.parse import quote
|
||||
|
||||
import aiohttp
|
||||
|
||||
from maubot import Plugin, MessageEvent
|
||||
from maubot.handlers import command
|
||||
from mautrix.util.config import BaseProxyConfig, ConfigUpdateHelper
|
||||
|
||||
_REQUEST_TIMEOUT = aiohttp.ClientTimeout(total=30)
|
||||
|
||||
|
||||
def _escape_md(text: str) -> str:
|
||||
"""Escape markdown-significant characters when embedding user content."""
|
||||
|
|
@ -38,7 +42,7 @@ class RoomsOverviewPlugin(Plugin):
|
|||
return Config
|
||||
|
||||
async def _fetch_hierarchy(self, space_id: str) -> Tuple[List[Dict[str, Any]], bool]:
|
||||
"""Fetch the full paginated space hierarchy for a room.
|
||||
"""Fetch the paginated space hierarchy for a room.
|
||||
|
||||
Uses GET /_matrix/client/v1/rooms/{roomId}/hierarchy, which
|
||||
paginates depth-first over the whole space tree. Retries on 429
|
||||
|
|
@ -75,7 +79,9 @@ class RoomsOverviewPlugin(Plugin):
|
|||
retries = 0
|
||||
while True:
|
||||
try:
|
||||
async with self.http.get(url, params=params, headers=headers) as resp:
|
||||
async with self.http.get(
|
||||
url, params=params, headers=headers, timeout=_REQUEST_TIMEOUT
|
||||
) as resp:
|
||||
if resp.status == 429:
|
||||
retries += 1
|
||||
try:
|
||||
|
|
|
|||
Loading…
Reference in a new issue