def check_schedule_message(sender: UserProfile, client: Client, message_type_name: str, message_to: Union[(Sequence[str], Sequence[int])], topic_name: Optional[str], message_content: str, delivery_type: str, deliver_at: datetime.datetime, realm: Optional[Realm]=None, forwarder_user_profile: Optional[UserProfile]=None) -> int:
    addressee = Addressee.legacy_build(sender, message_type_name, message_to, topic_name)
    message = check_message(sender, client, addressee, message_content, realm=realm, forwarder_user_profile=forwarder_user_profile)
    message['deliver_at'] = deliver_at
    message['delivery_type'] = delivery_type
    recipient = message['message'].recipient
    if ((delivery_type == 'remind') and ((recipient.type != Recipient.STREAM) and (recipient.type_id != sender.id))):
        raise JsonableError(_('Reminders can only be set for streams.'))
    return do_schedule_messages([message])[0]
def check_schedule_message(sender: UserProfile, client: Client, message_type_name: str, message_to: Union[(Sequence[str], Sequence[int])], topic_name: Optional[str], message_content: str, delivery_type: str, deliver_at: datetime.datetime, realm: Optional[Realm]=None, forwarder_user_profile: Optional[UserProfile]=None) -> int:
    addressee = Addressee.legacy_build(sender, message_type_name, message_to, topic_name)
    message = check_message(sender, client, addressee, message_content, realm=realm, forwarder_user_profile=forwarder_user_profile)
    message['deliver_at'] = deliver_at
    message['delivery_type'] = delivery_type
    recipient = message['message'].recipient
    if ((delivery_type == 'remind') and ((recipient.type != Recipient.STREAM) and (recipient.type_id != sender.id))):
        raise JsonableError(_('Reminders can only be set for streams.'))
    return do_schedule_messages([message])[0]