Java Code Examples for org.telegram.tgnet.TLRPC#InputPeer
The following examples show how to use
org.telegram.tgnet.TLRPC#InputPeer .
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: DialogObject.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public static long getPeerDialogId(TLRPC.InputPeer peer) { if (peer == null) { return 0; } if (peer.user_id != 0) { return peer.user_id; } else if (peer.chat_id != 0) { return -peer.chat_id; } else { return -peer.channel_id; } }
Example 2
Source File: ImageLocation.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
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 3
Source File: ImageLocation.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private static ImageLocation getForPhoto(TLRPC.FileLocation location, int size, TLRPC.Photo photo, TLRPC.Document document, TLRPC.InputPeer photoPeer, boolean photoPeerBig, int dc_id, TLRPC.InputStickerSet stickerSet, String thumbSize) { if (location == null || photo == null && photoPeer == null && stickerSet == null && document == null) { return null; } ImageLocation imageLocation = new ImageLocation(); imageLocation.dc_id = dc_id; imageLocation.photo = photo; imageLocation.currentSize = size; imageLocation.photoPeer = photoPeer; imageLocation.photoPeerBig = photoPeerBig; imageLocation.stickerSet = stickerSet; if (location instanceof TLRPC.TL_fileLocationToBeDeprecated) { imageLocation.location = (TLRPC.TL_fileLocationToBeDeprecated) location; if (photo != null) { imageLocation.file_reference = photo.file_reference; imageLocation.access_hash = photo.access_hash; imageLocation.photoId = photo.id; imageLocation.thumbSize = thumbSize; } else if (document != null) { imageLocation.file_reference = document.file_reference; imageLocation.access_hash = document.access_hash; imageLocation.documentId = document.id; imageLocation.thumbSize = thumbSize; } } else { imageLocation.location = new TLRPC.TL_fileLocationToBeDeprecated(); imageLocation.location.local_id = location.local_id; imageLocation.location.volume_id = location.volume_id; imageLocation.location.secret = location.secret; imageLocation.dc_id = location.dc_id; imageLocation.file_reference = location.file_reference; imageLocation.key = location.key; imageLocation.iv = location.iv; imageLocation.access_hash = location.secret; } return imageLocation; }
Example 4
Source File: FileRefController.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
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 5
Source File: DialogObject.java From Telegram with GNU General Public License v2.0 | 5 votes |
public static long getPeerDialogId(TLRPC.InputPeer peer) { if (peer == null) { return 0; } if (peer.user_id != 0) { return peer.user_id; } else if (peer.chat_id != 0) { return -peer.chat_id; } else { return -peer.channel_id; } }
Example 6
Source File: ImageLocation.java From Telegram with GNU General Public License v2.0 | 5 votes |
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 7
Source File: ImageLocation.java From Telegram with GNU General Public License v2.0 | 5 votes |
private static ImageLocation getForPhoto(TLRPC.FileLocation location, int size, TLRPC.Photo photo, TLRPC.Document document, TLRPC.InputPeer photoPeer, boolean photoPeerBig, int dc_id, TLRPC.InputStickerSet stickerSet, String thumbSize) { if (location == null || photo == null && photoPeer == null && stickerSet == null && document == null) { return null; } ImageLocation imageLocation = new ImageLocation(); imageLocation.dc_id = dc_id; imageLocation.photo = photo; imageLocation.currentSize = size; imageLocation.photoPeer = photoPeer; imageLocation.photoPeerBig = photoPeerBig; imageLocation.stickerSet = stickerSet; if (location instanceof TLRPC.TL_fileLocationToBeDeprecated) { imageLocation.location = (TLRPC.TL_fileLocationToBeDeprecated) location; if (photo != null) { imageLocation.file_reference = photo.file_reference; imageLocation.access_hash = photo.access_hash; imageLocation.photoId = photo.id; imageLocation.thumbSize = thumbSize; } else if (document != null) { imageLocation.file_reference = document.file_reference; imageLocation.access_hash = document.access_hash; imageLocation.documentId = document.id; imageLocation.thumbSize = thumbSize; } } else { imageLocation.location = new TLRPC.TL_fileLocationToBeDeprecated(); imageLocation.location.local_id = location.local_id; imageLocation.location.volume_id = location.volume_id; imageLocation.location.secret = location.secret; imageLocation.dc_id = location.dc_id; imageLocation.file_reference = location.file_reference; imageLocation.key = location.key; imageLocation.iv = location.iv; imageLocation.access_hash = location.secret; } return imageLocation; }
Example 8
Source File: FileRefController.java From Telegram with GNU General Public License v2.0 | 5 votes |
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; }