Added checks for empty tweet messages.
This commit is contained in:
parent
751a8bafa3
commit
6cd93b9334
@ -202,7 +202,7 @@ public class Hebdobot extends PircBot
|
|||||||
*/
|
*/
|
||||||
public void notifyTwitter(final String message)
|
public void notifyTwitter(final String message)
|
||||||
{
|
{
|
||||||
if (this.twitterSettings.isValid())
|
if ((this.twitterSettings.isValid()) && (StringUtils.isNotBlank(message)))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -89,16 +89,23 @@ public class TwitterClient
|
|||||||
*/
|
*/
|
||||||
public void tweet(final String message) throws TwitterException
|
public void tweet(final String message) throws TwitterException
|
||||||
{
|
{
|
||||||
ConfigurationBuilder config = new ConfigurationBuilder();
|
if (StringUtils.isBlank(message))
|
||||||
config.setDebugEnabled(true);
|
{
|
||||||
config.setOAuthConsumerKey(this.consumerKey);
|
logger.info("Empty message => tweet aborted.");
|
||||||
config.setOAuthConsumerSecret(this.consumerSecret);
|
}
|
||||||
config.setOAuthAccessToken(this.accessToken);
|
else
|
||||||
config.setOAuthAccessTokenSecret(this.accessTokenSecret);
|
{
|
||||||
|
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();
|
Twitter twitter = new TwitterFactory(config.build()).getInstance();
|
||||||
|
|
||||||
Status status = twitter.updateStatus(message);
|
Status status = twitter.updateStatus(message);
|
||||||
logger.info("Tweet result [" + status.getText() + "].");
|
logger.info("Tweet result [" + status.getText() + "].");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user