Browse Source

minor fixes

master
Anonymous 1 month ago
parent
commit
99bd59e9a3
2 changed files with 25 additions and 9 deletions
  1. 21
    9
      antipedo.py
  2. 4
    0
      requirements.txt

+ 21
- 9
antipedo.py View File

@@ -1,10 +1,14 @@
from telegram.error import BadRequest
from magic import Magic
from os import remove
import logging
from imagehash import average_hash
from PIL import Image

from telegram.error import (
BadRequest,
TimedOut,
Unauthorized
)
from telegram import (
ReplyKeyboardMarkup,
ReplyKeyboardRemove,
@@ -317,7 +321,11 @@ def checkMedia(update,context):
return
break

path = file.get_file().download(f"/tmp/{file.file_unique_id}")
try:
path = file.get_file().download(f"/tmp/{file.file_unique_id}")
except TimedOut:
return

phash = str(average_hash( Image.open(path) ))
remove(path)

@@ -366,13 +374,17 @@ def trackPublicChats(update,context):
chat = update.effective_chat
if chat.type=="private" or str(chat.id) in chan_list:
return
chan_list[chat.id] = {
"full_name": chat.full_name or chat.title,
"username" : chat.username or chat.invite_link,
"type" : chat.type,
"admin" : updater.bot.getChatMember( chat.id,updater.bot.id ).can_restrict_members,
"members" : chat.get_members_count()
}

try:
chan_list[chat.id] = {
"full_name": chat.full_name or chat.title,
"username" : chat.username or chat.invite_link,
"type" : chat.type,
"admin" : updater.bot.getChatMember( chat.id,updater.bot.id ).can_restrict_members,
"members" : chat.get_members_count()
}
except Unauthorized:
return
dump_json(chan_list,"chats.json")

dispatcher.add_handler(reporter)

+ 4
- 0
requirements.txt View File

@@ -0,0 +1,4 @@
python-telegram-bot
Pillow
imagehash
python-magic

Loading…
Cancel
Save