Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.jibble.pircbot.*;
- public class MyBot extends PircBot {
- public MyBot() {
- this.setName("ElectricBot");
- }
- public void onMessage(String channel, String sender, String login, String hostname, String message) {
- // This command says Hello, Have a Magical Cookie!
- if (message.equalsIgnoreCase("@hello")) {
- sendMessage(channel, "Hello, Have a Magical Cookie!");
- }
- // This tells the bot to login with nickserv, using the specified password for its nick
- if (message.equalsIgnoreCase("@ident")) {
- sendMessage("NickServ", "identify Max3lis2");
- sendMessage(channel, "This bot is now identified and active!");
- }
- // This tells the user the time
- if (message.equalsIgnoreCase("@time")) {
- String time = (new java.util.Date()).toString();
- sendMessage(channel, sender + ": The time is now " + time);
- }
- // This ops the user who sent the command
- if (message.equalsIgnoreCase("@opme")) {
- op(channel, sender);
- }
- // This deops the user who sent the command
- if (message.equalsIgnoreCase("@deopme")) {
- deOp(channel, sender);
- }
- // This tells the bot to disconnect entirely from the network, allowing a safe quit with CTRL + C
- if (message.equalsIgnoreCase("@botdc")) {
- quitServer("Quit Command Run");
- }
- // Bans a user
- if (message.split(" ")[0].equalsIgnoreCase("@ban")) {
- ban(channel, message.split(" ")[1]);
- }
- // Unbans a user
- if (message.split(" ")[0].equalsIgnoreCase("@unban")) {
- unBan(channel, message.split(" ")[1]);
- }
- // Give the user who executed the command voice
- if (message.equalsIgnoreCase("@voiceme")) {
- voice(channel, sender);
- }
- // Remove voice from the user who executed the command
- if (message.equalsIgnoreCase("@devoiceme")) {
- deVoice(channel, sender);
- }
- // Devoice a user
- if (message.split(" ")[0].equalsIgnoreCase("@devoice")) {
- deVoice(channel, message.split(" ")[1]);
- }
- // Voice a user
- if (message.split(" ")[0].equalsIgnoreCase("@voice")) {
- voice(channel, message.split(" ")[1]);
- }
- // Leave the channel in which the command is executed.
- if (message.equalsIgnoreCase("@part")) {
- sendMessage(channel, "Part command executed, Disconnecting from Channel...");
- partChannel(channel, "Check out https://electricgameing.tk !");
- }
- // Send a raw command through the console
- if (message.split(" ")[0].equalsIgnoreCase("@raw")) {
- sendRawLine(message.split(" ")[1]);
- sendMessage(channel, "Success. Check the console.");
- }
- // Give a user Operator in the current channel
- if (message.split(" ")[0].equalsIgnoreCase("@op")) {
- op(channel, message.split(" ")[1]);
- }
- // Remove a users Operator status in the current channel
- if (message.split(" ")[0].equalsIgnoreCase("@deop")) {
- deOp(channel, message.split(" ")[1]);
- }
- }
- // This protected void tells the bot that if its invited to a channel, it is to join it
- protected void onInvite(String targetNick, String sourceNick, String sourceLogin, String sourceHostname, String channel) {
- joinChannel(channel);
- }
- protected void voiceCheck(String channel, String nickname, String targetNick, String sourceNick, String sourceLogin, String sourceHostname) {
- public bool hasVoice(String channel, String nickname) {
- User[] users = getUsers(channel);
- for (User user : users) {
- if (user.getNick().equalsIgnoreCase(nickname))
- return user.hasVoice();
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement