/** {@inheritDoc} */ @Override public int send(final List<Argument> arguments) { final Twitter svc = buildUblogService(arguments); String destUser = findDestName(arguments); Status response; if (destUser == null || "".equals(destUser)) { LOG.error("Cannot send a microblog reply notice to a user with no microblog username set. Either set a microblog username for this OpenNMS user or use the MicroblogUpdateNotificationStrategy instead."); return 1; } // In case the user tried to be helpful, avoid a double @@ if (destUser.startsWith("@")) destUser = destUser.substring(1); final String fullMessage = String.format("@%s %s", destUser, buildMessageBody(arguments)); LOG.debug("Dispatching microblog reply notification at base URL '{}' with message '{}'", svc.getConfiguration().getClientURL(), fullMessage); try { response = svc.updateStatus(fullMessage); } catch (final TwitterException e) { LOG.error("Microblog notification failed at service URL '{}'", svc.getConfiguration().getClientURL(), e); return 1; } LOG.info("Microblog reply notification succeeded: reply update posted with ID {}", response.getId()); return 0; }
/** {@inheritDoc} */ @Override public int send(List<Argument> arguments) { Twitter svc = buildUblogService(arguments); String destUser = findDestName(arguments); DirectMessage response; if (destUser == null || "".equals(destUser)) { LOG.error("Cannot send a microblog DM notice to a user with no microblog username set. Either set a microblog username for this OpenNMS user or use the MicroblogUpdateNotificationStrategy instead."); return 1; } // In case the user tried to be helpful, avoid a double @@ if (destUser.startsWith("@")) destUser = destUser.substring(1); String fullMessage = buildMessageBody(arguments); LOG.debug("Dispatching microblog DM notification at base URL '{}' with destination user '{}' and message '{}'", svc.getConfiguration().getClientURL(), destUser, fullMessage); try { response = svc.sendDirectMessage(destUser, fullMessage); } catch (TwitterException e) { LOG.error("Microblog notification failed at service URL '{}' to destination user '{}'", svc.getConfiguration().getClientURL(), destUser, e); return 1; } LOG.info("Microblog DM notification succeeded: DM sent with ID {}", response.getId()); return 0; } }
/** {@inheritDoc} */ @Override public int send(List<Argument> arguments) { Twitter svc = buildUblogService(arguments); String messageBody = buildMessageBody(arguments); Status response; final String baseURL = svc.getConfiguration().getClientURL(); LOG.debug("Dispatching microblog notification at base URL '{}' with message '{}'", baseURL, messageBody); try { response = svc.updateStatus(messageBody); } catch (TwitterException e) { LOG.error("Microblog notification failed at service URL '{}'", baseURL, e); return 1; } LOG.info("Microblog notification succeeded: update posted with ID {}", response.getId()); return 0; }