From 4aaa7160f06ef12a08e21d627512ce6446971a5f Mon Sep 17 00:00:00 2001 From: Florent Gallaire Date: Mon, 15 Jun 2020 05:19:45 +0000 Subject: [PATCH] Send a warning instead throwing an exeption when message type is not compatible with as_copy --- pyrogram/client/types/messages_and_media/message.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pyrogram/client/types/messages_and_media/message.py b/pyrogram/client/types/messages_and_media/message.py index 215f86d0..238736e6 100644 --- a/pyrogram/client/types/messages_and_media/message.py +++ b/pyrogram/client/types/messages_and_media/message.py @@ -18,6 +18,7 @@ from functools import partial from typing import List, Match, Union +import logging import pyrogram from pyrogram.api import types @@ -34,6 +35,8 @@ from ..user_and_chats.user import User from ...ext import utils from ...parser import utils as parser_utils, Parser +log = logging.getLogger(__name__) + class Str(str): def __init__(self, *args): @@ -2684,12 +2687,10 @@ class Message(Object, Update): """ if as_copy: if self.service: - raise ValueError("Unable to copy service messages") - - if self.game and not self._client.is_bot: - raise ValueError("Users cannot send messages with Game media type") - - if self.text: + log.warning("Unable to copy service messages, message_id: {}".format(self.message_id)) + elif self.game and not self._client.is_bot: + log.warning("Users cannot send messages with Game media type, message_id: {}".format(self.message_id)) + elif self.text: return self._client.send_message( chat_id, text=self.text.html,