diff --git a/.classpath b/.classpath index c094381..22dfeb2 100644 --- a/.classpath +++ b/.classpath @@ -16,22 +16,6 @@ - - - - - - - - - - - - - - - - @@ -48,8 +32,9 @@ - - - + + + + diff --git a/lib/Spring/aopalliance-1.0.jar b/lib/Spring/aopalliance-1.0.jar deleted file mode 100644 index 578b1a0..0000000 Binary files a/lib/Spring/aopalliance-1.0.jar and /dev/null differ diff --git a/lib/Spring/spring-aop-4.1.7.jar b/lib/Spring/spring-aop-4.1.7.jar deleted file mode 100644 index 7dce4d6..0000000 Binary files a/lib/Spring/spring-aop-4.1.7.jar and /dev/null differ diff --git a/lib/Spring/spring-beans-4.1.7.jar b/lib/Spring/spring-beans-4.1.7.jar deleted file mode 100644 index 6bf32ee..0000000 Binary files a/lib/Spring/spring-beans-4.1.7.jar and /dev/null differ diff --git a/lib/Spring/spring-context-4.1.7.jar b/lib/Spring/spring-context-4.1.7.jar deleted file mode 100644 index 2d78145..0000000 Binary files a/lib/Spring/spring-context-4.1.7.jar and /dev/null differ diff --git a/lib/Spring/spring-context-support-4.1.7.jar b/lib/Spring/spring-context-support-4.1.7.jar deleted file mode 100644 index 3b3f544..0000000 Binary files a/lib/Spring/spring-context-support-4.1.7.jar and /dev/null differ diff --git a/lib/Spring/spring-core-4.1.7.jar b/lib/Spring/spring-core-4.1.7.jar deleted file mode 100644 index 6441ef2..0000000 Binary files a/lib/Spring/spring-core-4.1.7.jar and /dev/null differ diff --git a/lib/Spring/spring-expression-4.1.7.jar b/lib/Spring/spring-expression-4.1.7.jar deleted file mode 100644 index e929e9e..0000000 Binary files a/lib/Spring/spring-expression-4.1.7.jar and /dev/null differ diff --git a/lib/Spring/spring-security-crypto-3.2.3.jar b/lib/Spring/spring-security-crypto-3.2.3.jar deleted file mode 100644 index df3d27a..0000000 Binary files a/lib/Spring/spring-security-crypto-3.2.3.jar and /dev/null differ diff --git a/lib/Spring/spring-social-config-1.1.0.jar b/lib/Spring/spring-social-config-1.1.0.jar deleted file mode 100644 index 831c6df..0000000 Binary files a/lib/Spring/spring-social-config-1.1.0.jar and /dev/null differ diff --git a/lib/Spring/spring-social-core-1.1.0.jar b/lib/Spring/spring-social-core-1.1.0.jar deleted file mode 100644 index e1698e5..0000000 Binary files a/lib/Spring/spring-social-core-1.1.0.jar and /dev/null differ diff --git a/lib/Spring/spring-social-twitter-1.1.0.jar b/lib/Spring/spring-social-twitter-1.1.0.jar deleted file mode 100644 index d9f4765..0000000 Binary files a/lib/Spring/spring-social-twitter-1.1.0.jar and /dev/null differ diff --git a/lib/Spring/spring-social-web-1.1.0.jar b/lib/Spring/spring-social-web-1.1.0.jar deleted file mode 100644 index 4e22a9c..0000000 Binary files a/lib/Spring/spring-social-web-1.1.0.jar and /dev/null differ diff --git a/lib/Spring/spring-test-4.1.7.jar b/lib/Spring/spring-test-4.1.7.jar deleted file mode 100644 index 6c35ed2..0000000 Binary files a/lib/Spring/spring-test-4.1.7.jar and /dev/null differ diff --git a/lib/Spring/spring-tx-4.1.7.jar b/lib/Spring/spring-tx-4.1.7.jar deleted file mode 100644 index 9d2d234..0000000 Binary files a/lib/Spring/spring-tx-4.1.7.jar and /dev/null differ diff --git a/lib/Spring/spring-web-4.0.3.jar b/lib/Spring/spring-web-4.0.3.jar deleted file mode 100644 index ceef695..0000000 Binary files a/lib/Spring/spring-web-4.0.3.jar and /dev/null differ diff --git a/lib/Spring/spring-webmvc-4.0.3.jar b/lib/Spring/spring-webmvc-4.0.3.jar deleted file mode 100644 index 4f895da..0000000 Binary files a/lib/Spring/spring-webmvc-4.0.3.jar and /dev/null differ diff --git a/lib/jackson-annotations-2.3.2.jar b/lib/jackson-annotations-2.3.2.jar deleted file mode 100644 index 7ea186f..0000000 Binary files a/lib/jackson-annotations-2.3.2.jar and /dev/null differ diff --git a/lib/jackson-core-2.3.2.jar b/lib/jackson-core-2.3.2.jar deleted file mode 100644 index 0b000af..0000000 Binary files a/lib/jackson-core-2.3.2.jar and /dev/null differ diff --git a/lib/jackson-databind-2.3.2.jar b/lib/jackson-databind-2.3.2.jar deleted file mode 100644 index 0449f39..0000000 Binary files a/lib/jackson-databind-2.3.2.jar and /dev/null differ diff --git a/lib/twitter4j-async-4.0.4-src.zip b/lib/twitter4j-async-4.0.4-src.zip new file mode 100644 index 0000000..a654672 Binary files /dev/null and b/lib/twitter4j-async-4.0.4-src.zip differ diff --git a/lib/twitter4j-async-4.0.4.jar b/lib/twitter4j-async-4.0.4.jar new file mode 100644 index 0000000..4bdd7c0 Binary files /dev/null and b/lib/twitter4j-async-4.0.4.jar differ diff --git a/lib/twitter4j-core-4.0.4-src.zip b/lib/twitter4j-core-4.0.4-src.zip new file mode 100644 index 0000000..3540362 Binary files /dev/null and b/lib/twitter4j-core-4.0.4-src.zip differ diff --git a/lib/twitter4j-core-4.0.4.jar b/lib/twitter4j-core-4.0.4.jar new file mode 100644 index 0000000..029abce Binary files /dev/null and b/lib/twitter4j-core-4.0.4.jar differ diff --git a/lib/twitter4j-media-support-4.0.4-src.zip b/lib/twitter4j-media-support-4.0.4-src.zip new file mode 100644 index 0000000..e349231 Binary files /dev/null and b/lib/twitter4j-media-support-4.0.4-src.zip differ diff --git a/lib/twitter4j-media-support-4.0.4.jar b/lib/twitter4j-media-support-4.0.4.jar new file mode 100644 index 0000000..8ce34ae Binary files /dev/null and b/lib/twitter4j-media-support-4.0.4.jar differ diff --git a/lib/twitter4j-stream-4.0.4-src.zip b/lib/twitter4j-stream-4.0.4-src.zip new file mode 100644 index 0000000..e6c7eeb Binary files /dev/null and b/lib/twitter4j-stream-4.0.4-src.zip differ diff --git a/lib/twitter4j-stream-4.0.4.jar b/lib/twitter4j-stream-4.0.4.jar new file mode 100644 index 0000000..b5c4a08 Binary files /dev/null and b/lib/twitter4j-stream-4.0.4.jar differ diff --git a/src/org/april/hebdobot/cli/HebdobotCLI.java b/src/org/april/hebdobot/cli/HebdobotCLI.java index f58e696..9327bd2 100644 --- a/src/org/april/hebdobot/cli/HebdobotCLI.java +++ b/src/org/april/hebdobot/cli/HebdobotCLI.java @@ -143,7 +143,7 @@ public class HebdobotCLI { logger.info("Bot configuring…"); Hebdobot bot = new Hebdobot(config.getIrcHost(), config.getIrcPort(), config.getIrcName(), config.getIrcChannel(), - config.getReviewFileSuffix()); + configFile.getParentFile(), config.getReviewFileSuffix()); bot.getPastebinSettings().setApiKey(config.getPastebinApiKey()); bot.getIdenticaSettings().setApiKey(config.getIdenticaApiKey()); diff --git a/src/org/april/hebdobot/model/Hebdobot.java b/src/org/april/hebdobot/model/Hebdobot.java index c9dda57..6d9742e 100644 --- a/src/org/april/hebdobot/model/Hebdobot.java +++ b/src/org/april/hebdobot/model/Hebdobot.java @@ -48,9 +48,9 @@ import org.joda.time.format.ISODateTimeFormat; import org.quartz.SchedulerException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.social.ApiException; import fr.devinsy.util.strings.StringsUtils; +import twitter4j.TwitterException; /** * The Class Hebdobot. @@ -59,6 +59,7 @@ public class Hebdobot extends PircBot { private static final Logger logger = LoggerFactory.getLogger(Hebdobot.class); + private File homeDirectory; private String host; private int port; private String channel; @@ -83,8 +84,10 @@ public class Hebdobot extends PircBot * @param channel * the channel */ - public Hebdobot(final String host, final int port, final String name, final String channel, final String reviewFileSuffix) + public Hebdobot(final String host, final int port, final String name, final String channel, final File homeDirectory, + final String reviewFileSuffix) { + this.homeDirectory = homeDirectory; this.host = host; this.port = port; this.channel = channel; @@ -110,26 +113,61 @@ public class Hebdobot extends PircBot this.dispose(); } + /** + * Gets the aliases. + * + * @return the aliases + */ public UserAliases getAliases() { return this.aliases; } + /** + * Gets the cron settings. + * + * @return the cron settings + */ public CronSettings getCronSettings() { return this.cronSettings; } + /** + * Gets the home directory. + * + * @return the home directory + */ + public File getHomeDirectory() + { + return this.homeDirectory; + } + + /** + * Gets the identica settings. + * + * @return the identica settings + */ public IdenticaSettings getIdenticaSettings() { return this.identicaSettings; } + /** + * Gets the pastebin settings. + * + * @return the pastebin settings + */ public PastebinSettings getPastebinSettings() { return this.pastebinSettings; } + /** + * Gets the twitter settings. + * + * @return the twitter settings + */ public TwitterSettings getTwitterSettings() { return this.twitterSettings; @@ -162,10 +200,10 @@ public class Hebdobot extends PircBot this.twitterSettings.getAccessToken(), this.twitterSettings.getAccessTokenSecret()); twitter.tweet(message); } - catch (ApiException exception) + catch (TwitterException exception) { logger.error("Error in tweet", exception); - sendMessage("Pour information, le tweet de notifiation a échoué : " + exception.getMessage()); + sendMessage("(pour information, la notification par Tweet a échoué : " + exception.getErrorMessage() + ")"); } } } @@ -304,7 +342,7 @@ public class Hebdobot extends PircBot logger.info("Write review file."); try { - File file = new File(date + "_" + this.reviewFileSuffix); + File file = new File(this.homeDirectory, date + "_" + this.reviewFileSuffix); FileUtils.writeStringToFile(file, textReview); sendMessage("% Compte-rendu de la revue : " + file.getName()); } @@ -564,4 +602,15 @@ public class Hebdobot extends PircBot logger.debug("Send message : {}", message); this.sendMessage(this.channel, message); } + + /** + * Sets the home directory. + * + * @param homeDirectory + * the new home directory + */ + public void setHomeDirectory(final File homeDirectory) + { + this.homeDirectory = homeDirectory; + } } diff --git a/src/org/april/hebdobot/twitter/TwitterClient.java b/src/org/april/hebdobot/twitter/TwitterClient.java index aafad6a..a5000de 100644 --- a/src/org/april/hebdobot/twitter/TwitterClient.java +++ b/src/org/april/hebdobot/twitter/TwitterClient.java @@ -19,13 +19,22 @@ package org.april.hebdobot.twitter; import org.apache.commons.lang3.StringUtils; -import org.springframework.social.twitter.api.impl.TwitterTemplate; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import twitter4j.Status; +import twitter4j.Twitter; +import twitter4j.TwitterException; +import twitter4j.TwitterFactory; +import twitter4j.conf.ConfigurationBuilder; /** * The Class TwitterClient. */ public class TwitterClient { + private static final Logger logger = LoggerFactory.getLogger(TwitterClient.class); + private String consumerKey; private String consumerSecret; private String accessToken; @@ -75,10 +84,20 @@ public class TwitterClient * * @param message * the message + * @throws TwitterException */ - public void tweet(final String message) + public void tweet(final String message) throws TwitterException { - TwitterTemplate twitterClient = new TwitterTemplate(this.consumerKey, this.consumerSecret, this.accessToken, this.accessTokenSecret); - twitterClient.timelineOperations().updateStatus(message); + ConfigurationBuilder config = new ConfigurationBuilder(); + config.setDebugEnabled(true); + config.setOAuthConsumerKey(this.consumerKey); + config.setOAuthConsumerSecret(this.consumerSecret); + config.setOAuthAccessToken(this.accessToken); + config.setOAuthAccessTokenSecret(this.accessTokenSecret); + + Twitter twitter = new TwitterFactory(config.build()).getInstance(); + + Status status = twitter.updateStatus(message); + logger.info("Tweet result [" + status.getText() + "]."); } }