feat: cleaning link for matrix

This commit is contained in:
草师傅 2025-10-02 14:20:11 +08:00
parent 4388c3fc21
commit 4adfa8f170
3 changed files with 28 additions and 9 deletions

View file

@ -1,14 +1,13 @@
import asyncio
import json
import logging
import os
import sys
from nio import AsyncClient, MatrixRoom, RoomMessageText
from nio.events.room_events import RoomMessageText
from typing import Dict, Callable
import config
from core.link import handle_matrix_links
# Configure logging
logging.basicConfig(level=logging.INFO)
@ -49,8 +48,6 @@ class MatrixAdapter:
# Check if message starts with command prefix
message = event.body.strip()
if not message.startswith('!'):
return
# Parse command and arguments
parts = message[1:].split(' ', 1)
@ -66,8 +63,7 @@ class MatrixAdapter:
except Exception as e:
logger.error(f"Error executing command {command}: {e}")
await self.send_message(room.room_id, f"Error executing command: {str(e)}")
else:
await self.send_message(room.room_id, f"Unknown command: {command}")
await handle_matrix_links(room, event, self.client)
async def send_message(self, room_id: str, message: str):
"""Send a message to a room."""

View file

@ -16,7 +16,7 @@ from core.middleware.rikki import RikkiMiddleware
from core.post_to_fedi import router as fedi_router
from core.bitflip import handle_bitflip_command
from core.link import handle_links
from core.link import handle_tg_links
from core.post_to_fedi import handle_auth, handle_post_to_fedi
from core.promote import handle_promote_command
from core.repeater import MessageRepeater
@ -67,7 +67,7 @@ class TelegramAdapter:
router.message(Command('post'))(handle_post_to_fedi)
# link 模块
router.message(Command('report_broken_links'))(report_broken_links)
router.message(F.text.contains('http') & ~F.text.contains('/report_broken_links'))(handle_links)
router.message(F.text.contains('http') & ~F.text.contains('/report_broken_links'))(handle_tg_links)
# mc 模块
router.message(Command('mc'))(handle_mc_status_command) # 这个模块
# unpin 模块