Java Code Examples for org.telegram.tgnet.TLRPC#TL_inputPeerChannel

The following examples show how to use org.telegram.tgnet.TLRPC#TL_inputPeerChannel . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImageLocation.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public static ImageLocation getForChat(TLRPC.Chat chat, boolean big) {
    if (chat == null || chat.photo == null) {
        return null;
    }
    TLRPC.FileLocation fileLocation = big ? chat.photo.photo_big : chat.photo.photo_small;
    if (fileLocation == null) {
        return null;
    }
    TLRPC.InputPeer inputPeer;
    if (ChatObject.isChannel(chat)) {
        if (chat.access_hash == 0) {
            return null;
        }
        inputPeer = new TLRPC.TL_inputPeerChannel();
        inputPeer.channel_id = chat.id;
        inputPeer.access_hash = chat.access_hash;
    } else {
        inputPeer = new TLRPC.TL_inputPeerChat();
        inputPeer.chat_id = chat.id;
    }
    int dc_id;
    if (chat.photo.dc_id != 0) {
        dc_id = chat.photo.dc_id;
    } else {
        dc_id = fileLocation.dc_id;
    }
    return getForPhoto(fileLocation, 0, null, null, inputPeer, big, dc_id, null, null);
}
 
Example 2
Source File: FileRefController.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private boolean getPeerReferenceReplacement(TLRPC.User user, TLRPC.Chat chat, boolean big, TLRPC.InputFileLocation location, TLRPC.InputFileLocation[] replacement, boolean[] needReplacement) {
    if (needReplacement != null && needReplacement[0]) {
        replacement[0] = new TLRPC.TL_inputPeerPhotoFileLocation();
        replacement[0].id = location.volume_id;
        replacement[0].volume_id = location.volume_id;
        replacement[0].local_id = location.local_id;
        replacement[0].big = big;
        TLRPC.InputPeer peer;
        if (user != null) {
            TLRPC.TL_inputPeerUser inputPeerUser = new TLRPC.TL_inputPeerUser();
            inputPeerUser.user_id = user.id;
            inputPeerUser.access_hash = user.access_hash;
            peer = inputPeerUser;
        } else {
            if (ChatObject.isChannel(chat)) {
                TLRPC.TL_inputPeerChat inputPeerChat = new TLRPC.TL_inputPeerChat();
                inputPeerChat.chat_id = chat.id;
                peer = inputPeerChat;
            } else {
                TLRPC.TL_inputPeerChannel inputPeerChannel = new TLRPC.TL_inputPeerChannel();
                inputPeerChannel.channel_id = chat.id;
                inputPeerChannel.access_hash = chat.access_hash;
                peer = inputPeerChannel;
            }
        }
        replacement[0].peer = peer;
        return true;
    }
    return false;
}
 
Example 3
Source File: ImageLocation.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public static ImageLocation getForChat(TLRPC.Chat chat, boolean big) {
    if (chat == null || chat.photo == null) {
        return null;
    }
    TLRPC.FileLocation fileLocation = big ? chat.photo.photo_big : chat.photo.photo_small;
    if (fileLocation == null) {
        return null;
    }
    TLRPC.InputPeer inputPeer;
    if (ChatObject.isChannel(chat)) {
        if (chat.access_hash == 0) {
            return null;
        }
        inputPeer = new TLRPC.TL_inputPeerChannel();
        inputPeer.channel_id = chat.id;
        inputPeer.access_hash = chat.access_hash;
    } else {
        inputPeer = new TLRPC.TL_inputPeerChat();
        inputPeer.chat_id = chat.id;
    }
    int dc_id;
    if (chat.photo.dc_id != 0) {
        dc_id = chat.photo.dc_id;
    } else {
        dc_id = fileLocation.dc_id;
    }
    return getForPhoto(fileLocation, 0, null, null, inputPeer, big, dc_id, null, null);
}
 
Example 4
Source File: FileRefController.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private boolean getPeerReferenceReplacement(TLRPC.User user, TLRPC.Chat chat, boolean big, TLRPC.InputFileLocation location, TLRPC.InputFileLocation[] replacement, boolean[] needReplacement) {
    if (needReplacement != null && needReplacement[0]) {
        replacement[0] = new TLRPC.TL_inputPeerPhotoFileLocation();
        replacement[0].id = location.volume_id;
        replacement[0].volume_id = location.volume_id;
        replacement[0].local_id = location.local_id;
        replacement[0].big = big;
        TLRPC.InputPeer peer;
        if (user != null) {
            TLRPC.TL_inputPeerUser inputPeerUser = new TLRPC.TL_inputPeerUser();
            inputPeerUser.user_id = user.id;
            inputPeerUser.access_hash = user.access_hash;
            peer = inputPeerUser;
        } else {
            if (ChatObject.isChannel(chat)) {
                TLRPC.TL_inputPeerChat inputPeerChat = new TLRPC.TL_inputPeerChat();
                inputPeerChat.chat_id = chat.id;
                peer = inputPeerChat;
            } else {
                TLRPC.TL_inputPeerChannel inputPeerChannel = new TLRPC.TL_inputPeerChannel();
                inputPeerChannel.channel_id = chat.id;
                inputPeerChannel.access_hash = chat.access_hash;
                peer = inputPeerChannel;
            }
        }
        replacement[0].peer = peer;
        return true;
    }
    return false;
}