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


Java MessageEvent.getBot方法代码示例

本文整理汇总了Java中org.pircbotx.hooks.events.MessageEvent.getBot方法的典型用法代码示例。如果您正苦于以下问题:Java MessageEvent.getBot方法的具体用法?Java MessageEvent.getBot怎么用?Java MessageEvent.getBot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.pircbotx.hooks.events.MessageEvent的用法示例。


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

示例1: onMessage

import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
@Override
public void onMessage(final MessageEvent event) {
	PircBotX bot = event.getBot();
	String[] splitMessage = event.getMessage().split(" ");
	for (String aSplitMessage : splitMessage) {
		if (aSplitMessage.contains("twitter.com") && aSplitMessage.contains("/status/")) {
			int index = aSplitMessage.lastIndexOf("/") + 1;
			long status = Long.parseLong(aSplitMessage.substring(index));
			try {
				Status lookup = twitter.showStatus(status);
				bot.sendIRC().message(event.getChannel().getName(), lookup.getCreatedAt() + " @" + lookup.getUser().getScreenName() + ": " + lookup.getText());
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
}
 
开发者ID:MCUpdater,项目名称:RavenBot,代码行数:18,代码来源:TwitterHandler.java

示例2: handleCommand

import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
@Override
public void handleCommand(String sender, MessageEvent event, String command, String[] args) {
	if (command.equals(".ping")) {
		event.respond("Pong!");
	}
	if (command.equals(".whoami")) {
		event.getUser().send().notice("UUID: " + event.getUser().getUserId().toString());
		event.getUser().send().notice("Verified: " + event.getUser().isVerified() + "\n");
		event.getUser().send().notice("Login: " + event.getUser().getLogin() + "\n");
		event.getUser().send().notice("Real name: " + event.getUser().getRealName() + "\n");
		event.getUser().send().notice("Hostmask: " + event.getUser().getHostmask() + "\n");
		try {
			event.getBot().sendRaw().rawLine("WHOIS " + event.getUser().getNick() + " " + event.getUser().getNick());
			WaitForQueue waitForQueue = new WaitForQueue(event.getBot());
			while (true) {
				WhoisEvent whoisEvent = waitForQueue.waitFor(WhoisEvent.class);
				if (!whoisEvent.getNick().equals(event.getUser().getNick()))
					continue;
				 waitForQueue.close();
				event.getUser().send().notice("Registered as: " + whoisEvent.getRegisteredAs());
			}
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
}
 
开发者ID:MCUpdater,项目名称:RavenBot,代码行数:27,代码来源:DebugHandler.java

示例3: onMessage

import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
@Override
public void onMessage(final MessageEvent event) {
 super.onMessage(event);
 try {
  PircBotX bot = event.getBot();
  String user = event.getUser().getNick();
        PreparedStatement checkTells = RavenBot.getInstance().getPreparedStatement("getTells");
        checkTells.setString(1, user);
        ResultSet results = checkTells.executeQuery();
      while (results.next()) {
       bot.sendIRC().notice(user, results.getString(2) + " in " + results.getString(3) + " said: " + results.getString(4));
      }
      PreparedStatement clearTells = RavenBot.getInstance().getPreparedStatement("removeTells");
      clearTells.setString(1, user);
      clearTells.execute();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:MCUpdater,项目名称:RavenBot,代码行数:20,代码来源:TellHandler.java

示例4: onMessage

import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
@Override
public void onMessage(MessageEvent event) throws Exception {
    if (event.getMessage().startsWith(Helix.botPrefix + Commands.nick + " ") && event.getMessage().length() > (Commands.nick.length() + 2) && admins.contains(Util.getLogin(event.getUser()).toLowerCase()) && Util.isVerified(event.getUser())) {
        String newNick = event.getMessage().split(" ", 2)[1];
        WaitForQueue queue = new WaitForQueue(event.getBot());
        event.getBot().sendIRC().changeNick(newNick);
        while (true) {
            Event currentEvent = queue.waitFor(Arrays.asList(ServerResponseEvent.class, NickChangeEvent.class));
            if (currentEvent instanceof ServerResponseEvent) {
                switch (((ServerResponseEvent)currentEvent).getCode()) {
                    case 431:
                        event.getUser().send().notice("No nickname given");
                        return;
                    case 432:
                        event.getUser().send().notice("Erroneous nickname");
                        return;
                    case 433:
                        event.getUser().send().notice("Nickname is already in use");
                        return;
                }
            } else if (currentEvent instanceof NickChangeEvent && ((NickChangeEvent)currentEvent).getUser() == event.getBot().getUserBot()) return;
        }
    }
}
 
开发者ID:MatheusVigaro,项目名称:Helix,代码行数:25,代码来源:ListenerCommandNick.java

示例5: onMessage

import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
@Override
public void onMessage(final MessageEvent event) {
	super.onMessage(event);
	PircBotX bot = event.getBot();
	String[] splitMessage = event.getMessage().split(" ");
	for (String aSplitMessage : splitMessage) {
		if (aSplitMessage.contains("youtube.com") && aSplitMessage.contains("v=")) {
			int index = aSplitMessage.lastIndexOf("v=") + 2;
			String videoId = (aSplitMessage.indexOf("&",index) > -1 ? aSplitMessage.substring(index, aSplitMessage.indexOf("&",index)) : aSplitMessage.substring(index));
			System.out.println(videoId);
			try {
				YouTube.Videos.List videos = youtube.videos().list("id,snippet,contentDetails");
				videos.setKey(SettingsManager.getInstance().getSettings().getYoutubeKey());
				videos.setId(videoId);

				VideoListResponse videoListResponse = videos.execute();
				List<Video> videoList = videoListResponse.getItems();
				if (videoList != null) {
					Video firstResult = videoList.get(0);
					bot.sendIRC().message(event.getChannel().getName(), formatResult(firstResult));
				} else {
					bot.sendIRC().message(event.getChannel().getName(), "Could not find information about that video");
				}

			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	}
}
 
开发者ID:MCUpdater,项目名称:RavenBot,代码行数:31,代码来源:YouTubeHandler.java

示例6: handleCommand

import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
@Override
public void handleCommand(String sender, MessageEvent event, String command, String[] args) {
    PircBotX bot = event.getBot();
    if (command.equals(".tell")) {
        try {
            PreparedStatement addTell = RavenBot.getInstance().getPreparedStatement("addTell");
            if (args.length == 0) {
                event.respond("Who did you want to tell?");
                return;
            }
            String recipient = args[0];
            if (args.length == 1) {
                event.respond("What did you want to say to " + recipient + "?");
                return;
            }

            String channel = event.getChannel().getName();
            String message = StringUtils.join(args," ", 1, args.length);

            addTell.setString(1, sender);
            addTell.setString(2, recipient);
            addTell.setString(3, channel);
            addTell.setString(4, message);
            addTell.executeUpdate();
            event.respond(recipient + " will be notified of this message when next seen.");
        } catch (Exception e) {
            e.printStackTrace();
            event.respond("An error occurred while processing this command (.tell)");
        }
    }
}
 
开发者ID:MCUpdater,项目名称:RavenBot,代码行数:32,代码来源:TellHandler.java

示例7: CommandEvent

import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
public CommandEvent(MessageEvent<T> event, User user, Channel channel, Command command, String[] args) {
	super(event.getBot());
	SOURCE = event;
	USER = user;
	CHANNEL = channel;
	COMMAND = command;
	ARGS = args;
}
 
开发者ID:IAreKyleW00t,项目名称:aradiabot,代码行数:9,代码来源:CommandEvent.java

示例8: GenericUserMessageEvent

import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
public GenericUserMessageEvent(MessageEvent e) {
	super(e.getBot());
	event = e;
	eMessage = e;
	eChannelUser = e;
}
 
开发者ID:Shockah,项目名称:Skylark,代码行数:7,代码来源:GenericUserMessageEvent.java


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