Created Twitter Command
Added Twitter command for Devs to post from discord
This commit is contained in:
@@ -11,5 +11,7 @@
|
|||||||
<classpathentry kind="lib" path="lib/JDA-3.7.1_385-withDependencies.jar"/>
|
<classpathentry kind="lib" path="lib/JDA-3.7.1_385-withDependencies.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/sqlite-jdbc-3.23.1.jar"/>
|
<classpathentry kind="lib" path="lib/sqlite-jdbc-3.23.1.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/slf4j-jdk14-1.7.25.jar"/>
|
<classpathentry kind="lib" path="lib/slf4j-jdk14-1.7.25.jar"/>
|
||||||
|
<classpathentry kind="lib" path="F:/Shared/Coding/Java/workspace/ProKitty/lib/twitter4j-core-4.0.7-javadoc.jar"/>
|
||||||
|
<classpathentry kind="lib" path="F:/Shared/Coding/Java/workspace/ProKitty/lib/twitter4j-core-4.0.7.jar"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -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("stats", new CommandStats(KittyRole.Dev, KittyRating.Safe));
|
||||||
manager.Register("invite", new CommandInvite(KittyRole.Dev, KittyRating.Safe));
|
manager.Register("invite", new CommandInvite(KittyRole.Dev, KittyRating.Safe));
|
||||||
manager.Register("buildHelp", new CommandHelpBuilder(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("rating", new CommandRating(KittyRole.Admin, KittyRating.Safe));
|
||||||
manager.Register("indicator", new CommandChangeIndicator(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