Skip to content

Commit

Permalink
✨ chore(pyproject.toml): Update author email in pyproject.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
sudoskys committed Dec 10, 2023
1 parent 7eb83ab commit 9abdbb9
Show file tree
Hide file tree
Showing 6 changed files with 285 additions and 79 deletions.
9 changes: 9 additions & 0 deletions app/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from telebot.asyncio_helper import ApiTelegramException
from telebot.asyncio_storage import StateMemoryStorage

from app_conf import settings
from setting.telegrambot import BotSetting

StepCache = StateMemoryStorage()
Expand Down Expand Up @@ -49,6 +50,14 @@ async def listen_help_command(message: types.Message):
parse_mode="MarkdownV2",
)

@bot.message_handler(
content_types=["photo", "document"], chat_types=["supergroup", "group"]
)
async def handle_group_photo(message: types.Message):
if not settings.rule.check_spoiler_photo:
if message.has_media_spoiler:
return logger.info("Ignore Spoiler Photos")

try:
await bot.polling(
non_stop=True, allowed_updates=util.update_types, skip_pending=True
Expand Down
5 changes: 5 additions & 0 deletions app/event.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-
# @Time : 2023/12/10 下午10:33
# @Author : sudoskys
# @File : event.py
# @Software: PyCharm
9 changes: 9 additions & 0 deletions app_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@
settings.validators.register(
Validator("app.debug", condition=lambda v: isinstance(v, bool), env="DEBUG"),
)

settings.validators.register(
Validator(
"rule.check_spoiler_photo",
condition=lambda v: isinstance(v, bool),
env="CHECK_SPOILER_PHOTO",
)
)

# raises after all possible errors are evaluated
try:
settings.validators.validate_all()
Expand Down
4 changes: 4 additions & 0 deletions conf_dir/settings.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
[app]
debug = false


[rule]
check_spoiler_photo = false
Loading

0 comments on commit 9abdbb9

Please sign in to comment.