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

The following examples show how to use org.telegram.tgnet.TLRPC#TL_chatBannedRights . 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: ChatObject.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public static String getBannedRightsString(TLRPC.TL_chatBannedRights bannedRights) {
    String currentBannedRights = "";
    currentBannedRights += bannedRights.view_messages ? 1 : 0;
    currentBannedRights += bannedRights.send_messages ? 1 : 0;
    currentBannedRights += bannedRights.send_media ? 1 : 0;
    currentBannedRights += bannedRights.send_stickers ? 1 : 0;
    currentBannedRights += bannedRights.send_gifs ? 1 : 0;
    currentBannedRights += bannedRights.send_games ? 1 : 0;
    currentBannedRights += bannedRights.send_inline ? 1 : 0;
    currentBannedRights += bannedRights.embed_links ? 1 : 0;
    currentBannedRights += bannedRights.send_polls ? 1 : 0;
    currentBannedRights += bannedRights.invite_users ? 1 : 0;
    currentBannedRights += bannedRights.change_info ? 1 : 0;
    currentBannedRights += bannedRights.pin_messages ? 1 : 0;
    currentBannedRights += bannedRights.until_date;
    return currentBannedRights;
}
 
Example 2
Source File: ChatUsersActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private void updateParticipantWithRights(TLRPC.ChannelParticipant channelParticipant, TLRPC.TL_chatAdminRights rightsAdmin, TLRPC.TL_chatBannedRights rightsBanned, int user_id, boolean withDelegate) {
    boolean delegateCalled = false;
    for (int a = 0; a < 3; a++) {
        SparseArray<TLObject> map;
        if (a == 0) {
            map = contactsMap;
        } else if (a == 1) {
            map = botsMap;
        } else {
            map = participantsMap;
        }
        TLObject p = map.get(channelParticipant.user_id);
        if (p instanceof TLRPC.ChannelParticipant) {
            channelParticipant = (TLRPC.ChannelParticipant) p;
            channelParticipant.admin_rights = rightsAdmin;
            channelParticipant.banned_rights = rightsBanned;
            if (withDelegate) {
                channelParticipant.promoted_by = getUserConfig().getClientUserId();
            }
        }
        if (withDelegate && p != null && !delegateCalled && delegate != null) {
            delegateCalled = true;
            delegate.didAddParticipantToList(user_id, p);
        }
    }
}
 
Example 3
Source File: ChatObject.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public static String getBannedRightsString(TLRPC.TL_chatBannedRights bannedRights) {
    String currentBannedRights = "";
    currentBannedRights += bannedRights.view_messages ? 1 : 0;
    currentBannedRights += bannedRights.send_messages ? 1 : 0;
    currentBannedRights += bannedRights.send_media ? 1 : 0;
    currentBannedRights += bannedRights.send_stickers ? 1 : 0;
    currentBannedRights += bannedRights.send_gifs ? 1 : 0;
    currentBannedRights += bannedRights.send_games ? 1 : 0;
    currentBannedRights += bannedRights.send_inline ? 1 : 0;
    currentBannedRights += bannedRights.embed_links ? 1 : 0;
    currentBannedRights += bannedRights.send_polls ? 1 : 0;
    currentBannedRights += bannedRights.invite_users ? 1 : 0;
    currentBannedRights += bannedRights.change_info ? 1 : 0;
    currentBannedRights += bannedRights.pin_messages ? 1 : 0;
    currentBannedRights += bannedRights.until_date;
    return currentBannedRights;
}
 
Example 4
Source File: ChatUsersActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private void updateParticipantWithRights(TLRPC.ChannelParticipant channelParticipant, TLRPC.TL_chatAdminRights rightsAdmin, TLRPC.TL_chatBannedRights rightsBanned, int user_id, boolean withDelegate) {
    boolean delegateCalled = false;
    for (int a = 0; a < 3; a++) {
        SparseArray<TLObject> map;
        if (a == 0) {
            map = contactsMap;
        } else if (a == 1) {
            map = botsMap;
        } else {
            map = participantsMap;
        }
        TLObject p = map.get(channelParticipant.user_id);
        if (p instanceof TLRPC.ChannelParticipant) {
            channelParticipant = (TLRPC.ChannelParticipant) p;
            channelParticipant.admin_rights = rightsAdmin;
            channelParticipant.banned_rights = rightsBanned;
            if (withDelegate) {
                channelParticipant.promoted_by = getUserConfig().getClientUserId();
            }
        }
        if (withDelegate && p != null && !delegateCalled && delegate != null) {
            delegateCalled = true;
            delegate.didAddParticipantToList(user_id, p);
        }
    }
}
 
Example 5
Source File: ChatObject.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private static boolean getBannedRight(TLRPC.TL_chatBannedRights rights, int action) {
    if (rights == null) {
        return false;
    }
    boolean value;
    switch (action) {
        case ACTION_PIN:
            return rights.pin_messages;
        case ACTION_CHANGE_INFO:
            return rights.change_info;
        case ACTION_INVITE:
            return rights.invite_users;
        case ACTION_SEND:
            return rights.send_messages;
        case ACTION_SEND_MEDIA:
            return rights.send_media;
        case ACTION_SEND_STICKERS:
            return rights.send_stickers;
        case ACTION_EMBED_LINKS:
            return rights.embed_links;
        case ACTION_SEND_POLLS:
            return rights.send_polls;
        case ACTION_VIEW:
            return rights.view_messages;
    }
    return false;
}
 
Example 6
Source File: ChatObject.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private static boolean getBannedRight(TLRPC.TL_chatBannedRights rights, int action) {
    if (rights == null) {
        return false;
    }
    boolean value;
    switch (action) {
        case ACTION_PIN:
            return rights.pin_messages;
        case ACTION_CHANGE_INFO:
            return rights.change_info;
        case ACTION_INVITE:
            return rights.invite_users;
        case ACTION_SEND:
            return rights.send_messages;
        case ACTION_SEND_MEDIA:
            return rights.send_media;
        case ACTION_SEND_STICKERS:
            return rights.send_stickers;
        case ACTION_EMBED_LINKS:
            return rights.embed_links;
        case ACTION_SEND_POLLS:
            return rights.send_polls;
        case ACTION_VIEW:
            return rights.view_messages;
    }
    return false;
}
 
Example 7
Source File: AndroidUtilities.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public static boolean isBannedForever(TLRPC.TL_chatBannedRights rights) {
    return rights == null || Math.abs(rights.until_date - System.currentTimeMillis() / 1000) > 5 * 365 * 24 * 60 * 60;
}
 
Example 8
Source File: ChatUsersActivity.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
private String formatUserPermissions(TLRPC.TL_chatBannedRights rights) {
    if (rights == null) {
        return "";
    }
    StringBuilder builder = new StringBuilder();
    if (rights.view_messages && defaultBannedRights.view_messages != rights.view_messages) {
        builder.append(LocaleController.getString("UserRestrictionsNoRead", R.string.UserRestrictionsNoRead));
    }
    if (rights.send_messages && defaultBannedRights.send_messages != rights.send_messages) {
        if (builder.length() != 0) {
            builder.append(", ");
        }
        builder.append(LocaleController.getString("UserRestrictionsNoSend", R.string.UserRestrictionsNoSend));
    }
    if (rights.send_media && defaultBannedRights.send_media != rights.send_media) {
        if (builder.length() != 0) {
            builder.append(", ");
        }
        builder.append(LocaleController.getString("UserRestrictionsNoSendMedia", R.string.UserRestrictionsNoSendMedia));
    }
    if (rights.send_stickers && defaultBannedRights.send_stickers != rights.send_stickers) {
        if (builder.length() != 0) {
            builder.append(", ");
        }
        builder.append(LocaleController.getString("UserRestrictionsNoSendStickers", R.string.UserRestrictionsNoSendStickers));
    }
    if (rights.send_polls && defaultBannedRights.send_polls != rights.send_polls) {
        if (builder.length() != 0) {
            builder.append(", ");
        }
        builder.append(LocaleController.getString("UserRestrictionsNoSendPolls", R.string.UserRestrictionsNoSendPolls));
    }
    if (rights.embed_links && defaultBannedRights.embed_links != rights.embed_links) {
        if (builder.length() != 0) {
            builder.append(", ");
        }
        builder.append(LocaleController.getString("UserRestrictionsNoEmbedLinks", R.string.UserRestrictionsNoEmbedLinks));
    }
    if (rights.invite_users && defaultBannedRights.invite_users != rights.invite_users) {
        if (builder.length() != 0) {
            builder.append(", ");
        }
        builder.append(LocaleController.getString("UserRestrictionsNoInviteUsers", R.string.UserRestrictionsNoInviteUsers));
    }
    if (rights.pin_messages && defaultBannedRights.pin_messages != rights.pin_messages) {
        if (builder.length() != 0) {
            builder.append(", ");
        }
        builder.append(LocaleController.getString("UserRestrictionsNoPinMessages", R.string.UserRestrictionsNoPinMessages));
    }
    if (rights.change_info && defaultBannedRights.change_info != rights.change_info) {
        if (builder.length() != 0) {
            builder.append(", ");
        }
        builder.append(LocaleController.getString("UserRestrictionsNoChangeInfo", R.string.UserRestrictionsNoChangeInfo));
    }
    if (builder.length() != 0) {
        builder.replace(0, 1, builder.substring(0, 1).toUpperCase());
        builder.append('.');
    }
    return builder.toString();
}
 
Example 9
Source File: AndroidUtilities.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public static boolean isBannedForever(TLRPC.TL_chatBannedRights rights) {
    return rights == null || Math.abs(rights.until_date - System.currentTimeMillis() / 1000) > 5 * 365 * 24 * 60 * 60;
}
 
Example 10
Source File: ChatUsersActivity.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
private String formatUserPermissions(TLRPC.TL_chatBannedRights rights) {
    if (rights == null) {
        return "";
    }
    StringBuilder builder = new StringBuilder();
    if (rights.view_messages && defaultBannedRights.view_messages != rights.view_messages) {
        builder.append(LocaleController.getString("UserRestrictionsNoRead", R.string.UserRestrictionsNoRead));
    }
    if (rights.send_messages && defaultBannedRights.send_messages != rights.send_messages) {
        if (builder.length() != 0) {
            builder.append(", ");
        }
        builder.append(LocaleController.getString("UserRestrictionsNoSend", R.string.UserRestrictionsNoSend));
    }
    if (rights.send_media && defaultBannedRights.send_media != rights.send_media) {
        if (builder.length() != 0) {
            builder.append(", ");
        }
        builder.append(LocaleController.getString("UserRestrictionsNoSendMedia", R.string.UserRestrictionsNoSendMedia));
    }
    if (rights.send_stickers && defaultBannedRights.send_stickers != rights.send_stickers) {
        if (builder.length() != 0) {
            builder.append(", ");
        }
        builder.append(LocaleController.getString("UserRestrictionsNoSendStickers", R.string.UserRestrictionsNoSendStickers));
    }
    if (rights.send_polls && defaultBannedRights.send_polls != rights.send_polls) {
        if (builder.length() != 0) {
            builder.append(", ");
        }
        builder.append(LocaleController.getString("UserRestrictionsNoSendPolls", R.string.UserRestrictionsNoSendPolls));
    }
    if (rights.embed_links && defaultBannedRights.embed_links != rights.embed_links) {
        if (builder.length() != 0) {
            builder.append(", ");
        }
        builder.append(LocaleController.getString("UserRestrictionsNoEmbedLinks", R.string.UserRestrictionsNoEmbedLinks));
    }
    if (rights.invite_users && defaultBannedRights.invite_users != rights.invite_users) {
        if (builder.length() != 0) {
            builder.append(", ");
        }
        builder.append(LocaleController.getString("UserRestrictionsNoInviteUsers", R.string.UserRestrictionsNoInviteUsers));
    }
    if (rights.pin_messages && defaultBannedRights.pin_messages != rights.pin_messages) {
        if (builder.length() != 0) {
            builder.append(", ");
        }
        builder.append(LocaleController.getString("UserRestrictionsNoPinMessages", R.string.UserRestrictionsNoPinMessages));
    }
    if (rights.change_info && defaultBannedRights.change_info != rights.change_info) {
        if (builder.length() != 0) {
            builder.append(", ");
        }
        builder.append(LocaleController.getString("UserRestrictionsNoChangeInfo", R.string.UserRestrictionsNoChangeInfo));
    }
    if (builder.length() != 0) {
        builder.replace(0, 1, builder.substring(0, 1).toUpperCase());
        builder.append('.');
    }
    return builder.toString();
}
 
Example 11
Source File: ChatRightsEditActivity.java    From Telegram-FOSS with GNU General Public License v2.0 votes vote down vote up
void didSetRights(int rights, TLRPC.TL_chatAdminRights rightsAdmin, TLRPC.TL_chatBannedRights rightsBanned, String rank); 
Example 12
Source File: ChatRightsEditActivity.java    From Telegram with GNU General Public License v2.0 votes vote down vote up
void didSetRights(int rights, TLRPC.TL_chatAdminRights rightsAdmin, TLRPC.TL_chatBannedRights rightsBanned, String rank);