Submission feature development started
This commit is contained in:
parent
91a65d9b49
commit
5d29bfeff4
@ -16,7 +16,8 @@
|
||||
"data": "data",
|
||||
"queue": "data/queue",
|
||||
"sent": "data/sent",
|
||||
"index": "data/index.json"
|
||||
"index": "data/index.json",
|
||||
"submit": "data/submit.json"
|
||||
},
|
||||
"posting": {
|
||||
"channel": 0,
|
||||
@ -51,5 +52,8 @@
|
||||
"enabled": false,
|
||||
"text": "sample text",
|
||||
"link": null
|
||||
},
|
||||
"submission": {
|
||||
"limit": 30
|
||||
}
|
||||
}
|
1
data/submit.json
Normal file
1
data/submit.json
Normal file
@ -0,0 +1 @@
|
||||
{}
|
37
main.py
37
main.py
@ -10,8 +10,7 @@ import traceback
|
||||
from modules.logging import logWrite
|
||||
from modules.utils import configGet, jsonLoad, jsonSave
|
||||
|
||||
pid = os.getpid()
|
||||
|
||||
# Args =====================================================================================================================================
|
||||
if "--move-sent" in sys.argv:
|
||||
for entry in jsonLoad(configGet("index", "locations"))["sent"]:
|
||||
try:
|
||||
@ -54,7 +53,10 @@ if "--cleanup-index" in sys.argv:
|
||||
if "--norun" in sys.argv:
|
||||
logWrite("Argument --norun passed, not running the main script")
|
||||
sys.exit()
|
||||
#===========================================================================================================================================
|
||||
|
||||
|
||||
# Import ===================================================================================================================================
|
||||
try:
|
||||
import schedule # type: ignore
|
||||
from pyrogram import Client, filters, idle # type: ignore
|
||||
@ -62,7 +64,10 @@ try:
|
||||
except ModuleNotFoundError:
|
||||
print(f"Required modules are not installed. Run 'pip3 install -r requirements.txt' and restart the program.", flush=True)
|
||||
sys.exit()
|
||||
#===========================================================================================================================================
|
||||
|
||||
|
||||
pid = os.getpid()
|
||||
app = Client("duptsiaposter", bot_token=configGet("bot_token", "bot"), api_id=configGet("api_id", "bot"), api_hash=configGet("api_hash", "bot"))
|
||||
|
||||
|
||||
@ -151,6 +156,34 @@ def kill(app, msg):
|
||||
os.system('kill -9 '+str(pid))
|
||||
|
||||
|
||||
# Submission =====================================================================================================================================
|
||||
def subLimit(user):
|
||||
submit = jsonLoad(configGet("submit", "locations"))
|
||||
submit[str(user.id)] = time.time()
|
||||
jsonSave(submit, configGet("submit", "locations"))
|
||||
|
||||
def subLimited(user):
|
||||
if user.id == configGet("admin", "reports"):
|
||||
return False
|
||||
else:
|
||||
submit = jsonLoad(configGet("submit", "locations"))
|
||||
if str(user.id) in submit:
|
||||
if (time.time - submit[str(user.id)]) > configGet("limit", "submission"):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
return False
|
||||
|
||||
@app.on_message(filters.photo | filters.video | filters.animation)
|
||||
def get_submission(_, msg):
|
||||
if not subLimited(msg.from_user):
|
||||
subLimit(msg.from_user)
|
||||
else:
|
||||
msg.reply_text(f'You can only submit 1 media per {configGet("limit", "submission")} seconds')
|
||||
#===========================================================================================================================================
|
||||
|
||||
|
||||
for entry in configGet("time", "posting"):
|
||||
schedule.every().day.at(entry).do(send_content)
|
||||
|
||||
|
Reference in New Issue
Block a user