Send a warning instead throwing an exeption when message type is not compatible with as_copy

This commit is contained in:
Florent Gallaire 2020-06-15 05:19:45 +00:00
parent 2adc01be7f
commit 4aaa7160f0

View File

@ -18,6 +18,7 @@
from functools import partial from functools import partial
from typing import List, Match, Union from typing import List, Match, Union
import logging
import pyrogram import pyrogram
from pyrogram.api import types from pyrogram.api import types
@ -34,6 +35,8 @@ from ..user_and_chats.user import User
from ...ext import utils from ...ext import utils
from ...parser import utils as parser_utils, Parser from ...parser import utils as parser_utils, Parser
log = logging.getLogger(__name__)
class Str(str): class Str(str):
def __init__(self, *args): def __init__(self, *args):
@ -2684,12 +2687,10 @@ 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("Unable to copy service messages, message_id: {}".format(self.message_id))
elif self.game and not self._client.is_bot:
if self.game and not self._client.is_bot: log.warning("Users cannot send messages with Game media type, message_id: {}".format(self.message_id))
raise ValueError("Users cannot send messages with Game media type") elif self.text:
if self.text:
return self._client.send_message( return self._client.send_message(
chat_id, chat_id,
text=self.text.html, text=self.text.html,