Mime types
This commit is contained in:
parent
f2487d66a4
commit
42257304fa
14
config.json
14
config.json
@ -21,6 +21,7 @@
|
|||||||
"index": "data/index.json",
|
"index": "data/index.json",
|
||||||
"submit": "data/submit.json",
|
"submit": "data/submit.json",
|
||||||
"blocked": "data/blocked.json",
|
"blocked": "data/blocked.json",
|
||||||
|
"captions": "data/captions.json",
|
||||||
"locale": "locale"
|
"locale": "locale"
|
||||||
},
|
},
|
||||||
"posting": {
|
"posting": {
|
||||||
@ -38,7 +39,8 @@
|
|||||||
"mp4",
|
"mp4",
|
||||||
"avi",
|
"avi",
|
||||||
"mkv",
|
"mkv",
|
||||||
"webm"
|
"webm",
|
||||||
|
"mov"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"time": [
|
"time": [
|
||||||
@ -58,7 +60,15 @@
|
|||||||
"link": null
|
"link": null
|
||||||
},
|
},
|
||||||
"submission": {
|
"submission": {
|
||||||
"timeout": 30
|
"timeout": 30,
|
||||||
|
"file_size": 5242880,
|
||||||
|
"mime_types": [
|
||||||
|
"image/png",
|
||||||
|
"image/gif",
|
||||||
|
"image/jpeg",
|
||||||
|
"video/mp4",
|
||||||
|
"video/quicktime"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"commands": [
|
"commands": [
|
||||||
"start",
|
"start",
|
||||||
|
1
data/captions.json
Normal file
1
data/captions.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{}
|
@ -18,11 +18,13 @@
|
|||||||
"sub_by": "\n\nSubmitted by:",
|
"sub_by": "\n\nSubmitted by:",
|
||||||
"sub_sent": "Media has been submitted.\nWe'll notify you whether it will be accepted or not soon.",
|
"sub_sent": "Media has been submitted.\nWe'll notify you whether it will be accepted or not soon.",
|
||||||
"sub_cooldown": "You can only submit 1 media per {0} seconds",
|
"sub_cooldown": "You can only submit 1 media per {0} seconds",
|
||||||
|
"mime_not_allowed": "File type not allowed. Please, consider using one of these: {0}",
|
||||||
"post_exception": "Could not send content due to `{exp}`\n\nTraceback:\n```{0}```",
|
"post_exception": "Could not send content due to `{exp}`\n\nTraceback:\n```{0}```",
|
||||||
"post_empty": "Could not send content: `Queue folder is empty or contains only unsupported or already sent files.`"
|
"post_empty": "Could not send content: `Queue folder is empty or contains only unsupported or already sent files.`"
|
||||||
},
|
},
|
||||||
"button": {
|
"button": {
|
||||||
"sub_yes": "✅ Accept",
|
"sub_yes": "✅ Accept",
|
||||||
|
"sub_yes_caption": "✅ Accept + 📝",
|
||||||
"sub_no": "❌ Deny",
|
"sub_no": "❌ Deny",
|
||||||
"sub_block": "☠️ Block sender",
|
"sub_block": "☠️ Block sender",
|
||||||
"sub_unblock": "🏳️ Unblock sender",
|
"sub_unblock": "🏳️ Unblock sender",
|
||||||
|
@ -18,11 +18,13 @@
|
|||||||
"sub_by": "\n\nПредставлено:",
|
"sub_by": "\n\nПредставлено:",
|
||||||
"sub_sent": "Медіа-файл надіслано.\nСкоро ми повідомимо вас, чи буде його прийнято.",
|
"sub_sent": "Медіа-файл надіслано.\nСкоро ми повідомимо вас, чи буде його прийнято.",
|
||||||
"sub_cooldown": "Ви можете надсилати лише 1 медіафайл на {0} секунд",
|
"sub_cooldown": "Ви можете надсилати лише 1 медіафайл на {0} секунд",
|
||||||
|
"mime_not_allowed": "Тип файлу не дозволений. Розгляньте можливість використання одного з цих: {0}",
|
||||||
"post_exception": "Не вдалося надіслати контент через `{exp}`\n\nTraceback:\n```{0}```",
|
"post_exception": "Не вдалося надіслати контент через `{exp}`\n\nTraceback:\n```{0}```",
|
||||||
"post_empty": "Не вдалося надіслати контент: «Папка черги порожня або містить лише непідтримувані або вже надіслані файли»."
|
"post_empty": "Не вдалося надіслати контент: «Папка черги порожня або містить лише непідтримувані або вже надіслані файли»."
|
||||||
},
|
},
|
||||||
"button": {
|
"button": {
|
||||||
"sub_yes": "✅ Прийняти",
|
"sub_yes": "✅ Прийняти",
|
||||||
|
"sub_yes_caption": "✅ Прийняти + 📝",
|
||||||
"sub_no": "❌ Відхилити",
|
"sub_no": "❌ Відхилити",
|
||||||
"sub_block": "☠️ Заблокувати відправника",
|
"sub_block": "☠️ Заблокувати відправника",
|
||||||
"sub_unblock": "🏳️ Розблокувати відправника",
|
"sub_unblock": "🏳️ Розблокувати відправника",
|
||||||
|
46
main.py
46
main.py
@ -6,6 +6,7 @@ import sys
|
|||||||
from threading import Thread
|
from threading import Thread
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from modules.logging import logWrite
|
from modules.logging import logWrite
|
||||||
from modules.utils import configGet, jsonLoad, jsonSave, killProc, locale
|
from modules.utils import configGet, jsonLoad, jsonSave, killProc, locale
|
||||||
@ -197,16 +198,40 @@ def subUnblock(user):
|
|||||||
blocked.remove(user)
|
blocked.remove(user)
|
||||||
jsonSave(blocked, configGet("blocked", "locations"))
|
jsonSave(blocked, configGet("blocked", "locations"))
|
||||||
|
|
||||||
@app.on_message(~ filters.scheduled & filters.photo | filters.video | filters.animation)
|
@app.on_message(~ filters.scheduled & filters.photo | filters.video | filters.animation | filters.document)
|
||||||
def get_submission(_, msg):
|
def get_submission(_, msg):
|
||||||
if msg.from_user.id not in jsonLoad(configGet("blocked", "locations")):
|
if msg.from_user.id not in jsonLoad(configGet("blocked", "locations")):
|
||||||
user_locale = msg.from_user.language_code
|
user_locale = msg.from_user.language_code
|
||||||
if not subLimited(msg.from_user):
|
if not subLimited(msg.from_user):
|
||||||
|
|
||||||
|
if msg.document != None:
|
||||||
|
if msg.document.mime_type not in configGet("mime_types", "submission"):
|
||||||
|
msg.reply_text(locale("mime_not_allowed", "message", locale=user_locale), quote=True)
|
||||||
|
return
|
||||||
|
|
||||||
|
buttons = [
|
||||||
|
[
|
||||||
|
InlineKeyboardButton(text=locale("sub_yes", "button", locale=configGet("locale")), callback_data=f"sub_yes_{msg.from_user.id}_{msg.id}")
|
||||||
|
],
|
||||||
|
[
|
||||||
|
InlineKeyboardButton(text=locale("sub_block", "button", locale=configGet("locale")), callback_data=f"sub_block_{msg.from_user.id}")
|
||||||
|
],
|
||||||
|
[
|
||||||
|
InlineKeyboardButton(text=locale("sub_unblock", "button", locale=configGet("locale")), callback_data=f"sub_unblock_{msg.from_user.id}")
|
||||||
|
]
|
||||||
|
]
|
||||||
|
|
||||||
if msg.caption != None:
|
if msg.caption != None:
|
||||||
caption = str(msg.caption)
|
caption = str(msg.caption)
|
||||||
|
buttons[0].append(
|
||||||
|
InlineKeyboardButton(text=locale("sub_yes_caption", "button", locale=configGet("locale")), callback_data=f"sub_yes_{msg.from_user.id}_{msg.id}_caption"),
|
||||||
|
InlineKeyboardButton(text=locale("sub_no", "button", locale=configGet("locale")), callback_data=f"sub_no_{msg.from_user.id}_{msg.id}")
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
caption = ""
|
caption = ""
|
||||||
|
buttons[0].append(
|
||||||
|
InlineKeyboardButton(text=locale("sub_no", "button", locale=configGet("locale")), callback_data=f"sub_no_{msg.from_user.id}_{msg.id}")
|
||||||
|
)
|
||||||
|
|
||||||
caption += locale("sub_by", "message", locale=locale(configGet("locale")))
|
caption += locale("sub_by", "message", locale=locale(configGet("locale")))
|
||||||
|
|
||||||
@ -219,19 +244,7 @@ def get_submission(_, msg):
|
|||||||
if msg.from_user.phone_number != None:
|
if msg.from_user.phone_number != None:
|
||||||
caption += f" ({msg.from_user.phone_number})"
|
caption += f" ({msg.from_user.phone_number})"
|
||||||
|
|
||||||
msg.copy(configGet("admin", "reports"), caption=caption, reply_markup=InlineKeyboardMarkup([
|
msg.copy(configGet("admin", "reports"), caption=caption, reply_markup=InlineKeyboardMarkup(buttons))
|
||||||
[
|
|
||||||
InlineKeyboardButton(text=locale("sub_yes", "button", locale=configGet("locale")), callback_data=f"sub_yes_{msg.from_user.id}_{msg.id}"),
|
|
||||||
InlineKeyboardButton(text=locale("sub_no", "button", locale=configGet("locale")), callback_data=f"sub_no_{msg.from_user.id}_{msg.id}")
|
|
||||||
],
|
|
||||||
[
|
|
||||||
InlineKeyboardButton(text=locale("sub_block", "button", locale=configGet("locale")), callback_data=f"sub_block_{msg.from_user.id}")
|
|
||||||
],
|
|
||||||
[
|
|
||||||
InlineKeyboardButton(text=locale("sub_unblock", "button", locale=configGet("locale")), callback_data=f"sub_unblock_{msg.from_user.id}")
|
|
||||||
]
|
|
||||||
]
|
|
||||||
))
|
|
||||||
msg.reply_text(locale("sub_sent", "message", locale=user_locale), quote=True)
|
msg.reply_text(locale("sub_sent", "message", locale=user_locale), quote=True)
|
||||||
subLimit(msg.from_user)
|
subLimit(msg.from_user)
|
||||||
else:
|
else:
|
||||||
@ -247,7 +260,10 @@ def callback_query_yes(app, clb): # type: ignore
|
|||||||
clb.answer(text=locale("sub_msg_unavail", "message", locale=user_locale), show_alert=True)
|
clb.answer(text=locale("sub_msg_unavail", "message", locale=user_locale), show_alert=True)
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
app.download_media(submission, file_name=configGet("queue", "locations")+os.sep)
|
media = app.download_media(submission, file_name=configGet("queue", "locations")+os.sep)
|
||||||
|
if clb.data.endswith("_caption"):
|
||||||
|
captions = jsonLoad(configGet("captions", "locations"))
|
||||||
|
captions[Path(media).name] = submission.caption
|
||||||
except:
|
except:
|
||||||
clb.answer(text=locale("sub_media_unavail", "message", locale=user_locale), show_alert=True)
|
clb.answer(text=locale("sub_media_unavail", "message", locale=user_locale), show_alert=True)
|
||||||
return
|
return
|
||||||
|
Reference in New Issue
Block a user