Skip to content

Commit

Permalink
Not logging messages for channel that have not installed us properly
Browse files Browse the repository at this point in the history
  • Loading branch information
f213 committed Jun 20, 2024
1 parent fc777d6 commit 5928f44
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,24 @@
from helpers import enable_logging, in_production, init_sentry


def get_previous_non_deleted_message_count(chat_id: int) -> int:
from models import LogEntry

return LogEntry.select().where(
(LogEntry.chat_id == chat_id),
(LogEntry.action == 'deletion_error'),
).count()


async def log_message(message: Message | None, action: str | None = ''):
"""Create a log entry for telegram message"""

if message is None or message.from_user is None:
return

if get_previous_non_deleted_message_count(message.chat_id) > 10:
return

from models import LogEntry

LogEntry.create(
Expand Down

0 comments on commit 5928f44

Please sign in to comment.