Skip to content

Instantly share code, notes, and snippets.

@JOPHESTUS
Created April 22, 2014 07:18
Show Gist options
  • Save JOPHESTUS/11168345 to your computer and use it in GitHub Desktop.
Save JOPHESTUS/11168345 to your computer and use it in GitHub Desktop.
package us.jophest.jimmy;
import org.pircbotx.PircBotX;
import org.pircbotx.hooks.ListenerAdapter;
import org.pircbotx.hooks.events.ConnectEvent;
import org.pircbotx.hooks.events.InviteEvent;
import org.pircbotx.hooks.events.MessageEvent;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.EmptyStackException;
import java.util.HashMap;
import java.util.Random;
public class Jimmy extends ListenerAdapter {
public static PircBotX bot = new PircBotX();
public static void main(String[] args) throws Exception {
bot.setName("Cobby");
bot.setLogin("Cobby");
bot.getListenerManager().addListener(new Jimmy());
bot.connect("irc.esper.net");
//password for nickserv goes here, you can't know though ;) bot.identify("");
bot.joinChannel("#chemnstuff");
bot.joinChannel("#huskehhh");
bot.joinChannel("#cobby");
bot.joinChannel("#DSH105");
bot.joinChannel("#entityapi");
bot.joinChannel("#gomeow");
bot.joinChannel("#hoolean");
bot.joinChannel("#jacklin213");
bot.joinChannel("#jophestus");
bot.joinChannel("#LividiusGaming");
bot.joinChannel("#frostalf");
bot.joinChannel("#dra");
bot.joinChannel("#hawkfalcon");
}
static String channelName = "";
static File f = new File("");
public void onLoad(ConnectEvent event) {
}
public static void itpa(String name, String state) throws Exception {
URL yahoo = new URL("http://itpa.jophest.us/adminz/addmobile.php?name=" + name + "&state=" + state);
URLConnection yc = yahoo.openConnection();
BufferedReader in = new BufferedReader(
new InputStreamReader(
yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
in.close();
}
public void onInvite(InviteEvent event) {
channelName = event.getChannel();
f = new File(channelName);
if (f.exists()) {
bot.sendMessage(event.getUser(), "You just invited Cobby to " + channelName + ". Unfortunately for some reason your channel has been blacklisted. Please contact JOPHESTUS if you believe this to be an error.");
} else {
bot.joinChannel(event.getChannel());
}
}
public void onMessage(final MessageEvent event) {
final String[] line = event.getMessage().split(" ");
if (line[0].equalsIgnoreCase("!pizza")) {
if (line.length == 1) {
event.getBot().sendAction(event.getChannel(),
"makes everyone a pizza!");
} else if (line[1] != null) {
event.getBot().sendAction(event.getChannel(),
"makes " + line[1] + " a pizza!");
}
} else if (event.getMessage().equalsIgnoreCase("!recipe")) {
event.getBot().sendMessage(event.getUser(),
"Basic Pizza Base Recipe. Serves: 1");
event.getBot()
.sendMessage(
event.getUser(),
"[Preheat oven 100C] 1 cup flour, 1/2 cup warm water, 1/2 tsp sugar, 1/2 tsp salt, 1tsp dried yeast");
event.getBot()
.sendMessage(event.getUser(),
"Mix all ingredients together, knead dough (add flour where necessary).");
event.getBot()
.sendMessage(event.getUser(),
"Prove (allow to rise) in a warm oven (100 C) with the door open for 5-10 mins");
event.getBot()
.sendMessage(event.getUser(),
"Knead, roll out dough, and apply desired toppings. Cook at 200C");
} else if (event.getMessage().equalsIgnoreCase("!a")) {
event.getBot().sendAction(event.getChannel(),
"agrees");
} else if (event.getMessage().equalsIgnoreCase("!cobby help")) {
event.getBot().sendMessage(event.getUser(), "!a - Agree");
event.getBot().sendMessage(event.getUser(), "!pizza <name> - Make someone a pizza");
event.getBot().sendMessage(event.getUser(), "!recipe - Tells you a basic pizza base recipe");
event.getBot().sendMessage(event.getUser(), "!tr <name> - Give someone a treat");
event.getBot().sendMessage(event.getUser(), "!sm <name> - Smite someone");
event.getBot().sendMessage(event.getUser(), "!cd <name> - Condemn someone");
event.getBot().sendMessage(event.getUser(), "!h <name> - Hug someone");
event.getBot().sendMessage(event.getUser(), "!wa <name> - Wave at someone");
event.getBot().sendMessage(event.getUser(), "!spam <user> - Spams someone");
event.getBot().sendMessage(event.getUser(), "!we <user> - Welcomes someone");
event.getBot().sendMessage(event.getUser(), "!l <user> - Laughs at someone");
event.getBot().sendMessage(event.getUser(), "!troll <user> - Trolls someone");
event.getBot().sendMessage(event.getUser(), "!bl <user> - Blames someone");
} else if (line[0].equalsIgnoreCase("!pr")) {
if (line.length == 1) {
event.getBot().sendAction(event.getChannel(),
"gives everyone a Christmas present!");
} else if (line[1] != null) {
event.getBot().sendAction(event.getChannel(),
"gives " + line[1] + " a Christmas present!");
}
} else if (event.getMessage().equalsIgnoreCase("!cobby leave")) {
if (event.getUser().getNick().equalsIgnoreCase("JOPHESTUS")) {
bot.partChannel(event.getChannel(), "JOPH told me to");
} else {
event.respond("You can't do that");
}
} else if (event.getMessage().startsWith("!cobby join")) {
if (event.getUser().getNick().equalsIgnoreCase("JOPHESTUS")) {
bot.joinChannel(line[2]);
event.getBot().sendMessage(line[2], "I was told to join by JOPHESTUS. If you don't want me here, please kick me.");
} else {
event.respond("You can't do that");
}
} else if (event.getMessage().startsWith("!cobby blacklist")) {
if (event.getUser().getNick().equalsIgnoreCase("JOPHESTUS")) {
channelName = line[2];
f = new File(line[2]);
try {
f.createNewFile();
event.respond("Channel " + line[2] + " has been blacklisted.");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
event.respond("You can't do that");
}
} else if (event.getMessage().startsWith("!cobby topic")) {
if (event.getChannel().isOp(event.getUser())) {
StringBuilder b = new StringBuilder();
for (int i = 2; i < line.length; i++) {
if (i != 2)
b.append(" ");
b.append(line[i]);
}
event.getBot().setTopic(event.getChannel(), b.toString());
} else {
event.respond("You can't do that");
}
} else if (line[0].equalsIgnoreCase("!sm")) {
if (line.length == 1) {
event.getBot().sendAction(event.getChannel(),
"smites " + "everyone!");
} else if (line[1] != null) {
event.getBot().sendAction(event.getChannel(),
"smites " + line[1] + "!");
}
} else if (line[0].equalsIgnoreCase("!cd")) {
if (line.length == 1) {
event.getBot().sendAction(event.getChannel(),
"condemns " + "everyone!");
} else if (line[1] != null) {
event.getBot().sendAction(event.getChannel(),
"condemns " + line[1] + "!");
}
}else if (line[0].equalsIgnoreCase("!tr")) {
if (line.length == 1) {
event.getBot().sendAction(event.getChannel(),
"gives everyone a treat!");
} else if (line[1] != null) {
event.getBot().sendAction(event.getChannel(),
"gives " + line[1] + " a treat!");
}
} else if (line[0].equalsIgnoreCase("!h")) {
if (line.length == 1) {
event.getBot().sendAction(event.getChannel(),
"hugs " + "everyone!");
} else if (line[1] != null) {
event.getBot().sendAction(event.getChannel(),
"hugs " + line[1] + "!");
}
} else if (line[0].equalsIgnoreCase("!wa")) {
if (line.length == 1) {
event.getBot().sendAction(event.getChannel(),
"waves at " + "everyone!");
} else if (line[1] != null) {
event.getBot().sendAction(event.getChannel(),
"waves at " + line[1] + "!");
}
} else if (line[0].equalsIgnoreCase("!setitpa")) {
if (event.getUser().getNick().equalsIgnoreCase("JOPHESTUS")) {
try {
itpa(line[1], line[2]);
event.respond("Awesomestate set!");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
event.respond("You can't do that");
}
} else if (line[0].equalsIgnoreCase("!l")) {
if (line.length == 1) {
event.getBot().sendAction(event.getChannel(),
"laughs at " + "everyone!");
} else if (line[1] != null) {
event.getBot().sendAction(event.getChannel(),
"laughs at " + line[1] + "!");
}
} else if (line[0].equalsIgnoreCase("!spam")) {
if (line[1] != null) {
event.getBot().sendMessage(event.getChannel(),
line[1] + " " + line[1] + " " + line[1] + " " + line[1] + " " + line[1] + " " + "!");
}
} else if (line[0].equalsIgnoreCase("!we")) {
if (line[1] != null) {
event.getBot().sendAction(event.getChannel(), "welcomes " + line[1]);
}
} else if (line[0].equalsIgnoreCase("!troll")) {
if (line[1] != null) {
event.getBot().sendMessage(event.getChannel(), line[1] + " got trolled!");
}
} else if (line[0].equalsIgnoreCase("!bl")) {
if (line.length == 1) {
event.getBot().sendAction(event.getChannel(),
"blames Hoolean!");
} else if (line[1] != null) {
event.getBot().sendAction(event.getChannel(),
"blames " + line[1] + "!");
}
} else if (line[0].equalsIgnoreCase("!r")) {
Random rand = new Random();
String nick = event.getUser().getNick().toString();
int one;
int two;
int three;
int four;
one = rand.nextInt(10);
two = rand.nextInt(10);
three = rand.nextInt(10);
four = rand.nextInt(10);
event.respond("" + one + "" + two + "" + three + "" + four);
int digit0 = 5;
int digit1 = 2;
int digit2 = 2;
int digit3 = 4;
int digit4 = 4;
int digit5 = 6;
int digit6 = 6;
int digit7 = 8;
int digit8 = 5;
int digit9 = 10;
if (four == three) {
if (two == four) {
if (one == four) {
event.respond("Quads! You get 25 territories");
} else {
event.respond("Trips! You get 20 territories ");
}
} else {
event.respond("Dubs! You get 15 territories");
}
} else {
if (four == 0) {
event.respond("0! You get 5 territories ");
} else if (four == 1) {
event.respond("1! You get 2 territories ");
} else if (four == 2) {
event.respond("2! You get 2 territories ");
} else if (four == 3) {
event.respond("3! You get 4 territories ");
} else if (four == 4) {
event.respond("4! You get 4 territories ");
} else if (four == 5) {
event.respond("5! You get 6 territories ");
} else if (four == 6) {
event.respond("6! You get 6 territories ");
} else if (four == 7) {
event.respond("7! You get 8 territories ");
} else if (four == 8) {
event.respond("8! You get 8 territories ");
} else if (four == 9) {
event.respond("9! You get 10 territories ");
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment