Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Arrays;
- import org.jibble.pircbot.*;
- import java.sql.*;
- public class Ross extends PircBot {
- public Ross() {
- this.setName("RICK_ROSS");
- this.setVersion("v1.0");
- this.setLogin("not_a_bot");
- if (!main.password.equals("")) this.sendMessage(main.loginbot, "auth "+main.username+" "+main.password);
- }
- public int checkOwner (String hostname) {
- hostname = hostname.replace(".users.quakenet.org", "");
- if (Arrays.asList(main.owner).contains(hostname)) return 1;
- else return 0;
- }
- public void noAccess (String channel) {
- sendMessage(channel,"You do not have access.");
- }
- public int checkLength (String[] words) {
- if (words.length == 1) return 0;
- else return 1;
- }
- public void noParameters (String channel) {
- sendMessage(channel, "Not enough parameters.");
- }
- public String MySQL (String statement) throws SQLException, ClassNotFoundException {
- Connection conn = null;
- String url = "jdbc:mysql://zzzzzzzzzzzzzzzz:3306/zzz";
- Class.forName ("com.mysql.jdbc.Driver");
- conn = DriverManager.getConnection (url,"zzzzzzzzzz","zzzzzzzzzz");
- Statement stmt = conn.createStatement() ;
- ResultSet rs = stmt.executeQuery(statement);
- String result = "";
- while (rs.next()) {
- result = rs.getString(1);
- }
- rs.close();
- stmt.close();
- conn.close ();
- return result;
- }
- public void onMessage(String channel, String sender, String login, String hostname, String message) {
- int value = checkOwner(hostname);
- if (message.equalsIgnoreCase("!online")) {
- String statement = "SELECT COUNT(*) from `char` where `online` = '1'";
- try {
- String result = MySQL(statement);
- int check = Integer.parseInt(result);
- if (check > 0) sendMessage(channel,"It looks like the server is online.");
- else sendMessage(channel,"The server appears to be offline.");
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- if (message.equalsIgnoreCase("!players")) {
- String statement = "SELECT COUNT(*) from `char` where `online` = '1'";
- try {
- String result = MySQL(statement);
- sendMessage(channel,"There are currently "+result+" players playing Oblivion Ragnarok Online.");
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- if (message.equalsIgnoreCase("!owner")) {
- String temp = "";
- if (main.owner.length != 1) {
- for (int i = 0; i < main.owner.length; i++) {
- if (i == main.owner.length-1) temp = temp+"and "+main.owner[i]+" are the best.";
- else temp = temp+main.owner[i]+", ";
- }
- }
- else temp = main.owner[0]+" is the best.";
- sendMessage(channel, temp);
- }
- if (message.equalsIgnoreCase("!time")) {
- String time = new java.util.Date().toString();
- sendMessage(channel, time);
- }
- if (message.startsWith("!topic")) {
- if (value == 1) {
- String topic = message.replace("!topic ", "");
- String[] words = message.split(" ");
- int rvalue = checkLength(words);
- if (rvalue != 1) {
- noParameters(channel);
- }
- else setTopic(channel, topic);
- }
- else noAccess(channel);
- }
- if (message.startsWith("!k")) {
- if (value == 1) {
- String[] words = message.split(" ");
- int rvalue = checkLength(words);
- if (rvalue != 1) {
- noParameters(channel);
- }
- else kick(channel, words[1]);
- }
- else noAccess(channel);
- }
- if (message.startsWith("!m")) {
- if (value == 1) {
- String[] words = message.split(" ");
- int rvalue = checkLength(words);
- if (rvalue != 1) {
- noParameters(channel);
- }
- else {
- if (words.length == 3) {
- if (words[1].equals("+b") || words[1].equals("b")) {
- setMode(channel, words[1]+" "+words[2]);
- kick(channel, words[2]);
- }
- else setMode(channel, words[1]+" "+words[2]);
- }
- else setMode(channel, words[1]);
- }
- }
- else noAccess(channel);
- }
- }
- public void onConnect() {
- joinChannel("#renegades");
- }
- }
Add Comment
Please, Sign In to add comment