예제 #1
0
def send_message(
    bot: Bot,
    message: TMessage,
    to_user: int,
    reply_to: int,
    anonymous: bool,
    quote: bool,
):
    """Send message to given user after proper quotation."""
    from_tag = _get_from_tag(message, quote) if not anonymous else ""
    text, caption, send_from = _get_quotable(message, from_tag)
    msg: TMessage = None
    msgs = []

    if text:
        msg = bot.send_message(
            chat_id=to_user,
            text=text,
            reply_to_message_id=reply_to,
        )
    elif caption:
        msg = message.copy(
            chat_id=to_user,
            caption=caption,
            reply_to_message_id=reply_to,
        )
    else:
        msg = message.copy(
            chat_id=to_user,
            reply_to_message_id=reply_to,
        )

    msgs.append(msg.message_id)

    if send_from and not anonymous:
        omsg = bot.send_message(
            chat_id=to_user,
            text=from_tag,
            reply_to_message_id=msg.message_id,
        )
        msgs.append(omsg.message_id)

    return msgs
예제 #2
0
def send_message(message: Message, chat_id: int) -> Union[MessageId, Message]:
    if REMOVE_TAG:
        return message.copy(chat_id)
    return message.forward(chat_id)