Fixed bugs of /message and now using cached media
This commit is contained in:
parent
1195df894c
commit
374effd5d7
@ -219,11 +219,11 @@ class HoloUser():
|
|||||||
if photo is not None:
|
if photo is not None:
|
||||||
if isinstance(photo, Photo):
|
if isinstance(photo, Photo):
|
||||||
photo = photo.file_id
|
photo = photo.file_id
|
||||||
new_message = await origin.reply_photo(photo, caption=caption, quote=True)
|
new_message = await origin.reply_cached_media(photo, caption=caption, quote=True)
|
||||||
elif video is not None:
|
elif video is not None:
|
||||||
if isinstance(video, Video):
|
if isinstance(video, Video):
|
||||||
video = video.file_id
|
video = video.file_id
|
||||||
new_message = await origin.reply_video(video, caption=caption, quote=True)
|
new_message = await origin.reply_cached_media(video, caption=caption, quote=True)
|
||||||
elif file is not None:
|
elif file is not None:
|
||||||
if isinstance(file, Document):
|
if isinstance(file, Document):
|
||||||
file = file.file_id
|
file = file.file_id
|
||||||
@ -231,7 +231,7 @@ class HoloUser():
|
|||||||
elif animation is not None:
|
elif animation is not None:
|
||||||
if isinstance(animation, Animation):
|
if isinstance(animation, Animation):
|
||||||
animation = animation.file_id
|
animation = animation.file_id
|
||||||
new_message = await origin.reply_animation(animation, caption=caption, quote=True)
|
new_message = await origin.reply_cached_media(animation, caption=caption, quote=True)
|
||||||
elif voice is not None:
|
elif voice is not None:
|
||||||
if isinstance(voice, Voice):
|
if isinstance(voice, Voice):
|
||||||
voice = voice.file_id
|
voice = voice.file_id
|
||||||
@ -244,11 +244,11 @@ class HoloUser():
|
|||||||
if photo is not None:
|
if photo is not None:
|
||||||
if isinstance(photo, Photo):
|
if isinstance(photo, Photo):
|
||||||
photo = photo.file_id
|
photo = photo.file_id
|
||||||
new_message = await app.send_photo(self.id, photo, caption=caption)
|
new_message = await app.send_cached_media(self.id, photo, caption=caption)
|
||||||
elif video is not None:
|
elif video is not None:
|
||||||
if isinstance(video, Video):
|
if isinstance(video, Video):
|
||||||
video = video.file_id
|
video = video.file_id
|
||||||
new_message = await app.send_video(self.id, video, caption=caption)
|
new_message = await app.send_cached_media(self.id, video, caption=caption)
|
||||||
elif file is not None:
|
elif file is not None:
|
||||||
if isinstance(file, Document):
|
if isinstance(file, Document):
|
||||||
file = file.file_id
|
file = file.file_id
|
||||||
@ -256,11 +256,11 @@ class HoloUser():
|
|||||||
elif animation is not None:
|
elif animation is not None:
|
||||||
if isinstance(animation, Animation):
|
if isinstance(animation, Animation):
|
||||||
animation = animation.file_id
|
animation = animation.file_id
|
||||||
new_message = await app.send_animation(self.id, animation, caption=caption)
|
new_message = await app.send_cached_media(self.id, animation, caption=caption)
|
||||||
elif voice is not None:
|
elif voice is not None:
|
||||||
if isinstance(voice, Voice):
|
if isinstance(voice, Voice):
|
||||||
voice = voice.file_id
|
voice = voice.file_id
|
||||||
new_message = await app.send_voice(self.id, voice, caption=caption)
|
new_message = await app.send_cached_media(self.id, voice, caption=caption)
|
||||||
else:
|
else:
|
||||||
new_message = await app.send_message(self.id, text)
|
new_message = await app.send_message(self.id, text)
|
||||||
|
|
||||||
@ -531,8 +531,8 @@ class HoloUser():
|
|||||||
return
|
return
|
||||||
progress["sponsorship"]["label"] = query
|
progress["sponsorship"]["label"] = query
|
||||||
col_tmp.update_one({"user": {"$eq": self.id}, "type": {"$eq": "sponsorship"}}, {"$set": {"sponsorship": progress["sponsorship"], "complete": True}})
|
col_tmp.update_one({"user": {"$eq": self.id}, "type": {"$eq": "sponsorship"}}, {"$set": {"sponsorship": progress["sponsorship"], "complete": True}})
|
||||||
await msg.reply_photo(
|
await msg.reply_cached_media(
|
||||||
photo=progress["sponsorship"]["proof"],
|
progress["sponsorship"]["proof"],
|
||||||
caption=locale("sponsor_confirm", "message", locale=self.locale).format(
|
caption=locale("sponsor_confirm", "message", locale=self.locale).format(
|
||||||
progress["sponsorship"]["streamer"],
|
progress["sponsorship"]["streamer"],
|
||||||
progress["sponsorship"]["expires"].strftime("%d.%m.%Y"),
|
progress["sponsorship"]["expires"].strftime("%d.%m.%Y"),
|
||||||
|
@ -18,11 +18,11 @@ async def cmd_message(app: Client, msg: Message):
|
|||||||
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(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, adm_context=True)
|
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)
|
||||||
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, adm_context=True)
|
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)
|
||||||
else:
|
else:
|
||||||
await destination.message(context=msg, text=None, caption=None, photo=msg.photo, video=msg.video, file=msg.document, 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)
|
||||||
|
|
||||||
except IndexError:
|
except IndexError:
|
||||||
await msg.reply_text(locale("message_invalid_syntax", "message", locale=msg.from_user), quote=should_quote(msg))
|
await msg.reply_text(locale("message_invalid_syntax", "message", locale=msg.from_user), quote=should_quote(msg))
|
||||||
|
@ -33,11 +33,11 @@ async def cmd_start(app: Client, msg: Message):
|
|||||||
try:
|
try:
|
||||||
spoiler = col_spoilers.find_one( {"_id": ObjectId(msg.command[1])} )
|
spoiler = col_spoilers.find_one( {"_id": ObjectId(msg.command[1])} )
|
||||||
if spoiler["photo"] is not None:
|
if spoiler["photo"] is not None:
|
||||||
await msg.reply_photo(spoiler["photo"], caption=spoiler["caption"])
|
await msg.reply_document(spoiler["photo"], caption=spoiler["caption"])
|
||||||
if spoiler["video"] is not None:
|
if spoiler["video"] is not None:
|
||||||
await msg.reply_video(spoiler["video"], caption=spoiler["caption"])
|
await msg.reply_cached_media(spoiler["video"], caption=spoiler["caption"])
|
||||||
if spoiler["animation"] is not None:
|
if spoiler["animation"] is not None:
|
||||||
await msg.reply_animation(spoiler["animation"], caption=spoiler["caption"])
|
await msg.reply_cached_media(spoiler["animation"], caption=spoiler["caption"])
|
||||||
if spoiler["document"] is not None:
|
if spoiler["document"] is not None:
|
||||||
await msg.reply_document(spoiler["document"], caption=spoiler["caption"])
|
await msg.reply_document(spoiler["document"], caption=spoiler["caption"])
|
||||||
if spoiler["text"] is not None:
|
if spoiler["text"] is not None:
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
from os import remove, sep
|
|
||||||
from typing import Literal
|
from typing import Literal
|
||||||
from uuid import uuid1
|
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from app import app
|
from app import app
|
||||||
@ -119,7 +117,7 @@ async def confirm_yes(app: Client, msg: Message, kind: Literal["application", "s
|
|||||||
else:
|
else:
|
||||||
sponsorship_content.append(f"{locale(f'question_{question}', 'message', 'sponsor_titles')} {tmp_sponsorship['sponsorship'][question]}")
|
sponsorship_content.append(f"{locale(f'question_{question}', 'message', 'sponsor_titles')} {tmp_sponsorship['sponsorship'][question]}")
|
||||||
|
|
||||||
await app.send_photo(chat_id=configGet("admin", "groups"), photo=tmp_sponsorship["sponsorship"]["proof"], caption=(locale("sponsor_got", "message")).format(str(holo_user.id), msg.from_user.first_name, msg.from_user.username, "\n".join(sponsorship_content)), parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup(
|
await app.send_cached_media(chat_id=configGet("admin", "groups"), photo=tmp_sponsorship["sponsorship"]["proof"], caption=(locale("sponsor_got", "message")).format(str(holo_user.id), msg.from_user.first_name, msg.from_user.username, "\n".join(sponsorship_content)), parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup(
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
InlineKeyboardButton(text=str(locale("sponsor_yes", "button")), callback_data=f"sponsor_yes_{holo_user.id}")
|
InlineKeyboardButton(text=str(locale("sponsor_yes", "button")), callback_data=f"sponsor_yes_{holo_user.id}")
|
||||||
|
@ -43,6 +43,8 @@ async def any_stage(app: Client, msg: Message):
|
|||||||
photo=msg.photo,
|
photo=msg.photo,
|
||||||
video=msg.video,
|
video=msg.video,
|
||||||
file=msg.document,
|
file=msg.document,
|
||||||
|
animation=msg.animation,
|
||||||
|
voice=msg.voice,
|
||||||
adm_origin=await isAnAdmin(context_message.from_user.id),
|
adm_origin=await isAnAdmin(context_message.from_user.id),
|
||||||
adm_context=await isAnAdmin(msg.from_user.id)
|
adm_context=await isAnAdmin(msg.from_user.id)
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user