当前位置: 首页>>代码示例>>Java>>正文


Java GenericMessageEvent类代码示例

本文整理汇总了Java中org.pircbotx.hooks.types.GenericMessageEvent的典型用法代码示例。如果您正苦于以下问题:Java GenericMessageEvent类的具体用法?Java GenericMessageEvent怎么用?Java GenericMessageEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GenericMessageEvent类属于org.pircbotx.hooks.types包,在下文中一共展示了GenericMessageEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onGenericMessage

import org.pircbotx.hooks.types.GenericMessageEvent; //导入依赖的package包/类
@Override
public void onGenericMessage (GenericMessageEvent e) {

    String sender = e.getUser().getNick();

    // send a test message
    if (e.getMessage().equalsIgnoreCase(prefix + "test")) {
        e.respond("Ciao bello! ;-)");
    }

    //whoami
    if (e.getMessage().equalsIgnoreCase(prefix + "whoami")) {
        e.respond("You are " + sender + ", indeed!");
    }

    //write a test .property file to find out where it goes
    if (e.getMessage().equalsIgnoreCase(prefix + "writetest")) {
        if (sender.equals(masterUser)) {
            e.respond("Writing a " + CONFIG_FILE + "...");
            utils.writeProperty("test", "I'm a test");
            e.respond("Done!");
        } else { e.respond("Access denied!"); }
    }

}
 
开发者ID:Walkersneps,项目名称:SnepsBotX,代码行数:26,代码来源:TestCommands.java

示例2: onGenericMessage

import org.pircbotx.hooks.types.GenericMessageEvent; //导入依赖的package包/类
@Override
public void onGenericMessage (GenericMessageEvent e) {

    String sender = e.getUser().getNick();

    //stalk cycle
    if (canStalk) {
        String senderup = sender.toUpperCase();
        //System.out.println("Uppercase sender nick is: " + senderup);
        if (stalkingPeople.contains(senderup)) {
            System.out.println("extracting stalkSentence...");
            String stalkSentence = nextSentence();
            e.respond(stalkSentence);
        }
    }

}
 
开发者ID:Walkersneps,项目名称:SnepsBotX,代码行数:18,代码来源:StalkCycle.java

示例3: onGenericMessage

import org.pircbotx.hooks.types.GenericMessageEvent; //导入依赖的package包/类
@Override
public void onGenericMessage (GenericMessageEvent e) throws Exception {

    String message = e.getMessage();

    if (message.startsWith(prefix + "chat ")) {
        String mode = message.split(" ") [1];

        if (mode.equalsIgnoreCase("on")) {
            canChat = true;
            e.respond("I can now chat! How lovely :)");
        } else if (mode.equalsIgnoreCase("off")) {
            canChat = false;
            e.respond("Ok, so you want me to shut up?! Oh, what the fuck you little bitch!");
        }
    }


}
 
开发者ID:Walkersneps,项目名称:SnepsBotX,代码行数:20,代码来源:ChatToggle.java

示例4: onGenericMessage

import org.pircbotx.hooks.types.GenericMessageEvent; //导入依赖的package包/类
@Override
public void onGenericMessage(final GenericMessageEvent event) throws Exception {

    if (event.getMessage().startsWith(m_command)) {
        if(PermissionHelper.HasPermissionFromList(m_neededPermissions, event.getUser().getNick())) {

            if (CommandHelper.checkForAmountOfArgs(event.getMessage(), 0)) {
                event.respond("HalGNU V1.0 - Daisy");
            } else {
                event.respond("Ex: " + m_command + "");
            }
        } else {
            event.respond("Permission denied");
        }
    }
}
 
开发者ID:R4stl1n,项目名称:halgnu,代码行数:17,代码来源:VersionListener.java

示例5: handleReadTwitterCommand

import org.pircbotx.hooks.types.GenericMessageEvent; //导入依赖的package包/类
public void handleReadTwitterCommand(GenericMessageEvent event) {
        if (CommandHelper.checkForAmountOfArgs(event.getMessage(), 1)) {
            String check = CommandHelper.removeCommandFromString(event.getMessage()).trim();
            try {
                MemberModel memberModel = DatabaseManager.getInstance().getMemberByUsername(check);
                if (memberModel != null) {
                    event.respond(memberModel.getUserName()+"'s twitter handle is: "
                            +memberModel.getTwitterHandle()+" ");
                } else {
                    event.respond("No record found.");
                }
            } catch (SQLException e) {
                e.printStackTrace();
                event.respond("No record found.");
            }
        } else {
            event.respond("Ex. "+ m_readTwitter +" <user>");
        }
}
 
开发者ID:R4stl1n,项目名称:halgnu,代码行数:20,代码来源:TwitterHandleListener.java

示例6: onGenericMessage

import org.pircbotx.hooks.types.GenericMessageEvent; //导入依赖的package包/类
@Override
public void onGenericMessage(final GenericMessageEvent event) throws Exception {
    checkIfUrl(event.getMessage());
    if (event.getMessage().startsWith(m_command)) {
        if(PermissionHelper.HasPermissionFromList(m_neededPermissions, event.getUser().getNick())) {

            if (CommandHelper.checkForAmountOfArgs(event.getMessage(), 0)) {

                event.respond(getTitle());

            } else {

                event.respond("Ex: " + m_command + "");
            }
        } else {
            event.respond("Permission denied");
        }
    }
}
 
开发者ID:R4stl1n,项目名称:halgnu,代码行数:20,代码来源:WebsiteHeaderListener.java

示例7: onGenericMessage

import org.pircbotx.hooks.types.GenericMessageEvent; //导入依赖的package包/类
@Override
public void onGenericMessage(final GenericMessageEvent event) throws Exception {

    if (event.getMessage().startsWith(m_command)) {
        if(PermissionHelper.HasPermissionFromList(m_neededPermissions, event.getUser().getNick())) {

            if (CommandHelper.checkForAmountOfArgs(event.getMessage(), 0)) {

                event.respond("Current Date/Time: " + getDateTime());
            } else {
                event.respond("Ex: " + m_command + "");
            }
        } else {
            event.respond("Permission denied");
        }
    }
}
 
开发者ID:R4stl1n,项目名称:halgnu,代码行数:18,代码来源:TimeListener.java

示例8: handleLastSeenCommand

import org.pircbotx.hooks.types.GenericMessageEvent; //导入依赖的package包/类
public void handleLastSeenCommand(GenericMessageEvent event) {
    if (PermissionHelper.HasPermissionFromList(m_lastSeenNeededPermissions, event.getUser().getNick())) {
        if (CommandHelper.checkForAmountOfArgs(event.getMessage(), 1)) {
            String check = CommandHelper.removeCommandFromString(event.getMessage()).trim();
            try {
                ActivityModel activityModel = DatabaseManager.getInstance().getActivityByUsername(check);
                if (activityModel != null) {
                    event.respond(activityModel.getLastActive()+" :<"
                            +activityModel.getUsername()+"> " + activityModel.getLastMessage());
                } else {
                    event.respond("No record found.");
                }
            } catch (SQLException e) {
                e.printStackTrace();
                event.respond("No record found.");
            }

        } else {
            event.respond("Ex. "+ m_lastSeenCommand +" <user>");
        }
    } else {
        event.respond("Permission denied");
    }
}
 
开发者ID:R4stl1n,项目名称:halgnu,代码行数:25,代码来源:ActivityListener.java

示例9: handleExemptCommand

import org.pircbotx.hooks.types.GenericMessageEvent; //导入依赖的package包/类
public void handleExemptCommand(GenericMessageEvent event) {
    if (PermissionHelper.HasPermissionFromList(m_exemptNeededPermissions, event.getUser().getNick())) {
        if (CommandHelper.checkForAmountOfArgs(event.getMessage(), 1)) {
            String toggleUser = CommandHelper.removeCommandFromString(event.getMessage()).trim();

            if (DatabaseManager.getInstance().toggleActivityExempt(toggleUser)) {
                if(DatabaseManager.getInstance().getActivityExempt(toggleUser)) {
                    event.respond(toggleUser + " is now exempt from idle checks");
                } else {
                    event.respond(toggleUser + " is no longer exempt from idle checks");
                }
            } else {
                event.respond("No record found.");
            }

        } else {
            event.respond("Ex. "+ m_toggleExemptCommand +" <user>");
        }
    } else {
        event.respond("Permission denied");
    }
}
 
开发者ID:R4stl1n,项目名称:halgnu,代码行数:23,代码来源:ActivityListener.java

示例10: onGenericMessage

import org.pircbotx.hooks.types.GenericMessageEvent; //导入依赖的package包/类
@Override
public void onGenericMessage(final GenericMessageEvent event) throws Exception {
    if (event.getMessage().startsWith(m_command)) {
        if (PermissionHelper.HasPermissionFromList(m_neededPermissions, event.getUser().getNick())) {

            if (CommandHelper.checkForAmountOfArgs(event.getMessage(), 1)) {
                int saying = randInt(0,m_shameSayings.length - 1);
                String target = CommandHelper.removeCommandFromString(event.getMessage());
                event.getBot().sendIRC().message(ConfigManager.getInstance().getIrcChannel(),
                        m_shameSayings[saying].replace("%XXXX%", target));

            } else {
                event.respond("Ex. "+m_command+" <user>");
            }
        } else {
            event.respond("Permission Denied");
        }
    }
}
 
开发者ID:R4stl1n,项目名称:halgnu,代码行数:20,代码来源:ShameListener.java

示例11: handleRemoveMemberCommand

import org.pircbotx.hooks.types.GenericMessageEvent; //导入依赖的package包/类
private void handleRemoveMemberCommand(GenericMessageEvent event) {
    if(PermissionHelper.HasPermissionFromList(m_neededRemoveMemberPermissions, event.getUser().getNick())) {
        if (CommandHelper.checkForAmountOfArgs(event.getMessage(), 1)) {
            try {
                MemberModel member = DatabaseManager.getInstance().getMemberByUsername(CommandHelper.removeCommandFromString(event.getMessage()).trim());
                if (member != null) {
                    DatabaseManager.getInstance().getMemberDao().delete(member);
                    event.respond("User removed from database");
                    AdminCmdHelper.kickUserFromRoom(CommandHelper.removeCommandFromString(event.getMessage()).trim(), "Membership_Revoked");
                    
                } else {
                    event.respond("User does not exist");
                }
            } catch (SQLException e) {
                event.respond("User does not exist");
            }
        } else {
            event.respond("Ex: " + m_removeMemberCommand + " <user>");
        }
    } else {
        event.respond("Permission denied");
    }
}
 
开发者ID:R4stl1n,项目名称:halgnu,代码行数:24,代码来源:BouncerListener.java

示例12: handleEnforceCommand

import org.pircbotx.hooks.types.GenericMessageEvent; //导入依赖的package包/类
private void handleEnforceCommand(GenericMessageEvent event) {
    int numKicked = 0;

    if(PermissionHelper.HasPermissionFromList(m_neededEnforcePermissions, event.getUser().getNick())) {
        if (CommandHelper.checkForAmountOfArgs(event.getMessage(), 0)) {

            m_enforce = !m_enforce;

            if(m_enforce) {
                event.respond("Activating enforcement mode");

                event.respond("Scanning room");
                doEnforcmentCheck(event);
                event.respond("Scan complete");

            } else {
                event.respond("Deactivating enforcement mode");
            }
        }
    } else {
        event.respond("Permission denied");
    }
}
 
开发者ID:R4stl1n,项目名称:halgnu,代码行数:24,代码来源:BouncerListener.java

示例13: doEnforcmentCheck

import org.pircbotx.hooks.types.GenericMessageEvent; //导入依赖的package包/类
private void doEnforcmentCheck(GenericMessageEvent event) {
    int numKicked = 0;

    for (User user : event.getBot().getUserBot().getChannels().first().getUsers()) {
        if(!(user.getNick().trim().equals(ConfigManager.getInstance().getIrcNick()))) {
            try {
                MemberModel member = DatabaseManager.getInstance().getMemberByUsername(user.getNick().trim());
                if (member == null) {
                    AdminCmdHelper.kickUserFromRoom(user.getNick(), "Not-Authorized");
                    numKicked += 1;
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }

    if(numKicked == 1) {
        event.respond("Removed " + numKicked + " user");
    } else {
        event.respond("Removed " + numKicked + " users");
    }
}
 
开发者ID:R4stl1n,项目名称:halgnu,代码行数:24,代码来源:BouncerListener.java

示例14: handleInviteCommand

import org.pircbotx.hooks.types.GenericMessageEvent; //导入依赖的package包/类
private void handleInviteCommand(GenericMessageEvent event) {
    if(PermissionHelper.HasPermissionFromList(m_neededInvitePermissions, event.getUser().getNick())) {
        if (CommandHelper.checkForAmountOfArgs(event.getMessage(), 1)) {
            if(DatabaseManager.getInstance().createMember(CommandHelper.removeCommandFromString(event.getMessage()).trim()
                    ,event.getUser().getNick())) {
                event.respond("User added to registry");
            } else {
                event.respond("User already in registry");
            }
        } else {
            event.respond("Ex: " + m_inviteCommand + " <usernamehere>");
        }
    } else {
        event.respond("Permission denied");
    }
}
 
开发者ID:R4stl1n,项目名称:halgnu,代码行数:17,代码来源:BouncerListener.java

示例15: handleWhoInvitedCommand

import org.pircbotx.hooks.types.GenericMessageEvent; //导入依赖的package包/类
private void handleWhoInvitedCommand(GenericMessageEvent event) {
    if(PermissionHelper.HasPermissionFromList(m_neededWhoInvitedPermissions, event.getUser().getNick())) {

        if (CommandHelper.checkForAmountOfArgs(event.getMessage(), 1)) {
            MemberModel member = null;
            try {
                member = DatabaseManager.getInstance()
                        .getMemberByUsername(CommandHelper.removeCommandFromString(event.getMessage()).trim());

                if(member != null) {
                    event.respond(member.getInvitedBy() + " invited " + member.getUserName() + " on " + member.getDateInvited());
                } else {
                    event.respond("User not in registry");
                }
            } catch (SQLException e) {
                e.printStackTrace();
                event.respond("User not in registry");
            }
        } else {
            event.respond("Ex: " + m_whoInvitedCommand + " <usernamehere>");
        }
    } else {
        event.respond("Permission denied");
    }
}
 
开发者ID:R4stl1n,项目名称:halgnu,代码行数:26,代码来源:BouncerListener.java


注:本文中的org.pircbotx.hooks.types.GenericMessageEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。