Spoilers, major command system improvements #4
@ -351,6 +351,9 @@ class HoloUser():
|
|||||||
if self.sponsorship_state()[0] == "fill":
|
if self.sponsorship_state()[0] == "fill":
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if self.spoiler_state() is True:
|
||||||
|
return
|
||||||
|
|
||||||
# col_tmp.insert_one(
|
# col_tmp.insert_one(
|
||||||
# document=DefaultApplicationTemp(self.id).dict
|
# document=DefaultApplicationTemp(self.id).dict
|
||||||
# )
|
# )
|
||||||
|
@ -37,7 +37,6 @@ from modules.callbacks.sus import *
|
|||||||
from modules.handlers.confirmation import *
|
from modules.handlers.confirmation import *
|
||||||
from modules.handlers.contact import *
|
from modules.handlers.contact import *
|
||||||
from modules.handlers.group_join import *
|
from modules.handlers.group_join import *
|
||||||
from modules.handlers.spoiler import *
|
|
||||||
from modules.handlers.sponsorship import *
|
from modules.handlers.sponsorship import *
|
||||||
from modules.handlers.voice import *
|
from modules.handlers.voice import *
|
||||||
from modules.handlers.welcome import *
|
from modules.handlers.welcome import *
|
||||||
@ -53,26 +52,6 @@ if __name__ == "__main__":
|
|||||||
# I did compare performance, almost no difference and it's much more useful this way. Change my mind.
|
# I did compare performance, almost no difference and it's much more useful this way. Change my mind.
|
||||||
app.start()
|
app.start()
|
||||||
|
|
||||||
# if configGet("birthdays_notify"):
|
|
||||||
|
|
||||||
# every().day.at(configGet("birthdays_time")).do(check_birthdays, app)
|
|
||||||
|
|
||||||
# # Background tasks checker
|
|
||||||
# def background_task():
|
|
||||||
# try:
|
|
||||||
# while True:
|
|
||||||
# try:
|
|
||||||
# run_pending()
|
|
||||||
# #print('Checked')
|
|
||||||
# time.sleep(1)
|
|
||||||
# except:
|
|
||||||
# pass
|
|
||||||
# except KeyboardInterrupt:
|
|
||||||
# print('\nShutting down')
|
|
||||||
# killProc(pid)
|
|
||||||
# t = Thread(target=background_task)
|
|
||||||
# t.start()
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
app.send_message(configGet("owner"), f"Starting up with pid `{pid}`")
|
app.send_message(configGet("owner"), f"Starting up with pid `{pid}`")
|
||||||
except bad_request_400.PeerIdInvalid:
|
except bad_request_400.PeerIdInvalid:
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
from app import app, isAnAdmin
|
from app import app, isAnAdmin
|
||||||
import asyncio
|
import asyncio
|
||||||
from pyrogram import filters
|
from pyrogram import filters
|
||||||
from pyrogram.types import Message
|
from pyrogram.types import Message, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply, InlineKeyboardMarkup, InlineKeyboardButton
|
||||||
from pyrogram.client import Client
|
from pyrogram.client import Client
|
||||||
from classes.holo_user import HoloUser
|
from classes.holo_user import HoloUser
|
||||||
from modules.utils import configGet, logWrite
|
from modules.utils import configGet, logWrite, locale, all_locales
|
||||||
from modules.database import col_messages
|
from modules.database import col_messages, col_spoilers
|
||||||
|
|
||||||
async def message_involved(msg: Message) -> bool:
|
async def message_involved(msg: Message) -> bool:
|
||||||
message = col_messages.find_one({"destination.id": msg.reply_to_message.id, "destination.chat": msg.reply_to_message.chat.id})
|
message = col_messages.find_one({"destination.id": msg.reply_to_message.id, "destination.chat": msg.reply_to_message.chat.id})
|
||||||
@ -59,6 +59,39 @@ async def any_stage(app: Client, msg: Message):
|
|||||||
if configGet("enabled", "features", "sponsorships") is True:
|
if configGet("enabled", "features", "sponsorships") is True:
|
||||||
await holo_user.sponsorship_next(msg.text, msg=msg)
|
await holo_user.sponsorship_next(msg.text, msg=msg)
|
||||||
|
|
||||||
|
if holo_user.application_state()[0] != "fill" and holo_user.sponsorship_state()[0] != "fill":
|
||||||
|
|
||||||
|
spoiler = col_spoilers.find_one( {"user": msg.from_user.id, "completed": False} )
|
||||||
|
|
||||||
|
if spoiler is None:
|
||||||
|
return
|
||||||
|
|
||||||
|
if msg.photo is not None:
|
||||||
|
col_spoilers.find_one_and_update( {"user": msg.from_user.id, "completed": False}, {"$set": {"photo": msg.photo.file_id}} )
|
||||||
|
await msg.reply_text(locale("spoiler_send_description", "message", locale=msg.from_user), reply_markup=ReplyKeyboardMarkup(locale("spoiler_description", "keyboard"), resize_keyboard=True, one_time_keyboard=True, placeholder=locale("spoiler_description", "force_reply", locale=msg.from_user)))
|
||||||
|
return
|
||||||
|
elif msg.video is not None:
|
||||||
|
col_spoilers.find_one_and_update( {"user": msg.from_user.id, "completed": False}, {"$set": {"video": msg.video.file_id}} )
|
||||||
|
await msg.reply_text(locale("spoiler_send_description", "message", locale=msg.from_user), reply_markup=ReplyKeyboardMarkup(locale("spoiler_description", "keyboard"), resize_keyboard=True, one_time_keyboard=True, placeholder=locale("spoiler_description", "force_reply", locale=msg.from_user)))
|
||||||
|
return
|
||||||
|
elif msg.animation is not None:
|
||||||
|
col_spoilers.find_one_and_update( {"user": msg.from_user.id, "completed": False}, {"$set": {"animation": msg.animation.file_id}} )
|
||||||
|
await msg.reply_text(locale("spoiler_send_description", "message", locale=msg.from_user), reply_markup=ReplyKeyboardMarkup(locale("spoiler_description", "keyboard"), resize_keyboard=True, one_time_keyboard=True, placeholder=locale("spoiler_description", "force_reply", locale=msg.from_user)))
|
||||||
|
return
|
||||||
|
|
||||||
|
if spoiler["photo"] is None and spoiler["video"] is None and spoiler["animation"] is None and spoiler["text"] is None:
|
||||||
|
col_spoilers.find_one_and_update( {"user": msg.from_user.id, "completed": False}, {"$set": {"text": msg.text}} )
|
||||||
|
await msg.reply_text(locale("spoiler_send_description", "message", locale=msg.from_user), reply_markup=ReplyKeyboardMarkup(locale("spoiler_description", "keyboard"), resize_keyboard=True, one_time_keyboard=True, placeholder=locale("spoiler_description", "force_reply", locale=msg.from_user)))
|
||||||
|
else:
|
||||||
|
for lc in all_locales("spoiler_description", "keyboard"):
|
||||||
|
if msg.text == lc[-1][0]:
|
||||||
|
await msg.reply_text(locale("spoiler_description_enter", "message", locale=msg.from_user), reply_markup=ForceReply(placeholder=locale("spoiler_description", "force_reply", locale=msg.from_user)))
|
||||||
|
return
|
||||||
|
if msg.text != "-":
|
||||||
|
col_spoilers.find_one_and_update( {"user": msg.from_user.id, "completed": False}, {"$set": {"description": msg.text, "completed": True}} )
|
||||||
|
await msg.reply_text(locale("spoiler_using_description", "message", locale=msg.from_user).format(msg.text), reply_markup=ReplyKeyboardRemove())
|
||||||
|
await msg.reply_text(locale("spoiler_ready", "message", locale=msg.from_user), quote=False, reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(locale("spoiler_send", "button", locale=msg.from_user), switch_inline_query=f"spoiler:{spoiler['_id'].__str__()}")]]))
|
||||||
|
|
||||||
# user_stage = configGet("stage", file=str(msg.from_user.id))
|
# user_stage = configGet("stage", file=str(msg.from_user.id))
|
||||||
|
|
||||||
# if user_stage == 1:
|
# if user_stage == 1:
|
||||||
|
@ -1,86 +0,0 @@
|
|||||||
from app import app
|
|
||||||
from pyrogram import filters
|
|
||||||
from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton, ForceReply, ReplyKeyboardMarkup, ReplyKeyboardRemove
|
|
||||||
from pyrogram.client import Client
|
|
||||||
from classes.holo_user import HoloUser, UserInvalidError, UserNotFoundError
|
|
||||||
from modules.utils import locale, all_locales
|
|
||||||
from modules.database import col_spoilers
|
|
||||||
from modules import custom_filters
|
|
||||||
|
|
||||||
# Any other input ==============================================================================================================
|
|
||||||
@app.on_message(custom_filters.member & ~filters.scheduled & filters.private & filters.text)
|
|
||||||
async def handler_spoiler_text(app: Client, msg: Message):
|
|
||||||
|
|
||||||
try:
|
|
||||||
holo_user = HoloUser(msg.from_user)
|
|
||||||
except (UserInvalidError, UserNotFoundError):
|
|
||||||
return
|
|
||||||
|
|
||||||
if holo_user.application_state()[0] != "fill" and holo_user.sponsorship_state()[0] != "fill":
|
|
||||||
|
|
||||||
spoiler = col_spoilers.find_one( {"user": msg.from_user.id, "completed": False} )
|
|
||||||
|
|
||||||
if spoiler is None:
|
|
||||||
return
|
|
||||||
|
|
||||||
if spoiler["photo"] is None and spoiler["video"] is None and spoiler["animation"] is None and spoiler["text"] is None:
|
|
||||||
col_spoilers.find_one_and_update( {"user": msg.from_user.id, "completed": False}, {"$set": {"text": msg.text}} )
|
|
||||||
await msg.reply_text(locale("spoiler_send_description", "message", locale=msg.from_user), reply_markup=ReplyKeyboardMarkup(locale("spoiler_description", "keyboard"), resize_keyboard=True, one_time_keyboard=True, placeholder=locale("spoiler_description", "force_reply", locale=msg.from_user)))
|
|
||||||
else:
|
|
||||||
for lc in all_locales("spoiler_description", "keyboard"):
|
|
||||||
if msg.text == lc[-1][0]:
|
|
||||||
await msg.reply_text(locale("spoiler_description_enter", "message", locale=msg.from_user), reply_markup=ForceReply(placeholder=locale("spoiler_description", "force_reply", locale=msg.from_user)))
|
|
||||||
return
|
|
||||||
if msg.text != "-":
|
|
||||||
col_spoilers.find_one_and_update( {"user": msg.from_user.id, "completed": False}, {"$set": {"description": msg.text, "completed": True}} )
|
|
||||||
await msg.reply_text(locale("spoiler_using_description", "message", locale=msg.from_user).format(msg.text), reply_markup=ReplyKeyboardRemove())
|
|
||||||
await msg.reply_text(locale("spoiler_ready", "message", locale=msg.from_user), quote=False, reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(locale("spoiler_send", "button", locale=msg.from_user), switch_inline_query=f"spoiler:{spoiler['_id'].__str__()}")]]))
|
|
||||||
|
|
||||||
@app.on_message(custom_filters.member & ~filters.scheduled & filters.private & filters.photo)
|
|
||||||
async def handler_spoiler_photo(app: Client, msg: Message):
|
|
||||||
|
|
||||||
try:
|
|
||||||
holo_user = HoloUser(msg.from_user)
|
|
||||||
except (UserInvalidError, UserNotFoundError):
|
|
||||||
return
|
|
||||||
|
|
||||||
if holo_user.application_state()[0] != "fill" and holo_user.sponsorship_state()[0] != "fill":
|
|
||||||
|
|
||||||
|
|
||||||
if col_spoilers.find_one( {"user": msg.from_user.id, "completed": False} ) is None:
|
|
||||||
return
|
|
||||||
|
|
||||||
col_spoilers.find_one_and_update( {"user": msg.from_user.id, "completed": False}, {"$set": {"photo": msg.photo.file_id}} )
|
|
||||||
await msg.reply_text(locale("spoiler_send_description", "message", locale=msg.from_user), reply_markup=ReplyKeyboardMarkup(locale("spoiler_description", "keyboard"), resize_keyboard=True, one_time_keyboard=True, placeholder=locale("spoiler_description", "force_reply", locale=msg.from_user)))
|
|
||||||
|
|
||||||
@app.on_message(custom_filters.member & ~filters.scheduled & filters.private & filters.video)
|
|
||||||
async def handler_spoiler_video(app: Client, msg: Message):
|
|
||||||
|
|
||||||
try:
|
|
||||||
holo_user = HoloUser(msg.from_user)
|
|
||||||
except (UserInvalidError, UserNotFoundError):
|
|
||||||
return
|
|
||||||
|
|
||||||
if holo_user.application_state()[0] != "fill" and holo_user.sponsorship_state()[0] != "fill":
|
|
||||||
|
|
||||||
if col_spoilers.find_one( {"user": msg.from_user.id, "completed": False} ) is None:
|
|
||||||
return
|
|
||||||
|
|
||||||
col_spoilers.find_one_and_update( {"user": msg.from_user.id, "completed": False}, {"$set": {"video": msg.video.file_id}} )
|
|
||||||
await msg.reply_text(locale("spoiler_send_description", "message", locale=msg.from_user), reply_markup=ReplyKeyboardMarkup(locale("spoiler_description", "keyboard"), resize_keyboard=True, one_time_keyboard=True, placeholder=locale("spoiler_description", "force_reply", locale=msg.from_user)))
|
|
||||||
|
|
||||||
@app.on_message(custom_filters.member & ~filters.scheduled & filters.private & filters.animation)
|
|
||||||
async def handler_spoiler_animation(app: Client, msg: Message):
|
|
||||||
|
|
||||||
try:
|
|
||||||
holo_user = HoloUser(msg.from_user)
|
|
||||||
except (UserInvalidError, UserNotFoundError):
|
|
||||||
return
|
|
||||||
|
|
||||||
if holo_user.application_state()[0] != "fill" and holo_user.sponsorship_state()[0] != "fill":
|
|
||||||
|
|
||||||
if col_spoilers.find_one( {"user": msg.from_user.id, "completed": False} ) is None:
|
|
||||||
return
|
|
||||||
|
|
||||||
col_spoilers.find_one_and_update( {"user": msg.from_user.id, "completed": False}, {"$set": {"animation": msg.animation.file_id}} )
|
|
||||||
await msg.reply_text(locale("spoiler_send_description", "message", locale=msg.from_user), reply_markup=ReplyKeyboardMarkup(locale("spoiler_description", "keyboard"), resize_keyboard=True, one_time_keyboard=True, placeholder=locale("spoiler_description", "force_reply", locale=msg.from_user)))
|
|
Reference in New Issue
Block a user