622 lines
25 KiB
Java
622 lines
25 KiB
Java
package Utility;
|
|
|
|
import Manager.ChatManager;
|
|
import Manager.UserManager;
|
|
|
|
import Utility.User.MyUser;
|
|
import Utility.User.Roles;
|
|
import Utility.User.UserPermission;
|
|
import Utility.chat.Chat;
|
|
import Utility.chat.ChatCategory;
|
|
import org.json.simple.JSONObject;
|
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.telegram.telegrambots.meta.api.objects.replykeyboard.InlineKeyboardMarkup;
|
|
import org.telegram.telegrambots.meta.api.objects.replykeyboard.buttons.InlineKeyboardButton;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import static CORE.Core.*;
|
|
|
|
public class KeyBoards {
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(KeyBoards.class);
|
|
|
|
/////////////////////////////////////////////////////
|
|
// CORE MENUE
|
|
////////////////////////////////////////////////////
|
|
|
|
public static InlineKeyboardMarkup buildGuestMenu() {
|
|
log.debug("Building guest menu");
|
|
|
|
InlineKeyboardMarkup keyboard = new InlineKeyboardMarkup();
|
|
List<List<InlineKeyboardButton>> buttons = new ArrayList<>();
|
|
|
|
//List<InlineKeyboardButton> row2 = new ArrayList<>();
|
|
//row2.add(new InlineKeyboardButton().setText("Gästechat / Guest chat").setUrl(GUEST_CHAT_JOIN_LINK));
|
|
//buttons.add(row2);
|
|
|
|
for (Object chat : OPEN_CHATS) {
|
|
JSONObject chatJSON = (JSONObject) chat;
|
|
List<InlineKeyboardButton> row = new ArrayList<>();
|
|
row.add(new InlineKeyboardButton().setText((String) chatJSON.get("name"))
|
|
.setUrl((String) chatJSON.get("url")));
|
|
buttons.add(row);
|
|
}
|
|
|
|
List<InlineKeyboardButton> row3 = new ArrayList<>();
|
|
row3.add(new InlineKeyboardButton().setText("Menü schließen / Close menu").setCallbackData("close"));
|
|
buttons.add(row3);
|
|
|
|
keyboard.setKeyboard(buttons);
|
|
|
|
return keyboard;
|
|
}
|
|
|
|
public static InlineKeyboardMarkup buildMainMenu(long user_id) {
|
|
log.debug("Building main menu");
|
|
|
|
InlineKeyboardMarkup main_menu = new InlineKeyboardMarkup();
|
|
List<List<InlineKeyboardButton>> buttons = new ArrayList<>();
|
|
|
|
for (Object chat : OPEN_CHATS) {
|
|
JSONObject chatJSON = (JSONObject) chat;
|
|
List<InlineKeyboardButton> row = new ArrayList<>();
|
|
row.add(new InlineKeyboardButton().setText((String) chatJSON.get("name"))
|
|
.setUrl((String) chatJSON.get("url")));
|
|
buttons.add(row);
|
|
}
|
|
|
|
List<InlineKeyboardButton> row1 = new ArrayList<>();
|
|
row1.add(new InlineKeyboardButton().setText("Chats").setCallbackData("chats menu"));
|
|
|
|
buttons.add(row1);
|
|
|
|
if (UserManager.checkAdmin(user_id)) {
|
|
List<InlineKeyboardButton> adminbutton = new ArrayList<>();
|
|
adminbutton.add(new InlineKeyboardButton().setText("AdminTools").setCallbackData("admintools menu"));
|
|
buttons.add(adminbutton);
|
|
}
|
|
|
|
List<InlineKeyboardButton> close = new ArrayList<>();
|
|
close.add(new InlineKeyboardButton().setText("Menü schließen").setCallbackData("close"));
|
|
|
|
buttons.add(close);
|
|
|
|
main_menu.setKeyboard(buttons);
|
|
|
|
return main_menu;
|
|
}
|
|
|
|
public static InlineKeyboardMarkup buildOpenMenu() {
|
|
log.info("Building open menu");
|
|
|
|
InlineKeyboardMarkup open_menu = new InlineKeyboardMarkup();
|
|
List<List<InlineKeyboardButton>> buttons = new ArrayList<>();
|
|
|
|
for (Object chat : OPEN_CHATS) {
|
|
JSONObject chatJSON = (JSONObject) chat;
|
|
List<InlineKeyboardButton> row = new ArrayList<>();
|
|
row.add(new InlineKeyboardButton().setText((String) chatJSON.get("name"))
|
|
.setUrl((String) chatJSON.get("url")));
|
|
buttons.add(row);
|
|
}
|
|
|
|
if (!NO_BOT_RIGHTS) {
|
|
List<InlineKeyboardButton> row2 = new ArrayList<>();
|
|
row2.add(new InlineKeyboardButton().setText("Rechte anfragen").setCallbackData("permission request"));
|
|
buttons.add(row2);
|
|
}
|
|
|
|
List<InlineKeyboardButton> row3 = new ArrayList<>();
|
|
row3.add(new InlineKeyboardButton().setText("Gastrechte anfragen")
|
|
.setCallbackData("permission requestguest"));
|
|
buttons.add(row3);
|
|
|
|
open_menu.setKeyboard(buttons);
|
|
|
|
return open_menu;
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////
|
|
// ADMIN MENUE
|
|
/////////////////////////////////////////////////////////
|
|
|
|
public static InlineKeyboardMarkup buildAdminMenu() {
|
|
|
|
InlineKeyboardMarkup keyboard = new InlineKeyboardMarkup();
|
|
List<List<InlineKeyboardButton>> buttons = new ArrayList<>();
|
|
|
|
List<InlineKeyboardButton> row = new ArrayList<>();
|
|
List<InlineKeyboardButton> row2 = new ArrayList<>();
|
|
List<InlineKeyboardButton> row3 = new ArrayList<>();
|
|
|
|
row.add(new InlineKeyboardButton().setText("Offene Requests").setCallbackData("admintools loadrequests"));
|
|
row2.add(new InlineKeyboardButton().setText("Whitelist").setCallbackData("admintools whitelist"));
|
|
row2.add(new InlineKeyboardButton().setText("Blocklist").setCallbackData("admintools blocklist"));
|
|
row3.add(new InlineKeyboardButton().setText("Zurück").setCallbackData("mainmenu"));
|
|
|
|
buttons.add(row);
|
|
buttons.add(row2);
|
|
buttons.add(row3);
|
|
|
|
keyboard.setKeyboard(buttons);
|
|
return keyboard;
|
|
}
|
|
|
|
public static InlineKeyboardMarkup buildOpenRequests(Map<Long, MyUser> open_requests) {
|
|
|
|
InlineKeyboardMarkup requests = new InlineKeyboardMarkup();
|
|
List<List<InlineKeyboardButton>> buttons = new ArrayList<>();
|
|
|
|
for (int i = 0; i < open_requests.size(); i++) {
|
|
buttons.add(new ArrayList<>());
|
|
}
|
|
|
|
int i = 0;
|
|
for (long user_id : open_requests.keySet()) {
|
|
MyUser user = open_requests.get(user_id);
|
|
String user_name = user.getUserName();
|
|
String buttontext;
|
|
if (user.getRole() == Roles.GUEST) {
|
|
buttontext = "Gastanfrage: " + user_name.replaceAll("(?is:<[^>]+>)", "");
|
|
} else {
|
|
buttontext = user_name.replaceAll("(?is:<[^>]+>)", "");
|
|
}
|
|
InlineKeyboardButton user_button = new InlineKeyboardButton().setText(buttontext).setCallbackData(
|
|
"admintools loadopenuser " + user_id);
|
|
buttons.get(i).add(user_button);
|
|
i++;
|
|
}
|
|
|
|
List<InlineKeyboardButton> lastbutton = new ArrayList<>();
|
|
lastbutton.add(new InlineKeyboardButton().setText("Zurück.").setCallbackData("admintools menu"));
|
|
buttons.add(lastbutton);
|
|
|
|
requests.setKeyboard(buttons);
|
|
|
|
return requests;
|
|
}
|
|
|
|
public static InlineKeyboardMarkup buildRequestAnswers(long user_id) {
|
|
|
|
InlineKeyboardMarkup keyboard = new InlineKeyboardMarkup();
|
|
List<List<InlineKeyboardButton>> buttons = new ArrayList<>();
|
|
|
|
List<InlineKeyboardButton> row = new ArrayList<>();
|
|
List<InlineKeyboardButton> row2 = new ArrayList<>();
|
|
|
|
row.add(new InlineKeyboardButton().setText("Ja")
|
|
.setCallbackData("admintools grant " + user_id));
|
|
row.add(new InlineKeyboardButton().setText("Nein")
|
|
.setCallbackData("admintools deny " + user_id));
|
|
row.add(new InlineKeyboardButton().setText("Block")
|
|
.setCallbackData("admintools denyandblock " + user_id));
|
|
row2.add(new InlineKeyboardButton().setText("Zurück").setCallbackData("admintools loadrequests"));
|
|
|
|
buttons.add(row);
|
|
buttons.add(row2);
|
|
|
|
keyboard.setKeyboard(buttons);
|
|
return keyboard;
|
|
}
|
|
|
|
public static InlineKeyboardMarkup buildWhitelistMenu() {
|
|
|
|
InlineKeyboardMarkup keyboard = new InlineKeyboardMarkup();
|
|
List<List<InlineKeyboardButton>> buttons = new ArrayList<>();
|
|
|
|
List<InlineKeyboardButton> row = new ArrayList<>();
|
|
List<InlineKeyboardButton> row2 = new ArrayList<>();
|
|
|
|
row.add(new InlineKeyboardButton().setText("Spezifischen Nutzer laden").setCallbackData("admintools loaduser"));
|
|
row2.add(new InlineKeyboardButton().setText("Zurück").setCallbackData("admintools menu"));
|
|
|
|
buttons.add(row);
|
|
buttons.add(row2);
|
|
|
|
keyboard.setKeyboard(buttons);
|
|
return keyboard;
|
|
}
|
|
|
|
public static InlineKeyboardMarkup buildBlocklistMenu() {
|
|
|
|
InlineKeyboardMarkup keyboard = new InlineKeyboardMarkup();
|
|
List<List<InlineKeyboardButton>> buttons = new ArrayList<>();
|
|
|
|
List<InlineKeyboardButton> row = new ArrayList<>();
|
|
List<InlineKeyboardButton> row2 = new ArrayList<>();
|
|
|
|
row.add(new InlineKeyboardButton().setText("Unblock").setCallbackData("admintools unblock"));
|
|
row2.add(new InlineKeyboardButton().setText("Zurück").setCallbackData("admintools menu"));
|
|
|
|
buttons.add(row);
|
|
buttons.add(row2);
|
|
|
|
keyboard.setKeyboard(buttons);
|
|
return keyboard;
|
|
}
|
|
|
|
public static InlineKeyboardMarkup buildAdminFound(MyUser user) {
|
|
InlineKeyboardMarkup keyboard = new InlineKeyboardMarkup();
|
|
|
|
List<List<InlineKeyboardButton>> buttons = new ArrayList<>();
|
|
|
|
List<InlineKeyboardButton> row = new ArrayList<>();
|
|
List<InlineKeyboardButton> row2 = new ArrayList<>();
|
|
List<InlineKeyboardButton> row3 = new ArrayList<>();
|
|
List<InlineKeyboardButton> row4 = new ArrayList<>();
|
|
|
|
row.add(new InlineKeyboardButton().setText("Degradieren")
|
|
.setCallbackData("admintools changeadmin " + user.getId()));
|
|
row2.add(new InlineKeyboardButton().setText("Zu Gast ändern")
|
|
.setCallbackData("admintools changeguest " + user.getId()));
|
|
row3.add(new InlineKeyboardButton().setText("Blockieren")
|
|
.setCallbackData("admintools block " + user.getId()));
|
|
row4.add(new InlineKeyboardButton().setText("Zurück").setCallbackData("admintools whitelist"));
|
|
|
|
buttons.add(row);
|
|
buttons.add(row2);
|
|
buttons.add(row3);
|
|
buttons.add(row4);
|
|
|
|
keyboard.setKeyboard(buttons);
|
|
return keyboard;
|
|
}
|
|
|
|
public static InlineKeyboardMarkup buildGuestFound(MyUser user) {
|
|
InlineKeyboardMarkup keyboard = new InlineKeyboardMarkup();
|
|
|
|
List<List<InlineKeyboardButton>> buttons = new ArrayList<>();
|
|
|
|
List<InlineKeyboardButton> row = new ArrayList<>();
|
|
List<InlineKeyboardButton> row2 = new ArrayList<>();
|
|
List<InlineKeyboardButton> row3 = new ArrayList<>();
|
|
List<InlineKeyboardButton> row4 = new ArrayList<>();
|
|
|
|
row.add(new InlineKeyboardButton().setText("Zum Admin berufen")
|
|
.setCallbackData("admintools changeadmin " + user.getId()));
|
|
row2.add(new InlineKeyboardButton().setText("Zu normalem Nutzer machen")
|
|
.setCallbackData("admintools changeguest " + user.getId()));
|
|
row3.add(new InlineKeyboardButton().setText("Blockieren")
|
|
.setCallbackData("admintools block " + user.getId()));
|
|
row4.add(new InlineKeyboardButton().setText("Zurück").setCallbackData("admintools whitelist"));
|
|
|
|
buttons.add(row);
|
|
buttons.add(row2);
|
|
buttons.add(row3);
|
|
buttons.add(row4);
|
|
|
|
keyboard.setKeyboard(buttons);
|
|
return keyboard;
|
|
}
|
|
|
|
public static InlineKeyboardMarkup buildUserFound(MyUser user) {
|
|
InlineKeyboardMarkup keyboard = new InlineKeyboardMarkup();
|
|
|
|
List<List<InlineKeyboardButton>> buttons = new ArrayList<>();
|
|
|
|
List<InlineKeyboardButton> row = new ArrayList<>();
|
|
List<InlineKeyboardButton> row2 = new ArrayList<>();
|
|
List<InlineKeyboardButton> row3 = new ArrayList<>();
|
|
List<InlineKeyboardButton> row4 = new ArrayList<>();
|
|
List<InlineKeyboardButton> row5 = new ArrayList<>();
|
|
|
|
row.add(new InlineKeyboardButton().setText("Zum Admin berufen")
|
|
.setCallbackData("admintools changeadmin " + user.getId()));
|
|
row2.add(new InlineKeyboardButton().setText("Zu Gast ändern")
|
|
.setCallbackData("admintools changeguest " + user.getId()));
|
|
row2.add(new InlineKeyboardButton().setText("Mod ändern")
|
|
.setCallbackData("admintools changemod " + user.getId()));
|
|
row3.add(new InlineKeyboardButton().setText("Operator ändern")
|
|
.setCallbackData("admintools changeoperator " + user.getId()));
|
|
row3.add(new InlineKeyboardButton().setText("Hightrust ändern")
|
|
.setCallbackData("admintools changehightrust " + user.getId()));
|
|
row4.add(new InlineKeyboardButton().setText("Blockieren")
|
|
.setCallbackData("admintools block " + user.getId()));
|
|
row5.add(new InlineKeyboardButton().setText("Zurück").setCallbackData("admintools whitelist"));
|
|
|
|
buttons.add(row);
|
|
buttons.add(row2);
|
|
buttons.add(row3);
|
|
buttons.add(row4);
|
|
buttons.add(row5);
|
|
|
|
keyboard.setKeyboard(buttons);
|
|
return keyboard;
|
|
}
|
|
|
|
public static InlineKeyboardMarkup buildBlockOptions(MyUser user) {
|
|
InlineKeyboardMarkup keyboard = new InlineKeyboardMarkup();
|
|
List<List<InlineKeyboardButton>> buttons = new ArrayList<>();
|
|
|
|
List<InlineKeyboardButton> row = new ArrayList<>();
|
|
|
|
row.add(new InlineKeyboardButton().setText("BLOCK").setCallbackData("admintools blockapproval " + user.getId()));
|
|
row.add(new InlineKeyboardButton().setText("Zurück").setCallbackData("admintools whitelist"));
|
|
|
|
buttons.add(row);
|
|
|
|
keyboard.setKeyboard(buttons);
|
|
return keyboard;
|
|
}
|
|
|
|
public static InlineKeyboardMarkup buildBackButtonAdmintools() {
|
|
|
|
InlineKeyboardMarkup keyboard = new InlineKeyboardMarkup();
|
|
List<List<InlineKeyboardButton>> buttons = new ArrayList<>();
|
|
|
|
List<InlineKeyboardButton> row = new ArrayList<>();
|
|
|
|
row.add(new InlineKeyboardButton().setText("Zurück").setCallbackData("admintools menu"));
|
|
|
|
buttons.add(row);
|
|
|
|
keyboard.setKeyboard(buttons);
|
|
return keyboard;
|
|
}
|
|
|
|
public static InlineKeyboardMarkup buildBackButtonWhitelist() {
|
|
|
|
InlineKeyboardMarkup keyboard = new InlineKeyboardMarkup();
|
|
List<List<InlineKeyboardButton>> buttons = new ArrayList<>();
|
|
|
|
List<InlineKeyboardButton> row = new ArrayList<>();
|
|
|
|
row.add(new InlineKeyboardButton().setText("Zurück").setCallbackData("admintools whitelist"));
|
|
|
|
buttons.add(row);
|
|
|
|
keyboard.setKeyboard(buttons);
|
|
return keyboard;
|
|
}
|
|
|
|
/////////////////////////////////////////
|
|
// CHATS MENUE
|
|
/////////////////////////////////////////
|
|
|
|
public static InlineKeyboardMarkup buildCategoriesMenu(long user_id) {
|
|
log.debug("Building categories menu for user " + user_id);
|
|
List<ChatCategory> categories = ChatManager.loadCategories();
|
|
|
|
InlineKeyboardMarkup keyboardMarkup = new InlineKeyboardMarkup();
|
|
|
|
List<List<InlineKeyboardButton>> buttons = new ArrayList<>();
|
|
|
|
for (int i = 0; i < categories.size(); i++) {
|
|
buttons.add(new ArrayList<>());
|
|
}
|
|
|
|
MyUser user = UserManager.loadUser(user_id);
|
|
|
|
for (int i = 0; i < categories.size(); i++) {
|
|
|
|
//check for at least one valid chat in category
|
|
boolean hasPermission = false;
|
|
for (Chat x : categories.get(i).getChatList()) {
|
|
if (user != null && (user.getRole() == Roles.ADMIN || ( x.getPermissionNeeded() != null && x.getPermissionNeeded() == UserPermission.NORMAL ) || ( x.getPermissionNeeded() != null && user.getPermission().contains(x.getPermissionNeeded())))) {
|
|
hasPermission = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
//only add chat if it contains at leas one valid chat
|
|
if (hasPermission)
|
|
buttons.get(i).add(new InlineKeyboardButton().setText(categories.get(i).getName())
|
|
.setCallbackData("chats loadcategory " + categories.get(i).getUid()));
|
|
|
|
}
|
|
|
|
if (UserManager.checkAdmin(user_id)) {
|
|
List<InlineKeyboardButton> adminButtons = new ArrayList<>();
|
|
|
|
adminButtons.add(
|
|
new InlineKeyboardButton().setText("Kategorie hinzufügen").setCallbackData("chats addcategory"));
|
|
|
|
buttons.add(adminButtons);
|
|
}
|
|
|
|
List<InlineKeyboardButton> backButton = new ArrayList<>();
|
|
backButton.add(new InlineKeyboardButton().setText("Zurück").setCallbackData("mainmenu"));
|
|
buttons.add(backButton);
|
|
|
|
keyboardMarkup.setKeyboard(buttons);
|
|
|
|
return keyboardMarkup;
|
|
}
|
|
|
|
|
|
public static InlineKeyboardMarkup buildCategory(ChatCategory category, long userId) {
|
|
log.debug("Building category " + category.getName() + " for user " + userId);
|
|
|
|
InlineKeyboardMarkup keyboardMarkup = new InlineKeyboardMarkup();
|
|
|
|
List<List<InlineKeyboardButton>> buttons = new ArrayList<>();
|
|
|
|
for (int i = 0; i < (category.getChatList().size() + 1) / 2; i++) {
|
|
buttons.add(new ArrayList<>());
|
|
}
|
|
|
|
MyUser abstractUser = UserManager.loadUser(userId);
|
|
|
|
for (int i = 0; i < category.getChatList().size(); i++) {
|
|
|
|
Chat chat = category.getChatList().get(i);
|
|
InlineKeyboardButton button = new InlineKeyboardButton();
|
|
|
|
if (abstractUser != null && abstractUser.getRole() == Roles.ADMIN) {
|
|
if (chat.getUrl() == null) {
|
|
button.setText(chat.getName()).setCallbackData("chats notfound");
|
|
} else {
|
|
button.setText(chat.getFullName()).setUrl(chat.getUrl());
|
|
}
|
|
} else {
|
|
//show if permission match
|
|
if (abstractUser != null && chat.getPermissionNeeded() != null && abstractUser.getPermission().contains(chat.getPermissionNeeded())) {
|
|
if (chat.getUrl() == null) {
|
|
button.setText(chat.getFullName()).setCallbackData("chats notfound");
|
|
} else {
|
|
button.setText(chat.getFullName()).setUrl(chat.getUrl());
|
|
}
|
|
//Show if no permission is given
|
|
} else if (chat.getPermissionNeeded() == null) {
|
|
if (chat.getUrl() == null) {
|
|
button.setText(chat.getFullName()).setCallbackData("chats notfound");
|
|
} else {
|
|
button.setText(chat.getFullName()).setUrl(chat.getUrl());
|
|
}
|
|
//else wrong permission set
|
|
} else {
|
|
button.setText(chat.getFullName()).setCallbackData("chats permissionmissing");
|
|
}
|
|
}
|
|
|
|
buttons.get(i / 2).add(button);
|
|
}
|
|
|
|
|
|
if (UserManager.checkAdmin(userId)) {
|
|
List<InlineKeyboardButton> adminButton = new ArrayList<>();
|
|
adminButton.add(new InlineKeyboardButton().setText("Kategorie bearbeiten")
|
|
.setCallbackData("chats editcategory " + category.getUid()));
|
|
buttons.add(adminButton);
|
|
}
|
|
|
|
List<InlineKeyboardButton> backButton = new ArrayList<>();
|
|
backButton.add(new InlineKeyboardButton().setText("Zurück").setCallbackData("chats menu"));
|
|
buttons.add(backButton);
|
|
|
|
keyboardMarkup.setKeyboard(buttons);
|
|
return keyboardMarkup;
|
|
}
|
|
|
|
public static InlineKeyboardMarkup buildEditCategory(ChatCategory category) {
|
|
log.debug("Building edit category for " + category.getName());
|
|
InlineKeyboardMarkup keyboardMarkup = new InlineKeyboardMarkup();
|
|
|
|
List<List<InlineKeyboardButton>> buttons = new ArrayList<>();
|
|
|
|
List<InlineKeyboardButton> row = new ArrayList<>();
|
|
List<InlineKeyboardButton> row2 = new ArrayList<>();
|
|
List<InlineKeyboardButton> row3 = new ArrayList<>();
|
|
|
|
row.add(new InlineKeyboardButton().setText("Chat hinzufügen").setCallbackData("chats addchat " + category.getUid()));
|
|
row.add(new InlineKeyboardButton().setText("Chat bearbeiten").setCallbackData("chats editchat " + category.getUid()));
|
|
row2.add(new InlineKeyboardButton().setText("Kategorie löschen").setCallbackData("chats deletecategory " + category.getUid()));
|
|
row3.add(new InlineKeyboardButton().setText("Zurück").setCallbackData("chats loadcategory " + category.getUid()));
|
|
|
|
buttons.add(row);
|
|
buttons.add(row2);
|
|
buttons.add(row3);
|
|
|
|
keyboardMarkup.setKeyboard(buttons);
|
|
|
|
return keyboardMarkup;
|
|
}
|
|
|
|
public static InlineKeyboardMarkup buildPossiblePermissions() {
|
|
InlineKeyboardMarkup keyboardMarkup = new InlineKeyboardMarkup();
|
|
|
|
List<List<InlineKeyboardButton>> buttons = new ArrayList<>();
|
|
|
|
List<InlineKeyboardButton> row = new ArrayList<>();
|
|
List<InlineKeyboardButton> row2 = new ArrayList<>();
|
|
|
|
row.add(new InlineKeyboardButton().setText("Keine spezielle Berechtigung").setCallbackData("chats addpermission NORMAL"));
|
|
row.add(new InlineKeyboardButton().setText("Hightrust").setCallbackData("chats addpermission HIGHTRUST"));
|
|
row2.add(new InlineKeyboardButton().setText("Mod").setCallbackData("chats addpermission MOD"));
|
|
row2.add(new InlineKeyboardButton().setText("Operator").setCallbackData("chats addpermission OPERATOR"));
|
|
|
|
buttons.add(row);
|
|
buttons.add(row2);
|
|
|
|
keyboardMarkup.setKeyboard(buttons);
|
|
|
|
return keyboardMarkup;
|
|
}
|
|
|
|
public static InlineKeyboardMarkup buildBackToCategory(ChatCategory category) {
|
|
InlineKeyboardMarkup keyboardMarkup = new InlineKeyboardMarkup();
|
|
|
|
List<List<InlineKeyboardButton>> buttons = new ArrayList<>();
|
|
|
|
List<InlineKeyboardButton> row = new ArrayList<>();
|
|
|
|
row.add(new InlineKeyboardButton().setText("Zurück").setCallbackData("chats loadcategory " + category.getUid()));
|
|
|
|
buttons.add(row);
|
|
|
|
keyboardMarkup.setKeyboard(buttons);
|
|
|
|
return keyboardMarkup;
|
|
}
|
|
|
|
public static InlineKeyboardMarkup buildChangePermissions() {
|
|
InlineKeyboardMarkup keyboardMarkup = new InlineKeyboardMarkup();
|
|
|
|
List<List<InlineKeyboardButton>> buttons = new ArrayList<>();
|
|
|
|
List<InlineKeyboardButton> row = new ArrayList<>();
|
|
List<InlineKeyboardButton> row2 = new ArrayList<>();
|
|
|
|
row.add(new InlineKeyboardButton().setText("Keine spezielle Berechtigung").setCallbackData("chats changepermissionconfirm NORMAL"));
|
|
row.add(new InlineKeyboardButton().setText("Hightrust").setCallbackData("chats changepermissionconfirm HIGHTRUST"));
|
|
row2.add(new InlineKeyboardButton().setText("Mod").setCallbackData("chats changepermissionconfirm MOD"));
|
|
row2.add(new InlineKeyboardButton().setText("Operator").setCallbackData("chats changepermissionconfirm OPERATOR"));
|
|
|
|
buttons.add(row);
|
|
buttons.add(row2);
|
|
|
|
keyboardMarkup.setKeyboard(buttons);
|
|
|
|
return keyboardMarkup;
|
|
}
|
|
|
|
public static InlineKeyboardMarkup buildEditChat(Chat chat, long categoryUid) {
|
|
InlineKeyboardMarkup keyboardMarkup = new InlineKeyboardMarkup();
|
|
|
|
List<List<InlineKeyboardButton>> buttons = new ArrayList<>();
|
|
|
|
List<InlineKeyboardButton> row = new ArrayList<>();
|
|
List<InlineKeyboardButton> row2 = new ArrayList<>();
|
|
List<InlineKeyboardButton> row3 = new ArrayList<>();
|
|
|
|
row.add(new InlineKeyboardButton().setText("UID ändern").setCallbackData("chats changeuid " + chat.getUid() + " " + categoryUid));
|
|
row.add(new InlineKeyboardButton().setText("Name ändern").setCallbackData("chats changename " + chat.getUid() + " " + categoryUid));
|
|
row2.add(new InlineKeyboardButton().setText("Permission ändern").setCallbackData("chats changepermission " + chat.getUid() + " " + categoryUid));
|
|
row2.add(new InlineKeyboardButton().setText("Url ändern").setCallbackData("chats changeurl " + chat.getUid() + " " + categoryUid));
|
|
row3.add(new InlineKeyboardButton().setText("Löschen").setCallbackData("chats deletechat " + chat.getUid() + " " + categoryUid));
|
|
row3.add(new InlineKeyboardButton().setText("Zurück").setCallbackData("chats editcategory " + categoryUid + " " + categoryUid));
|
|
|
|
buttons.add(row);
|
|
buttons.add(row2);
|
|
buttons.add(row3);
|
|
|
|
keyboardMarkup.setKeyboard(buttons);
|
|
|
|
return keyboardMarkup;
|
|
}
|
|
|
|
public static InlineKeyboardMarkup buildConfirmCategoryDelete(ChatCategory category) {
|
|
InlineKeyboardMarkup keyboardMarkup = new InlineKeyboardMarkup();
|
|
|
|
List<List<InlineKeyboardButton>> buttons = new ArrayList<>();
|
|
|
|
List<InlineKeyboardButton> row = new ArrayList<>();
|
|
|
|
row.add(new InlineKeyboardButton().setText("LÖSCHEN").setCallbackData("chats deletecategoryconfirm " + category.getUid()));
|
|
row.add(new InlineKeyboardButton().setText("Zurück").setCallbackData("chats editcategory " + category.getUid()));
|
|
|
|
buttons.add(row);
|
|
|
|
keyboardMarkup.setKeyboard(buttons);
|
|
|
|
return keyboardMarkup;
|
|
}
|
|
|
|
}
|