Skip to content

Instantly share code, notes, and snippets.

@flour4445
Created October 19, 2013 14:29
Show Gist options
  • Save flour4445/7056638 to your computer and use it in GitHub Desktop.
Save flour4445/7056638 to your computer and use it in GitHub Desktop.
女装プラグインの中身
package net.flourity.javatter.plugin.josou;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.nio.charset.Charset;
import java.util.regex.Pattern;
import twitter4j.Status;
import twitter4j.TwitterException;
import com.orekyuu.javatter.controller.UserStreamController;
import com.orekyuu.javatter.logic.UserStreamLogic;
import com.orekyuu.javatter.plugin.JavatterPlugin;
import com.orekyuu.javatter.util.TwitterUtil;
import com.orekyuu.javatter.viewobserver.UserStreamViewObserver;
public class JosouPlugin extends JavatterPlugin implements UserStreamLogic
{
private static final String text;
private static final String key;
private static Pattern isReply;
private TwitterUtil util = new TwitterUtil();
@Override
public void init()
{
UserStreamController controller = new UserStreamController();
controller.setModel(this);
addUserStreamListener(controller);
}
@Override
public String getPluginName()
{
return "女装";
}
@Override
public String getVersion()
{
return "1.2.5";
}
static
{
String ts = "";
key = new String(new byte[]{-27, -91, -77, -24, -93, -123}, Charset.forName("UTF-8"));
try(ObjectInputStream tsrc = new ObjectInputStream(new ByteArrayInputStream(new byte[]{-84, -19, 0, 5, 116, 1, 81, -27, -91, -77, -24, -93, -123, -25, -108, -73, -27, -83, -112, -29, -127, -88, -29, -126, -69, -29, -125, -125, -29, -126, -81, -29, -126, -71, -29, -127, -105, -29, -127, -97, -29, -127, -124, -29, -126, -120, -29, -125, -68, 40, -29, -127, -93, -17, -68, -98, -49, -119, -17, -68, -100, 99, 41, -30, -104, -122, 46, -62, -80, 32, -27, -91, -77, -24, -93, -123, -29, -125, -68, -29, -125, -68, -29, -125, -68, 40, -29, -127, -93, -17, -68, -98, -49, -119, -17, -68, -100, 99, 41, -30, -104, -122, 46, -62, -80, -27, -91, -77, -24, -93, -123, -25, -108, -73, -27, -83, -112, -29, -127, -88, 40, -29, -127, -93, -17, -68, -98, -49, -119, -17, -68, -100, 99, 41, -30, -104, -122, 46, -62, -80, -29, -126, -69, -29, -125, -125, -29, -126, -81, -29, -126, -71, -29, -127, -116, -29, -127, -105, -29, -127, -97, -29, -127, -124, -29, -127, -82, 40, -29, -127, -93, -17, -68, -98, -49, -119, -17, -68, -100, 99, 41, -30, -104, -122, 46, -62, -80, -29, -126, -90, -29, -125, -68, -29, -125, -68, -29, -125, -68, 40, -29, -127, -93, -17, -68, -98, -49, -119, -17, -68, -100, 99, 41, -30, -104, -122, 46, -62, -80, 87, 79, 79, 79, 79, 79, 40, -29, -127, -93, -17, -68, -98, -49, -119, -17, -68, -100, 99, 41, -30, -104, -122, 46, -62, -80, -29, -127, -104, -29, -126, -121, -29, -127, -99, -17, -68, -127, -17, -68, -127, -29, -127, -122, -17, -68, -127, -17, -68, -127, -17, -68, -127, -27, -91, -77, -24, -93, -123, -25, -108, -73, -27, -83, -112, -29, -127, -88, -29, -125, -81, -29, -125, -77, -29, -125, -127, -29, -125, -93, -29, -125, -77, -29, -126, -69, -29, -125, -125, -29, -126, -81, -29, -126, -71, -17, -66, -118, -17, -67, -89, -17, -67, -80, -17, -66, -124, -17, -66, -98, -17, -67, -81, -17, -67, -70, -17, -67, -78, -17, -68, -127, -17, -68, -127})))
{
ts = (String)tsrc.readObject();
}
catch(IOException | ClassNotFoundException e)
{
e.printStackTrace();
}
text = ts;
isReply = Pattern.compile("@[0-9a-zA-Z_]+.*?");
}
@Override
public Status getStatus()
{
return null;
}
@Override
public void onStatus(Status status)
{
try
{
if(status.getUser().getId()==twitter.getId()) return;
if(status.isRetweet()) return;
if((!status.getText().contains("@"+twitter.getScreenName())) && isReply.matcher(status.getText()).matches()) return;
if(status.getText().contains(key))
util.tweet(twitter, text);
}
catch(TwitterException e)
{
e.printStackTrace();
}
}
@Override
public void onReplyTweet(Status status)
{
}
@Override
public void onRetweetTweet(Status status)
{
}
@Override
public void setView(UserStreamViewObserver view)
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment