1
0
Fork 0

Added "ignore_ids" config option

This commit is contained in:
Profitroll 2022-10-14 23:55:19 +02:00
parent 7eb1e29a6a
commit 954f1086f7
3 changed files with 149 additions and 126 deletions

View File

@ -5,5 +5,6 @@
"api_id": 1234,
"api_hash": "abcde12345",
"owner": "pavel.durov",
"owner_id": 123456789
"owner_id": 123456789,
"ignore_ids": []
}

View File

@ -15,15 +15,17 @@ def any_message_handler(_, message):
if configGet("debug") == True:
print(message)
indexId(message.chat.id, getChatName(message))
if message.chat.id not in configGet("ignore_ids"):
try:
lowered = message.text.lower()
except:
return
try:
print(f'{BBLACK}[{CYAN}{getTime(message.date)}{BBLACK}] {RESET}{message.from_user.first_name} ({getChatName(message)}) {BBLACK}» {RESET}{message.text.markdown}')
appendLog(f'[{getDateTime(message.date)}] {message.from_user.first_name} ({getChatName(message)}) » {message.text.markdown}', file=message.chat.id)
except AttributeError:
pass
indexId(message.chat.id, getChatName(message))
try:
lowered = message.text.lower()
except:
return
try:
print(f'{BBLACK}[{CYAN}{getTime(message.date)}{BBLACK}] {RESET}{message.from_user.first_name} ({getChatName(message)}) {BBLACK}» {RESET}{message.text.markdown}')
appendLog(f'[{getDateTime(message.date)}] {message.from_user.first_name} ({getChatName(message)}) » {message.text.markdown}', file=message.chat.id)
except AttributeError:
pass

View File

@ -17,46 +17,50 @@ def getpic(_, msg):
@app.on_message(filters.photo)
def get_image(_, photo):
try:
from_name = photo.from_user.first_name
except:
if photo.chat.id not in configGet("ignore_ids"):
try:
from_name = photo.author_signature
from_name = photo.from_user.first_name
except:
from_name = "UNKNOWN"
try:
from_name = photo.author_signature
except:
from_name = "UNKNOWN"
indexId(photo.chat.id, getChatName(photo))
indexId(photo.chat.id, getChatName(photo))
#print(photo)
print(f'{BBLACK}[{CYAN}{getTime(photo.date)}{BBLACK}] [{BGREEN}IMAGE{BBLACK}] {RESET}{from_name} ({getChatName(photo)}) {BBLACK}» {RESET}{photo.caption} {BBLACK}| {RESET}{photo.photo.file_id}')
appendLog(f'[{getDateTime(photo.date)}] [IMAGE] {from_name} ({getChatName(photo)}) » {photo.caption} | {photo.photo.file_id}', file=photo.chat.id)
#print(photo)
print(f'{BBLACK}[{CYAN}{getTime(photo.date)}{BBLACK}] [{BGREEN}IMAGE{BBLACK}] {RESET}{from_name} ({getChatName(photo)}) {BBLACK}» {RESET}{photo.caption} {BBLACK}| {RESET}{photo.photo.file_id}')
appendLog(f'[{getDateTime(photo.date)}] [IMAGE] {from_name} ({getChatName(photo)}) » {photo.caption} | {photo.photo.file_id}', file=photo.chat.id)
if configGet("save_media"):
makedirs(f"logs/chats/{photo.chat.id}/images", exist_ok=True)
_.download_media(photo, file_name=f"logs/chats/{photo.chat.id}/images/")
if configGet("save_media"):
makedirs(f"logs/chats/{photo.chat.id}/images", exist_ok=True)
_.download_media(photo, file_name=f"logs/chats/{photo.chat.id}/images/")
#=================================================================================
@app.on_message(filters.document)
def get_file(_, document):
if document.chat.id not in configGet("ignore_ids"):
try:
from_name = document.from_user.first_name
except:
try:
from_name = document.author_signature
from_name = document.from_user.first_name
except:
from_name = "UNKNOWN"
try:
from_name = document.author_signature
except:
from_name = "UNKNOWN"
indexId(document.chat.id, getChatName(document))
indexId(document.chat.id, getChatName(document))
#print(document)
print(f'{BBLACK}[{CYAN}{getTime(document.date)}{BBLACK}] [{BGREEN}FILE{BBLACK}] {RESET}{from_name} ({getChatName(document)}) {BBLACK}» {RESET}{document.caption} {BBLACK}| {RESET}{document.document.file_id}')
appendLog(f'[{getDateTime(document.date)}] [FILE] {from_name} ({getChatName(document)}) » {document.caption} | {document.document.file_id}', file=document.chat.id)
#print(document)
print(f'{BBLACK}[{CYAN}{getTime(document.date)}{BBLACK}] [{BGREEN}FILE{BBLACK}] {RESET}{from_name} ({getChatName(document)}) {BBLACK}» {RESET}{document.caption} {BBLACK}| {RESET}{document.document.file_id}')
appendLog(f'[{getDateTime(document.date)}] [FILE] {from_name} ({getChatName(document)}) » {document.caption} | {document.document.file_id}', file=document.chat.id)
if configGet("save_media"):
makedirs(f"logs/chats/{document.chat.id}/files", exist_ok=True)
_.download_media(document, file_name=f"logs/chats/{document.chat.id}/files/")
if configGet("save_media"):
makedirs(f"logs/chats/{document.chat.id}/files", exist_ok=True)
_.download_media(document, file_name=f"logs/chats/{document.chat.id}/files/")
# Get file from id
@app.on_message(filters.command(["doc", "document", "file"], prefixes=".") & filters.me)
@ -67,28 +71,30 @@ def getfile(_, msg):
@app.on_message(filters.video)
def get_video(_, video):
if video.chat.id not in configGet("ignore_ids"):
try:
from_name = video.from_user.first_name
except:
try:
from_name = video.author_signature
from_name = video.from_user.first_name
except:
try:
from_name = video.author_signature
except:
from_name = "UNKNOWN"
try:
from_name = video.from_user.first_name
except:
from_name = "UNKNOWN"
try:
from_name = video.from_user.first_name
except:
from_name = "UNKNOWN"
indexId(video.chat.id, getChatName(video))
indexId(video.chat.id, getChatName(video))
#print(video)
print(f'{BBLACK}[{CYAN}{getTime(video.date)}{BBLACK}] [{BGREEN}VIDEO{BBLACK}] {RESET}{from_name} ({getChatName(video)}) {BBLACK}» {RESET}{video.caption} {BBLACK}| {RESET}{video.video.file_id}')
appendLog(f'[{getDateTime(video.date)}] [VIDEO] {from_name} ({getChatName(video)}) » {video.caption} | {video.video.file_id}', file=video.chat.id)
#print(video)
print(f'{BBLACK}[{CYAN}{getTime(video.date)}{BBLACK}] [{BGREEN}VIDEO{BBLACK}] {RESET}{from_name} ({getChatName(video)}) {BBLACK}» {RESET}{video.caption} {BBLACK}| {RESET}{video.video.file_id}')
appendLog(f'[{getDateTime(video.date)}] [VIDEO] {from_name} ({getChatName(video)}) » {video.caption} | {video.video.file_id}', file=video.chat.id)
if configGet("save_media"):
makedirs(f"logs/chats/{video.chat.id}/videos", exist_ok=True)
_.download_media(video, file_name=f"logs/chats/{video.chat.id}/videos/")
if configGet("save_media"):
makedirs(f"logs/chats/{video.chat.id}/videos", exist_ok=True)
_.download_media(video, file_name=f"logs/chats/{video.chat.id}/videos/")
# Get video from id
@app.on_message(filters.command(["vid", "mov", "video", "movie"], prefixes=".") & filters.me)
@ -99,24 +105,26 @@ def getvideo(_, msg):
@app.on_message(filters.animation)
def get_animation(_, animation):
if animation.chat.id not in configGet("ignore_ids"):
try:
from_name = animation.from_user.first_name
except:
try:
from_name = animation.author_signature
from_name = animation.from_user.first_name
except:
from_name = "UNKNOWN"
try:
from_name = animation.author_signature
except:
from_name = "UNKNOWN"
indexId(animation.chat.id, getChatName(animation))
indexId(animation.chat.id, getChatName(animation))
#print(animation)
print(f'{BBLACK}[{CYAN}{getTime(animation.date)}{BBLACK}] [{BGREEN}GIF{BBLACK}] {RESET}{from_name} ({getChatName(animation)}) {BBLACK}» {RESET}{animation.caption} {BBLACK}| {RESET}{animation.animation.file_id}')
appendLog(f'[{getDateTime(animation.date)}] [GIF] {from_name} ({getChatName(animation)}) » {animation.caption} | {animation.animation.file_id}', file=animation.chat.id)
#print(animation)
print(f'{BBLACK}[{CYAN}{getTime(animation.date)}{BBLACK}] [{BGREEN}GIF{BBLACK}] {RESET}{from_name} ({getChatName(animation)}) {BBLACK}» {RESET}{animation.caption} {BBLACK}| {RESET}{animation.animation.file_id}')
appendLog(f'[{getDateTime(animation.date)}] [GIF] {from_name} ({getChatName(animation)}) » {animation.caption} | {animation.animation.file_id}', file=animation.chat.id)
if configGet("save_media"):
makedirs(f"logs/chats/{animation.chat.id}/gifs", exist_ok=True)
_.download_media(animation, file_name=f"logs/chats/{animation.chat.id}/gifs/")
if configGet("save_media"):
makedirs(f"logs/chats/{animation.chat.id}/gifs", exist_ok=True)
_.download_media(animation, file_name=f"logs/chats/{animation.chat.id}/gifs/")
# Get animation from id
@app.on_message(filters.command(["gif", "ani", "animation"], prefixes=".") & filters.me)
@ -127,24 +135,26 @@ def getanimation(_, msg):
@app.on_message(filters.voice)
def get_voice(_, voice):
if voice.chat.id not in configGet("ignore_ids"):
try:
from_name = voice.from_user.first_name
except:
try:
from_name = voice.author_signature
from_name = voice.from_user.first_name
except:
from_name = "UNKNOWN"
try:
from_name = voice.author_signature
except:
from_name = "UNKNOWN"
indexId(voice.chat.id, getChatName(voice))
indexId(voice.chat.id, getChatName(voice))
#print(voice)
print(f'{BBLACK}[{CYAN}{getTime(voice.date)}{BBLACK}] [{BGREEN}VOICE{BBLACK}] {RESET}{from_name} ({getChatName(voice)}) {BBLACK}» {RESET}{voice.caption} {BBLACK}| {RESET}{voice.voice.file_id}')
appendLog(f'[{getDateTime(voice.date)}] [VOICE] {from_name} ({getChatName(voice)}) » {voice.caption} | {voice.voice.file_id}', file=voice.chat.id)
#print(voice)
print(f'{BBLACK}[{CYAN}{getTime(voice.date)}{BBLACK}] [{BGREEN}VOICE{BBLACK}] {RESET}{from_name} ({getChatName(voice)}) {BBLACK}» {RESET}{voice.caption} {BBLACK}| {RESET}{voice.voice.file_id}')
appendLog(f'[{getDateTime(voice.date)}] [VOICE] {from_name} ({getChatName(voice)}) » {voice.caption} | {voice.voice.file_id}', file=voice.chat.id)
if configGet("save_media"):
makedirs(f"logs/chats/{voice.chat.id}/voice", exist_ok=True)
_.download_media(voice, file_name=f"logs/chats/{voice.chat.id}/voice/")
if configGet("save_media"):
makedirs(f"logs/chats/{voice.chat.id}/voice", exist_ok=True)
_.download_media(voice, file_name=f"logs/chats/{voice.chat.id}/voice/")
# Get voice from id
@app.on_message(filters.command(["voi", "rec", "voice", "recording"], prefixes=".") & filters.me)
@ -155,24 +165,26 @@ def getvoice(_, msg):
@app.on_message(filters.audio)
def get_audio(_, audio):
if audio.chat.id not in configGet("ignore_ids"):
try:
from_name = audio.from_user.first_name
except:
try:
from_name = audio.author_signature
from_name = audio.from_user.first_name
except:
from_name = "UNKNOWN"
try:
from_name = audio.author_signature
except:
from_name = "UNKNOWN"
indexId(audio.chat.id, getChatName(audio))
indexId(audio.chat.id, getChatName(audio))
#print(audio)
print(f'{BBLACK}[{CYAN}{getTime(audio.date)}{BBLACK}] [{BGREEN}AUDIO{BBLACK}] {RESET}{from_name} ({getChatName(audio)}) {BBLACK}» {RESET}{audio.caption} {BBLACK}| {RESET}{audio.audio.file_id}')
appendLog(f'[{getDateTime(audio.date)}] [AUDIO] {from_name} ({getChatName(audio)}) » {audio.caption} | {audio.audio.file_id}', file=audio.chat.id)
#print(audio)
print(f'{BBLACK}[{CYAN}{getTime(audio.date)}{BBLACK}] [{BGREEN}AUDIO{BBLACK}] {RESET}{from_name} ({getChatName(audio)}) {BBLACK}» {RESET}{audio.caption} {BBLACK}| {RESET}{audio.audio.file_id}')
appendLog(f'[{getDateTime(audio.date)}] [AUDIO] {from_name} ({getChatName(audio)}) » {audio.caption} | {audio.audio.file_id}', file=audio.chat.id)
if configGet("save_media"):
makedirs(f"logs/chats/{audio.chat.id}/audio", exist_ok=True)
_.download_media(audio, file_name=f"logs/chats/{audio.chat.id}/audio/")
if configGet("save_media"):
makedirs(f"logs/chats/{audio.chat.id}/audio", exist_ok=True)
_.download_media(audio, file_name=f"logs/chats/{audio.chat.id}/audio/")
# Get audio from id
@app.on_message(filters.command(["aud", "snd", "audio", "sound", "music"], prefixes=".") & filters.me)
@ -183,24 +195,26 @@ def getaudio(_, msg):
@app.on_message(filters.video_note)
def get_video_note(_, video_note):
if video_note.chat.id not in configGet("ignore_ids"):
try:
from_name = video_note.from_user.first_name
except:
try:
from_name = video_note.author_signature
from_name = video_note.from_user.first_name
except:
from_name = "UNKNOWN"
try:
from_name = video_note.author_signature
except:
from_name = "UNKNOWN"
indexId(video_note.chat.id, getChatName(video_note))
indexId(video_note.chat.id, getChatName(video_note))
#print(video_note)
print(f'{BBLACK}[{CYAN}{getTime(video_note.date)}{BBLACK}] [{BGREEN}VIDNT{BBLACK}] {RESET}{from_name} ({getChatName(video_note)}) {BBLACK}» {RESET}{video_note.caption} {BBLACK}| {RESET}{video_note.video_note.file_id}')
appendLog(f'[{getDateTime(video_note.date)}] [VIDNT] {from_name} ({getChatName(video_note)}) » {video_note.caption} | {video_note.video_note.file_id}', file=video_note.chat.id)
#print(video_note)
print(f'{BBLACK}[{CYAN}{getTime(video_note.date)}{BBLACK}] [{BGREEN}VIDNT{BBLACK}] {RESET}{from_name} ({getChatName(video_note)}) {BBLACK}» {RESET}{video_note.caption} {BBLACK}| {RESET}{video_note.video_note.file_id}')
appendLog(f'[{getDateTime(video_note.date)}] [VIDNT] {from_name} ({getChatName(video_note)}) » {video_note.caption} | {video_note.video_note.file_id}', file=video_note.chat.id)
if configGet("save_media"):
makedirs(f"logs/chats/{video_note.chat.id}/circles", exist_ok=True)
_.download_media(video_note, file_name=f"logs/chats/{video_note.chat.id}/circles/")
if configGet("save_media"):
makedirs(f"logs/chats/{video_note.chat.id}/circles", exist_ok=True)
_.download_media(video_note, file_name=f"logs/chats/{video_note.chat.id}/circles/")
# Get video note from id
@app.on_message(filters.command(["vdn", "vnt", "videonote", "face", "circle"], prefixes=".") & filters.me)
@ -211,20 +225,22 @@ def getvideonote(_, msg):
@app.on_message(filters.sticker)
def get_sticker(_, sticker):
if sticker.chat.id not in configGet("ignore_ids"):
try:
from_name = sticker.from_user.first_name
except:
try:
from_name = sticker.author_signature
from_name = sticker.from_user.first_name
except:
from_name = "UNKNOWN"
try:
from_name = sticker.author_signature
except:
from_name = "UNKNOWN"
indexId(sticker.chat.id, getChatName(sticker))
indexId(sticker.chat.id, getChatName(sticker))
#print(sticker)
print(f'{BBLACK}[{CYAN}{getTime(sticker.date)}{BBLACK}] [{BGREEN}STICK{BBLACK}] {RESET}{from_name} ({getChatName(sticker)}) {BBLACK}» {RESET}{sticker.caption} {BBLACK}| {RESET}{sticker.sticker.file_id}')
appendLog(f'[{getDateTime(sticker.date)}] [STICK] {from_name} ({getChatName(sticker)}) » {sticker.caption} | {sticker.sticker.file_id}', file=sticker.chat.id)
#print(sticker)
print(f'{BBLACK}[{CYAN}{getTime(sticker.date)}{BBLACK}] [{BGREEN}STICK{BBLACK}] {RESET}{from_name} ({getChatName(sticker)}) {BBLACK}» {RESET}{sticker.caption} {BBLACK}| {RESET}{sticker.sticker.file_id}')
appendLog(f'[{getDateTime(sticker.date)}] [STICK] {from_name} ({getChatName(sticker)}) » {sticker.caption} | {sticker.sticker.file_id}', file=sticker.chat.id)
# Get sticker from id
@app.on_message(filters.command(["stc", "stk", "sti", "sticker", "stick"], prefixes=".") & filters.me)
@ -235,38 +251,42 @@ def getsticker(_, msg):
@app.on_message(filters.location)
def get_location(_, location):
if location.chat.id not in configGet("ignore_ids"):
try:
from_name = location.from_user.first_name
except:
try:
from_name = location.author_signature
from_name = location.from_user.first_name
except:
from_name = "UNKNOWN"
try:
from_name = location.author_signature
except:
from_name = "UNKNOWN"
indexId(location.chat.id, getChatName(location))
indexId(location.chat.id, getChatName(location))
#print(location)
print(f'{BBLACK}[{CYAN}{getTime(location.date)}{BBLACK}] [{BGREEN}PLACE{BBLACK}] {RESET}{from_name} ({getChatName(location)}) {BBLACK}» {RESET}{location.caption} {BBLACK}| {RESET}longitude: {location.location.longitude}, latitude: {location.location.latitude}')
appendLog(f'[{getDateTime(location.date)}] [PLACE] {from_name} ({getChatName(location)}) » {location.caption} | longitude: {location.location.longitude}, latitude: {location.location.latitude}', file=location.chat.id)
#print(location)
print(f'{BBLACK}[{CYAN}{getTime(location.date)}{BBLACK}] [{BGREEN}PLACE{BBLACK}] {RESET}{from_name} ({getChatName(location)}) {BBLACK}» {RESET}{location.caption} {BBLACK}| {RESET}longitude: {location.location.longitude}, latitude: {location.location.latitude}')
appendLog(f'[{getDateTime(location.date)}] [PLACE] {from_name} ({getChatName(location)}) » {location.caption} | longitude: {location.location.longitude}, latitude: {location.location.latitude}', file=location.chat.id)
#=================================================================================
@app.on_message(filters.contact)
def get_contact(_, contact):
if contact.chat.id not in configGet("ignore_ids"):
try:
from_name = contact.from_user.first_name
except:
try:
from_name = contact.author_signature
from_name = contact.from_user.first_name
except:
from_name = "UNKNOWN"
try:
from_name = contact.author_signature
except:
from_name = "UNKNOWN"
indexId(contact.chat.id, getChatName(contact))
indexId(contact.chat.id, getChatName(contact))
#print(contact)
print(f'{BBLACK}[{CYAN}{getTime(contact.date)}{BBLACK}] [{BGREEN}STICK{BBLACK}] {RESET}{from_name} ({getChatName(contact)}) {BBLACK}» {RESET}{contact.caption} {BBLACK}| {RESET}name: {contact.contact.first_name}, number: {contact.contact.phone_number}, uid: {contact.contact.user_id}')
appendLog(f'[{getDateTime(contact.date)}] [STICK] {from_name} ({getChatName(contact)}) » {contact.caption} | name: {contact.contact.first_name}, number: {contact.contact.phone_number}, uid: {contact.contact.user_id}', file=contact.chat.id)
#print(contact)
print(f'{BBLACK}[{CYAN}{getTime(contact.date)}{BBLACK}] [{BGREEN}STICK{BBLACK}] {RESET}{from_name} ({getChatName(contact)}) {BBLACK}» {RESET}{contact.caption} {BBLACK}| {RESET}name: {contact.contact.first_name}, number: {contact.contact.phone_number}, uid: {contact.contact.user_id}')
appendLog(f'[{getDateTime(contact.date)}] [STICK] {from_name} ({getChatName(contact)}) » {contact.caption} | name: {contact.contact.first_name}, number: {contact.contact.phone_number}, uid: {contact.contact.user_id}', file=contact.chat.id)
#=================================================================================