feat: add source websites with automated endpoint analysis, target queue dispatch ordering, and markdown styling

This commit is contained in:
mamad
2026-08-28 22:05:48 +03:30
parent 462ad3be93
commit 446f3ea041
11 changed files with 1100 additions and 32 deletions
+17 -2
View File
@@ -30,11 +30,26 @@ class RedisQueue:
await self.client.rpush(key, raw_json)
logger.info(f"Enqueued post {payload.get('post_id')} to Target #{target_id} queue [{key}]")
async def pop_target_post(self, target_id: int) -> Optional[Dict[str, Any]]:
async def pop_target_post(self, target_id: int, dispatch_order: str = "order") -> Optional[Dict[str, Any]]:
if not self.client:
await self.connect()
key = self._get_target_key(target_id)
raw = await self.client.lpop(key)
if dispatch_order == "random":
import random
length = await self.client.llen(key)
if length == 0:
return None
if length == 1:
raw = await self.client.lpop(key)
else:
idx = random.randint(0, length - 1)
raw = await self.client.lindex(key, idx)
if raw:
await self.client.lrem(key, 1, raw)
else:
raw = await self.client.lpop(key)
if raw:
try:
return json.loads(raw)