init commit

This commit is contained in:
草师傅 2025-07-30 21:40:15 +08:00
commit 7ec4ee6c6f
19 changed files with 7155 additions and 0 deletions

23
core/unpin.py Normal file
View file

@ -0,0 +1,23 @@
from aiogram.types import Message
from config import config
async def handle_unpin_channel_message(message: Message):
"""Handle unpinning messages from linked channels without a specific hashtag"""
if not config.is_feature_enabled('unpin', message.chat.id):
return
try:
regex_pattern = config.get_feature_config('unpin', message.chat.id)['regex']
print(regex_pattern)
# If a regex pattern exists, check if the message matches
if regex_pattern:
import re
if re.search(regex_pattern, message.text or message.caption or ""):
# Message matches regex, don't unpin
return
# Either no regex pattern or message doesn't match, proceed to unpin
print("trying to unpin the message")
await message.unpin()
except Exception as e:
print('Error unpinning message:', e)