diff --git a/main.py b/main.py index 0607730..d868639 100644 --- a/main.py +++ b/main.py @@ -148,6 +148,11 @@ def send_content(): app.send_message(configGet("admin", "reports"), f"Could not send content due to `{exp}`\n\nTraceback:\n```{traceback.format_exc()}```") # type: ignore +@app.on_message(~ filters.scheduled & filters.command(["start", "help"], prefixes="/")) +def start(app, msg): + if msg.from_user.id not in jsonLoad(configGet("blocked", "locations")): + msg.reply_text(f"Hi and welcome!\n\nYou can submit your pictures and videos here. We'll review and add them, if we like them. Make sure you send your stuff one at a time and have chosen media that corresponds to our rules.\n\nYou can also write something to us in the description field. We'll send it with the submission itself, if needed.\n\nHave fun and happy submitting!") + @app.on_message(~ filters.scheduled & filters.command(["kill", "die", "reboot"], prefixes=["", "/"])) def kill(app, msg): @@ -177,21 +182,38 @@ def subLimited(user): def subBlock(user): blocked = jsonLoad(configGet("blocked", "locations")) - if user.id not in blocked: - blocked.append(user.id) + if user not in blocked: + blocked.append(user) jsonSave(blocked, configGet("blocked", "locations")) def subUnblock(user): blocked = jsonLoad(configGet("blocked", "locations")) - if user.id in blocked: - blocked.remove(user.id) + if user in blocked: + blocked.remove(user) jsonSave(blocked, configGet("blocked", "locations")) -@app.on_message(filters.photo | filters.video | filters.animation) +@app.on_message(~ filters.scheduled & filters.photo | filters.video | filters.animation) def get_submission(_, msg): if msg.from_user.id not in jsonLoad(configGet("blocked", "locations")): if not subLimited(msg.from_user): - msg.copy(configGet("admin", "reports"), reply_markup=InlineKeyboardMarkup([ + + if msg.caption != None: + caption = str(msg.caption) + else: + caption = "" + + caption += "\n\nSubmitted by:" + + if msg.from_user.first_name != None: + caption += f" {msg.from_user.first_name}" + if msg.from_user.last_name != None: + caption += f" {msg.from_user.last_name}" + if msg.from_user.username != None: + caption += f" (@{msg.from_user.username})" + if msg.from_user.phone_number != None: + caption += f" ({msg.from_user.phone_number})" + + msg.copy(configGet("admin", "reports"), caption=caption, reply_markup=InlineKeyboardMarkup([ [ InlineKeyboardButton(text="✅ Accept", callback_data=f"sub_yes_{msg.from_user.id}_{msg.id}"), InlineKeyboardButton(text="❌ Deny", callback_data=f"sub_no_{msg.from_user.id}_{msg.id}") @@ -281,6 +303,10 @@ if __name__ == "__main__": t = Thread(target=background_task) t.start() + app.set_bot_commands([ # type: ignore + BotCommand("start", "Start using the bot") + ]) + app.set_bot_commands([ # type: ignore BotCommand("reboot", "Reboot the bot"), ],