diff --git a/.classpath b/.classpath index 2b6e34d..d07b8ea 100644 --- a/.classpath +++ b/.classpath @@ -11,5 +11,7 @@ + + diff --git a/lib/twitter4j-core-4.0.7-javadoc.jar b/lib/twitter4j-core-4.0.7-javadoc.jar new file mode 100644 index 0000000..59afcb7 Binary files /dev/null and b/lib/twitter4j-core-4.0.7-javadoc.jar differ diff --git a/lib/twitter4j-core-4.0.7.jar b/lib/twitter4j-core-4.0.7.jar new file mode 100644 index 0000000..a688455 Binary files /dev/null and b/lib/twitter4j-core-4.0.7.jar differ diff --git a/src/commands/CommandTweet.java b/src/commands/CommandTweet.java new file mode 100644 index 0000000..947a26d --- /dev/null +++ b/src/commands/CommandTweet.java @@ -0,0 +1,24 @@ +package commands; + +import core.Command; +import dataStructures.*; +import network.NetworkTwitter; + +public class CommandTweet extends Command +{ + NetworkTwitter tweet = new NetworkTwitter(); + public CommandTweet(KittyRole level, KittyRating rating) { super(level, rating); } + + @Override + public String HelpText() { return "With an input of x,y,z where x y and z are all choices, kitty will choose one"; } + + @Override + public void OnRun(KittyGuild guild, KittyChannel channel, KittyUser user, UserInput input, Response res) + { + try { + res.Call(tweet.tweet(input.args)); + } catch (Exception e) { + res.Call("FUCKED UP HARD"); + } + } +} diff --git a/src/core/ObjectBuilderFactory.java b/src/core/ObjectBuilderFactory.java index e63323f..503a2b8 100644 --- a/src/core/ObjectBuilderFactory.java +++ b/src/core/ObjectBuilderFactory.java @@ -295,6 +295,7 @@ public class ObjectBuilderFactory manager.Register("stats", new CommandStats(KittyRole.Dev, KittyRating.Safe)); manager.Register("invite", new CommandInvite(KittyRole.Dev, KittyRating.Safe)); manager.Register("buildHelp", new CommandHelpBuilder(KittyRole.Dev, KittyRating.Safe)); + manager.Register("tweet", new CommandTweet(KittyRole.Dev, KittyRating.Safe)); manager.Register("rating", new CommandRating(KittyRole.Admin, KittyRating.Safe)); manager.Register("indicator", new CommandChangeIndicator(KittyRole.Admin, KittyRating.Safe)); diff --git a/src/network/NetworkTwitter.java b/src/network/NetworkTwitter.java new file mode 100644 index 0000000..f298e4e --- /dev/null +++ b/src/network/NetworkTwitter.java @@ -0,0 +1,33 @@ +package network; + +import twitter4j.Status; +import twitter4j.Twitter; +import twitter4j.TwitterFactory; +import twitter4j.conf.ConfigurationBuilder; +import offline.Ref; + +public class NetworkTwitter +{ + ConfigurationBuilder cbuilder = new ConfigurationBuilder(); + + + public NetworkTwitter() + { + cbuilder.setDebugEnabled(true) + .setOAuthConsumerKey(Ref.twitterAPIKey) + .setOAuthConsumerSecret(Ref.twitterAPISecret) + .setOAuthAccessToken(Ref.twitterAccessToken) + .setOAuthAccessTokenSecret(Ref.twitterAccessTokenSecret); + + + } + + public String tweet(String tweetText) throws Exception + { + TwitterFactory tf = new TwitterFactory(cbuilder.build()); + Twitter twitter = tf.getInstance(); + Status status = twitter.updateStatus(tweetText); + return "Status set to: `" + status.getText() + "`!"; + + } +}