User bans, emoji and other bug fixes, age limiter, etc #26

Merged
profitroll merged 31 commits from dev into master 2023-01-31 15:26:56 +02:00
3 changed files with 20 additions and 17 deletions
Showing only changes of commit f98fb0b6dc - Show all commits

View File

@ -319,7 +319,7 @@ class HoloUser():
if progress["state"] == "fill" and progress["sent"] is False:
if msg.text is not None:
msg.text = fix_text(msg.text)
msg.text = fix_text(str(msg.text))
if stage == 2:
@ -445,7 +445,7 @@ class HoloUser():
stage = progress["stage"]
if msg.text is not None:
msg.text = fix_text(msg.text)
msg.text = fix_text(str(msg.text))
elif msg.caption is not None:
msg.caption = fix_text(msg.caption)

View File

@ -18,10 +18,10 @@ async def cmd_message(app: Client, msg: Message):
except (ValueError, UserInvalidError):
destination = HoloUser(await find_user(app, query=msg.command[1]))
if ((msg.text is not None) and (len(msg.text.split()) > 2)):
await destination.message(context=msg, text=" ".join(msg.text.split()[2:]), caption=msg.caption, photo=msg.photo, video=msg.video, file=msg.document, voice=msg.voice, animation=msg.animation, adm_context=True)
if ((msg.text is not None) and (len(str(msg.text).split()) > 2)):
await destination.message(context=msg, text=" ".join(str(msg.text).split()[2:]), caption=msg.caption, photo=msg.photo, video=msg.video, file=msg.document, voice=msg.voice, animation=msg.animation, adm_context=True)
elif ((msg.caption is not None) and (len(msg.caption.split()) > 2)):
await destination.message(context=msg, text=msg.text, caption=" ".join(msg.caption.split()[2:]), photo=msg.photo, video=msg.video, file=msg.document, voice=msg.voice, animation=msg.animation, adm_context=True)
await destination.message(context=msg, text=str(msg.text), caption=" ".join(msg.caption.split()[2:]), photo=msg.photo, video=msg.video, file=msg.document, voice=msg.voice, animation=msg.animation, adm_context=True)
else:
await destination.message(context=msg, text=None, caption=None, photo=msg.photo, video=msg.video, file=msg.document, voice=msg.voice, animation=msg.animation, adm_context=True)

View File

@ -36,10 +36,13 @@ async def any_stage(app: Client, msg: Message):
destination_user = HoloUser(context_message.from_user)
if destination_user is None:
return
await destination_user.message(
origin=context_message,
context=msg,
text=msg.text,
text=str(msg.text),
caption=msg.caption,
photo=msg.photo,
video=msg.video,
@ -58,14 +61,14 @@ async def any_stage(app: Client, msg: Message):
if msg.text is not None:
if configGet("enabled", "features", "applications") is True:
await holo_user.application_next(msg.text, msg=msg)
await holo_user.application_next(str(msg.text), msg=msg)
if configGet("enabled", "features", "sponsorships") is True:
await holo_user.sponsorship_next(msg.text, msg)
await holo_user.sponsorship_next(str(msg.text), msg)
if msg.photo is not None:
await holo_user.sponsorship_next(msg.text, msg=msg, photo=msg.photo)
await holo_user.sponsorship_next(str(msg.text), msg=msg, photo=msg.photo)
if holo_user.application_state()[0] != "fill" and holo_user.sponsorship_state()[0] != "fill":
@ -84,7 +87,7 @@ async def any_stage(app: Client, msg: Message):
# Find category in all locales
for lc in all_locales("spoiler_categories", "message"):
for key in lc:
if lc[key] == msg.text:
if lc[key] == str(msg.text):
found = True
category = key
@ -104,16 +107,16 @@ async def any_stage(app: Client, msg: Message):
# return
if msg.text != "-":
msg.text = fix_text(msg.text)
if len(msg.text) > 1024:
if str(msg.text) != "-":
msg.text = fix_text(str(msg.text))
if len(str(msg.text)) > 1024:
await msg.reply_text(locale("spoiler_description_too_long", "message", locale=msg.from_user), reply_markup=ForceReply(placeholder=locale("spoiler_description", "force_reply", locale=msg.from_user)))
return
col_spoilers.find_one_and_update( {"user": msg.from_user.id, "completed": False}, {"$set": {"description": msg.text}} )
else:
col_spoilers.find_one_and_update( {"user": msg.from_user.id, "completed": False}, {"$set": {"description": ""}} )
logWrite(f"Adding description '{msg.text}' to {msg.from_user.id}'s spoiler")
logWrite(f"Adding description '{str(msg.text)}' to {msg.from_user.id}'s spoiler")
await msg.reply_text(locale("spoiler_using_description", "message", locale=msg.from_user).format(msg.text), reply_markup=ForceReply(placeholder=locale("spoiler_content", "force_reply", locale=msg.from_user)))
return
@ -147,8 +150,8 @@ async def any_stage(app: Client, msg: Message):
if spoiler["photo"] is None and spoiler["video"] is None and spoiler["audio"] is None and spoiler["animation"] is None and spoiler["document"] is None and spoiler["text"] is None:
if msg.text is not None:
col_spoilers.find_one_and_update( {"user": msg.from_user.id, "completed": False}, {"$set": {"text": msg.text, "completed": True}} )
logWrite(f"Adding text '{msg.text}' to {msg.from_user.id}'s spoiler")
col_spoilers.find_one_and_update( {"user": msg.from_user.id, "completed": False}, {"$set": {"text": str(msg.text), "completed": True}} )
logWrite(f"Adding text '{str(msg.text)}' to {msg.from_user.id}'s spoiler")
ready = True
if ready is True:
@ -191,7 +194,7 @@ async def any_stage(app: Client, msg: Message):
async def message_in_group(app: Client, msg: Message):
if (msg.chat is not None) and (msg.via_bot is not None):
if (msg.via_bot.id == (await app.get_me()).id) and (msg.chat.id == configGet("users", "groups")):
if msg.text.startswith(locale("spoiler_described", "message").split()[0]) or msg.text.startswith(locale("spoiler_empty", "message").split()[0]):
if str(msg.text).startswith(locale("spoiler_described", "message").split()[0]) or str(msg.text).startswith(locale("spoiler_empty", "message").split()[0]):
logWrite(f"User {msg.from_user.id} sent spoiler to user's group")
try:
logWrite("Forwarding spoiler to admin's group")