@Override public String toString() { return "EditedMessage{" + "messageId=" + messageId + ", from=" + from.toString() + ", chat=" + chat.toString() + ", date=" + date + ", editDate=" + editDate + ", text='" + text + '\'' + ", entities=" + entities.toString() + ", additionalProperties=" + additionalProperties + '}'; } }
public String registerNotification(MessageUpdate message) { String channel = null; if (message.getMessage().getChat().getType().equals("group") || message.getMessage().getChat().getType().equals("supergroup")) { channel = message.getMessage().getChat().getTitle(); } else { channel = message.getMessage().getFrom().getFirstName(); } return repository.register(new PacktNotification(message.getMessage().getChat().getId(), channel)); }
/** * When a member join, left or gets excluded from an Telegram group a msg will be sent to the target group. * If the member added or removed is a bot, no message is sent. * @param update {@link MessageUpdate} * @return true if the message is to inform a new member or if a member left the chat */ private String chatMember(MessageUpdate update) { ObjectMapper mapper = new ObjectMapper(); final Message message = new Message(); for (Map.Entry<String, Object> entry : update.getMessage().getAdditionalProperties().entrySet()) { log.fine("Additional Properties: KEY + " + entry.getKey() + " - VALUE " + entry.getValue().toString()); if (entry.getKey().equals("new_chat_member") && !update.getMessage().getFrom().isIsBot()) { NewChatMember member = mapper.convertValue(entry.getValue(), NewChatMember.class); message.setText(String.format(WELCOME_MESSAGE, member.getFirst_name(), update.getMessage().getChat().getTitle())); } else if (entry.getKey().equals("left_chat_participant") && !update.getMessage().getFrom().isIsBot()) { LeftChatMember member = mapper.convertValue(entry.getValue(), LeftChatMember.class); message.setText(String.format(GOODBYE_MESSAGE, member.getFirst_name())); } } return message.getText(); } }
public String unregisterNotification(MessageUpdate message) { String channel = null; if (message.getMessage().getChat().getType().equals("group") || message.getMessage().getChat().getType().equals("supergroup")) { channel = message.getMessage().getChat().getTitle(); } else { channel = message.getMessage().getFrom().getFirstName(); } return repository.unregister(new PacktNotification(message.getMessage().getChat().getId(), channel)); }