Add ban for photo captions
This commit is contained in:
@@ -1,32 +1,32 @@
|
|||||||
# This workflow will install Python dependencies, run tests and lint with a single version of Python
|
# This workflow will install Python dependencies, run tests and lint with a single version of Python
|
||||||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
|
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
|
||||||
|
|
||||||
name: Python application
|
#name: Python application
|
||||||
|
#
|
||||||
on:
|
#on:
|
||||||
push:
|
# push:
|
||||||
branches: [ "master" ]
|
# branches: [ "master" ]
|
||||||
pull_request:
|
# pull_request:
|
||||||
branches: [ "master" ]
|
# branches: [ "master" ]
|
||||||
|
#
|
||||||
permissions:
|
#permissions:
|
||||||
contents: read
|
# contents: read
|
||||||
|
#
|
||||||
jobs:
|
#jobs:
|
||||||
build:
|
# build:
|
||||||
|
#
|
||||||
runs-on: debian-latest
|
# runs-on: debian-latest
|
||||||
|
#
|
||||||
steps:
|
# steps:
|
||||||
- uses: actions/checkout@v3
|
# - uses: actions/checkout@v3
|
||||||
- name: Set up Python 3.11
|
# - name: Set up Python 3.11
|
||||||
uses: actions/setup-python@v3
|
# uses: actions/setup-python@v3
|
||||||
with:
|
# with:
|
||||||
python-version: "3.11"
|
# python-version: "3.11"
|
||||||
- name: Install dependencies
|
# - name: Install dependencies
|
||||||
run: |
|
# run: |
|
||||||
python -m pip install --upgrade pip
|
# python -m pip install --upgrade pip
|
||||||
pip install -r requirements/common.txt
|
# pip install -r requirements/common.txt
|
||||||
# - name: Test with unittest
|
# - name: Test with unittest
|
||||||
# run: |
|
# run: |
|
||||||
# python -m unittest discover -s tests
|
# python -m unittest discover -s tests
|
||||||
|
|||||||
+3
-2
@@ -42,9 +42,10 @@ async def moderate_messages(message: types.Message):
|
|||||||
increment(message.chat.id, banned=True)
|
increment(message.chat.id, banned=True)
|
||||||
|
|
||||||
|
|
||||||
@bot.message_handler(func=in_caption_spam_list, content_types=["video"], chat_types=["supergroup", "group"])
|
@bot.edited_message_handler(func=in_caption_spam_list, content_types=["video", "photo", "animation"], chat_types=["supergroup", "group"])
|
||||||
|
@bot.message_handler(func=in_caption_spam_list, content_types=["video", "photo", "animation"], chat_types=["supergroup", "group"])
|
||||||
async def catch_videos(message: types.Message):
|
async def catch_videos(message: types.Message):
|
||||||
"""Catch offensive videos"""
|
"""Catch offensive media"""
|
||||||
await bot.delete_message(message.chat.id, message.id)
|
await bot.delete_message(message.chat.id, message.id)
|
||||||
await bot.ban_chat_member(message.chat.id, message.from_user.id)
|
await bot.ban_chat_member(message.chat.id, message.from_user.id)
|
||||||
increment(message.chat.id, banned=True)
|
increment(message.chat.id, banned=True)
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ def in_caption_spam_list(message: types.Message) -> bool:
|
|||||||
"""Check for mentioning unwanted words in caption."""
|
"""Check for mentioning unwanted words in caption."""
|
||||||
if message.caption and is_ban_words_in_caption(message.caption):
|
if message.caption and is_ban_words_in_caption(message.caption):
|
||||||
from_user_id, title, from_user_name = message.from_user.id, message.chat.title, message.from_user.first_name
|
from_user_id, title, from_user_name = message.from_user.id, message.chat.title, message.from_user.first_name
|
||||||
logging.info("!BAN!" + LOG_COMM % (title, from_user_id, from_user_name, message.video.file_name))
|
logging.info("!BAN CAPTION!" + LOG_COMM % (title, from_user_id, from_user_name, message.video.file_name))
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user