Created Twitter Command
Added Twitter command for Devs to post from discord
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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));
|
||||
|
||||
@@ -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() + "`!";
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user