Show warnings when messages are not compatible with as_copy

This commit is contained in:
Dan 2020-08-30 11:34:23 +02:00
commit fcc78091c2

View File

@ -16,6 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License # You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. # along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
import logging
from functools import partial from functools import partial
from typing import List, Match, Union, BinaryIO from typing import List, Match, Union, BinaryIO
@ -28,6 +29,8 @@ from pyrogram.parser import utils as parser_utils, Parser
from ..object import Object from ..object import Object
from ..update import Update from ..update import Update
log = logging.getLogger(__name__)
class Str(str): class Str(str):
def __init__(self, *args): def __init__(self, *args):
@ -2706,12 +2709,12 @@ class Message(Object, Update):
""" """
if as_copy: if as_copy:
if self.service: if self.service:
raise ValueError("Unable to copy service messages") log.warning(f"Service messages cannot be copied. "
f"chat_id: {self.chat.id}, message_id: {self.message_id}")
if self.game and not await self._client.storage.is_bot(): elif self.game and not await self._client.storage.is_bot():
raise ValueError("Users cannot send messages with Game media type") log.warning(f"Users cannot send messages with Game media type. "
f"chat_id: {self.chat.id}, message_id: {self.message_id}")
if self.text: elif self.text:
return await self._client.send_message( return await self._client.send_message(
chat_id, chat_id,
text=self.text.html, text=self.text.html,