All pastes #985525 Raw Edit

Mine

public text v1 · immutable
·published 2008-04-15 02:18 UTC
rendered paste body
import org.jibble.pircbot.*;
import java.util.*;

public class TestBot extends PircBot {


	
	// Variable setup
	String prefix = "%";
	
	// Bot setup
	public TestBot() {
		this.setName("TestBot");
		this.setLogin("TestBot");
	}
	
	public void onConnect() {
		identify("wp3578");	
	}

	public void onPrivateMessage(String sender, String login, String hostname, String message) {
		if (sender.equals("Dr_Link")) {
			if (message.startsWith(prefix+"join ")) {
				String join = message.substring(6).trim();
				this.sendRawLine("JOIN "+join);
			}
		}
	}
	
	public void onMessage(String channel, String sender, String login, String hostname, String message) {
		if (message.startsWith(prefix+"prefix ") && sender.equals("TheMasterSwordsman")) {
			String newprefix = message.substring(8).trim();	
			if (newprefix.equals("")) {
				return;
			}		
			if (prefix.length() != 1) {
				sendMessage(channel, "The prefix cannot be changed because prefixes can only be 1 character long.");
			} else {
				prefix = newprefix;
				sendMessage(channel, "The prefix has been changed to " + prefix + ".");
			}
			
		}
		
		if (message.equals(prefix+"roulette")) {
			Random rouletterand = new Random();
			sendAction(channel, "spins the barrel.");
			int bullet = rouletterand.nextInt(10) + 1;
			System.out.println(bullet);
			try {
				Thread.sleep(3000);
			} catch (InterruptedException e) {
				sendMessage(channel, "Oh no, my shotgun is jammed!");			
			}			
			if (bullet >= 5) {
				sendMessage(channel, "BANG! You're dead!");
			} else {
				sendMessage(channel, "You're lucky...");
			}
		}

		if (message.equals(prefix+"dice ")) {
			Random dicerand = new Random();
			String dicestring = message.substring(6).trim();
			int sides = Integer.parseInt(dicestring+"+");
			System.out.println(sides);
			String dietype = "die";
			
			if (sides < 2 || sides > 200 ) {
				sendMessage(channel, "A die must have 2 or more sides and cannot exceed 200 sides.");
				return;
			}

			int die = dicerand.nextInt(sides) + 1;

			if (sides == 2) {
				dietype = "coin";
				if (die == 1) {
					sendMessage(channel, "The " + dietype + " landed on heads.");				
				} else {
					sendMessage(channel, "The " + dietype + " landed on tails.");				
				}
			} else {
				sendMessage(channel, "The " + dietype + " landed on " + die);
			}

			
		}

		
	}
}