sort imports w/ isort & format w/ black

Signed-off-by: Sebastian Hoß <seb@xn--ho-hia.de>
This commit is contained in:
Sebastian Hoß 2024-08-18 14:30:43 +02:00
parent 4c9a7258e2
commit 541a78d210
No known key found for this signature in database
2 changed files with 12 additions and 6 deletions

View File

@ -22,13 +22,12 @@ from time import mktime, time
import asyncio
import hashlib
import html
import re
import aiohttp
import attr
import feedparser
import re
from maubot import MessageEvent, Plugin, __version__ as maubot_version
from maubot.handlers import command, event
from mautrix.types import (
@ -110,7 +109,9 @@ class RSSBot(Plugin):
async def _send(self, feed: Feed, entry: Entry, sub: Subscription) -> EventID | None:
title_exclude_filter = sub.title_exclude_filter
if title_exclude_filter:
self.log.debug(f"Feed '{feed.id}' ({feed.title}) has exclude filter '{title_exclude_filter}'")
self.log.debug(
f"Feed '{feed.id}' ({feed.title}) has exclude filter '{title_exclude_filter}'"
)
if re.search(title_exclude_filter, entry.title):
self.log.info(f"Excluded '{entry.title}'")
return None
@ -400,7 +401,9 @@ class RSSBot(Plugin):
return
await self.dbm.update_title_filter(feed.id, evt.room_id, title_exclude_filter)
if title_exclude_filter:
await evt.reply(f"Feed {feed_id} will now exclude titles matching: {title_exclude_filter}")
await evt.reply(
f"Feed {feed_id} will now exclude titles matching: {title_exclude_filter}"
)
else:
await evt.reply(f"Removed title exclude filter from feed {feed_id}")
@ -501,7 +504,8 @@ class RSSBot(Plugin):
await evt.reply(
"**Subscriptions in this room:**\n\n"
+ "\n".join(
self._format_subscription(feed, subscriber, title_exclude_filter) for feed, subscriber, title_exclude_filter in subscriptions
self._format_subscription(feed, subscriber, title_exclude_filter)
for feed, subscriber, title_exclude_filter in subscriptions
)
)

View File

@ -244,6 +244,8 @@ class DBManager:
q = "UPDATE subscription SET send_notice=$3 WHERE feed_id=$1 AND room_id=$2"
await self.db.execute(q, feed_id, room_id, send_notice)
async def update_title_filter(self, feed_id: int, room_id: RoomID, title_exclude_filter: str) -> None:
async def update_title_filter(
self, feed_id: int, room_id: RoomID, title_exclude_filter: str
) -> None:
q = "UPDATE subscription SET title_exclude_filter=$3 WHERE feed_id=$1 AND room_id=$2"
await self.db.execute(q, feed_id, room_id, title_exclude_filter)