Compare commits

...

3 Commits

Author SHA1 Message Date
360bdf2c72 This commit closes #24 2023-01-30 10:58:47 +01:00
f98fb0b6dc Probably fix for static emojis from #25 2023-01-30 10:54:43 +01:00
eaec6f2fe8 Fixed join messages not being sent 2023-01-30 10:39:14 +01:00
5 changed files with 28 additions and 23 deletions

View File

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

View File

@@ -117,7 +117,8 @@
"spoiler_description_too_long": "Текст занадто довгий. Будь ласка, умісти опис у 1024 символи.", "spoiler_description_too_long": "Текст занадто довгий. Будь ласка, умісти опис у 1024 символи.",
"spoiler_using_description": "Встановлено опис спойлера: {0}\n\nЗалишилось додати вміст самого спойлера. Бот приймає текстове повідомлення, фото, відео, файл а також гіф зображення (1 шт.)", "spoiler_using_description": "Встановлено опис спойлера: {0}\n\nЗалишилось додати вміст самого спойлера. Бот приймає текстове повідомлення, фото, відео, файл а також гіф зображення (1 шт.)",
"spoiler_send_description": "Тепер треба надіслати коротенький опис спойлера, щоб люди розуміли що під ним варто очкувати. Надішли мінус (-) щоб пропустити цей крок.", "spoiler_send_description": "Тепер треба надіслати коротенький опис спойлера, щоб люди розуміли що під ним варто очкувати. Надішли мінус (-) щоб пропустити цей крок.",
"spoiler_ready": "Успіх! Спойлер створено. Користуйтесь кнопкою нижче щоб надіслати його.", "spoiler_ready": "Успіх! Спойлер створено",
"spoiler_send": "Користуйтесь кнопкою нижче щоб надіслати його.",
"spoiler_incorrect_content": "Бот не підтримує такий контент. Будь ласка, надішли текст, фото, відео, файл або анімацію (гіф).", "spoiler_incorrect_content": "Бот не підтримує такий контент. Будь ласка, надішли текст, фото, відео, файл або анімацію (гіф).",
"spoiler_incorrect_category": "Вказана категорія не є дійсною. Будь ласка, користуйся клавіатурою бота (кнопка біля 📎) для вибору категорії.", "spoiler_incorrect_category": "Вказана категорія не є дійсною. Будь ласка, користуйся клавіатурою бота (кнопка біля 📎) для вибору категорії.",
"spoiler_in_progress": "❌ **Дія неможлива**\nПерш ніж починати нову дію, треба завершити створення спойлера або перервати його командою /cancel.", "spoiler_in_progress": "❌ **Дія неможлива**\nПерш ніж починати нову дію, треба завершити створення спойлера або перервати його командою /cancel.",

View File

@@ -18,10 +18,10 @@ async def cmd_message(app: Client, msg: Message):
except (ValueError, UserInvalidError): except (ValueError, UserInvalidError):
destination = HoloUser(await find_user(app, query=msg.command[1])) destination = HoloUser(await find_user(app, query=msg.command[1]))
if ((msg.text is not None) and (len(msg.text.split()) > 2)): if ((msg.text is not None) and (len(str(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) 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)): 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: 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) 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

@@ -3,7 +3,7 @@ from app import app, isAnAdmin
import asyncio import asyncio
from ftfy import fix_text from ftfy import fix_text
from pyrogram import filters from pyrogram import filters
from pyrogram.types import Message, ForceReply, InlineKeyboardMarkup, InlineKeyboardButton from pyrogram.types import Message, ForceReply, InlineKeyboardMarkup, InlineKeyboardButton, ReplyKeyboardRemove
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, locale, all_locales from modules.utils import configGet, logWrite, locale, all_locales
@@ -36,10 +36,13 @@ async def any_stage(app: Client, msg: Message):
destination_user = HoloUser(context_message.from_user) destination_user = HoloUser(context_message.from_user)
if destination_user is None:
return
await destination_user.message( await destination_user.message(
origin=context_message, origin=context_message,
context=msg, context=msg,
text=msg.text, text=str(msg.text),
caption=msg.caption, caption=msg.caption,
photo=msg.photo, photo=msg.photo,
video=msg.video, video=msg.video,
@@ -58,14 +61,14 @@ async def any_stage(app: Client, msg: Message):
if msg.text is not None: if msg.text is not None:
if configGet("enabled", "features", "applications") is True: 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: 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: 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": 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 # Find category in all locales
for lc in all_locales("spoiler_categories", "message"): for lc in all_locales("spoiler_categories", "message"):
for key in lc: for key in lc:
if lc[key] == msg.text: if lc[key] == str(msg.text):
found = True found = True
category = key category = key
@@ -104,16 +107,16 @@ async def any_stage(app: Client, msg: Message):
# return # return
if msg.text != "-": if str(msg.text) != "-":
msg.text = fix_text(msg.text) msg.text = fix_text(str(msg.text))
if len(msg.text) > 1024: 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))) 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 return
col_spoilers.find_one_and_update( {"user": msg.from_user.id, "completed": False}, {"$set": {"description": msg.text}} ) col_spoilers.find_one_and_update( {"user": msg.from_user.id, "completed": False}, {"$set": {"description": msg.text}} )
else: else:
col_spoilers.find_one_and_update( {"user": msg.from_user.id, "completed": False}, {"$set": {"description": ""}} ) 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))) 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 return
@@ -147,14 +150,15 @@ 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 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: 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}} ) col_spoilers.find_one_and_update( {"user": msg.from_user.id, "completed": False}, {"$set": {"text": str(msg.text), "completed": True}} )
logWrite(f"Adding text '{msg.text}' to {msg.from_user.id}'s spoiler") logWrite(f"Adding text '{str(msg.text)}' to {msg.from_user.id}'s spoiler")
ready = True ready = True
if ready is True: if ready is True:
await msg.reply_text(locale("spoiler_ready", "message", locale=msg.from_user), reply_markup=ReplyKeyboardRemove())
if configGet("allow_external", "features", "spoilers") is True: if configGet("allow_external", "features", "spoilers") is True:
await msg.reply_text( await msg.reply_text(
locale("spoiler_ready", "message", locale=msg.from_user), locale("spoiler_send", "message", locale=msg.from_user),
reply_markup=InlineKeyboardMarkup( reply_markup=InlineKeyboardMarkup(
[ [
[ [
@@ -171,7 +175,7 @@ async def any_stage(app: Client, msg: Message):
) )
else: else:
await msg.reply_text( await msg.reply_text(
locale("spoiler_ready", "message", locale=msg.from_user), locale("spoiler_send", "message", locale=msg.from_user),
reply_markup=InlineKeyboardMarkup( reply_markup=InlineKeyboardMarkup(
[ [
[ [
@@ -191,7 +195,7 @@ async def any_stage(app: Client, msg: Message):
async def message_in_group(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.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.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") logWrite(f"User {msg.from_user.id} sent spoiler to user's group")
try: try:
logWrite("Forwarding spoiler to admin's group") logWrite("Forwarding spoiler to admin's group")

View File

@@ -41,7 +41,7 @@ async def filter_join(app: Client, member: ChatMemberUpdated):
i += 1 i += 1
await app.send_message(configGet("users", "groups"), locale("joined_application", "messages").format(member.from_user.first_name, member.from_user.username, "\n".join(application_content))) await app.send_message(configGet("users", "groups"), locale("joined_application", "message").format(member.from_user.first_name, member.from_user.username, "\n".join(application_content)))
return return
@@ -72,7 +72,7 @@ async def filter_join(app: Client, member: ChatMemberUpdated):
i += 1 i += 1
await app.send_message(configGet("users", "groups"), locale("joined_application", "messages").format(member.from_user.first_name, member.from_user.username, "\n".join(application_content))) await app.send_message(configGet("users", "groups"), locale("joined_application", "message").format(member.from_user.first_name, member.from_user.username, "\n".join(application_content)))
return return