本文整理汇总了Java中org.pircbotx.hooks.events.MessageEvent.getChannel方法的典型用法代码示例。如果您正苦于以下问题:Java MessageEvent.getChannel方法的具体用法?Java MessageEvent.getChannel怎么用?Java MessageEvent.getChannel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pircbotx.hooks.events.MessageEvent
的用法示例。
在下文中一共展示了MessageEvent.getChannel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: executeCommand
import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
@Override
public BotResponse executeCommand(final IRCbutt butt, final GenericMessageEvent event, final String[] cmd) {
if (event instanceof MessageEvent) {
MessageEvent channelEvent = (MessageEvent) event;
Channel channel = channelEvent.getChannel();
if (channel != null) {
StringBuilder sb = new StringBuilder();
for (User user : channel.getUsers()) {
if (sb.length() > 0) {
sb.append(' ');
}
sb.append(user.getNick());
}
return new BotResponse(BotIntention.CHAT, null, sb.toString());
}
}
return new BotResponse(BotIntention.PRIVATE_MESSAGE, event.getUser(),
"there aint nobody to wake up here!");
}
示例2: channelCommand
import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
public void channelCommand(MessageEvent<PircBotX> event) throws Exception {
message = event.getMessage();
command = message.split(" ")[0];
user = event.getUser().getNick();
args = event.getMessage().split(" ");
channel = event.getChannel();
}
示例3: onMessage
import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
@Override
public void onMessage(MessageEvent<PircBotX> event) {
final User user = event.getUser();
final Channel channel = event.getChannel();
final String message = event.getMessage();
if (user != plugin.getIrcBot().getUserBot()) {
if (!message.startsWith("!")) {
plugin.handleChat(user, channel, message);
}
}
}
示例4: onMessage
import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
@Override
public void onMessage(MessageEvent<PircBotX> event) throws Exception {
String message = event.getMessage();
User sender = event.getUser();
Channel channel = event.getChannel();
List<ICommand> commands = CommandRegistry.INSTANCE.getCommands();
Long lastFire = delayMap.get(event.getChannel().getName());
if (lastFire == null) {
lastFire = 0L;
}
ReactionRegistry.INSTANCE.getReactions().forEach(r -> r.onMessage(event));
String[] args = IRCUtils.trim(message.split(" "));
if (args.length < 1) {
return;
}
// Eira Bot
if (args[0].startsWith("<") && args[0].endsWith(">")) {
args = ArrayUtils.remove(args, 0);
}
if (args.length > 0 && args[0].startsWith(controlChar)) {
PermLevel perm = PermRegistry.INSTANCE.getPermLevelForUser(event.getChannel(), event.getUser());
if (perm == PermLevel.NONE && !PermRegistry.INSTANCE.isDefaultController(sender)) {
MessageSender.INSTANCE.enqueueNotice(event.getBot(), sender.getNick(), "You may not execute commands in " + channel.getName());
return;
}
if (lastFire + delayTime < System.currentTimeMillis() || IRCUtils.isPermLevelAboveOrEqualTo(perm, PermLevel.TRUSTED)) {
args[0] = pruneCommand(args[0]);
for (int i = 0; i < commands.size(); i++) {
ICommand c = commands.get(i);
if (c.getIdent().equalsIgnoreCase(args[0]) && (IRCUtils.userIsOp(event.getChannel(), event.getBot().getUserBot()) || !c.needsOp())) {
delayMap.put(channel.getName(), System.currentTimeMillis());
List<String> toSend = new ArrayList<String>();
if (IRCUtils.userMatchesPerms(channel, sender, c.getPermLevel())) {
c.onCommand(event.getBot(), event.getUser(), event.getChannel(), toSend, ArrayUtils.remove(args, 0));
} else {
MessageSender.INSTANCE.enqueueNotice(event.getBot(), event.getUser().getNick(), "You have no permission, you must be at least: " + c.getPermLevel().toString());
}
for (String s : toSend) {
IRCUtils.modeSensitiveEnqueue(event.getBot(), event.getUser(), event.getChannel(), s);
}
}
if (i < commands.size() && commands.get(i) != c) {
i--;
}
}
} else {
event.getUser().send().notice("Slow down there, partner.");
}
}
}
示例5: onMessage
import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
@Override
public void onMessage(MessageEvent event) throws Exception {
Chan = event.getChannel();
if (event.getMessage().equalsIgnoreCase("!test")) {
event.getChannel().send().message("Running C++ saying hello world! Just kidding, running Java baby!! Keepo");
}
else if (event.getMessage().equalsIgnoreCase("!join")) {
event.getBot().sendIRC().joinChannel("#" + event.getUser().getNick().toLowerCase());
}
else if (event.getMessage().equalsIgnoreCase("!createtable")) {
SQLConnection.createTable(Chan.getName());
} else if (event.getMessage().toLowerCase().startsWith("!join #")) {
event.respond("On My Way!");
String[] parts = event.getMessage().split(" ");
event.getBot().sendIRC().joinChannel(parts[1].toLowerCase());
//TODO Make the rank command read the actual user rank, needs TTVJSONHandler first.
} else if (event.getMessage().toLowerCase().startsWith("!rank")) {
String Rank = "";
//if(event.getUser().toString().toLowerCase() ==)
if(event.getUser().toString().equalsIgnoreCase(Owner)){
event.respond("Your rank is: " + Rank + ". You are also my creator.");
}
} /**else if (event.getMessage().toLowerCase().startsWith("!uptime")) {
event.getChannel().send().message(JSON.getUptime(Chan.getName()));
}**/
//Leave the dang channel.
else if (event.getMessage().toLowerCase().startsWith("!dismiss")) {
if(event.getUser().toString().equalsIgnoreCase(event.getChannel().getOwners().toString())){
event.getBot().sendRaw().rawLine("PART"+Chan.getName());
}
//If NONE of the previous hardcoded commands are right, THEN go to the MySQL database.
} else if (event.getMessage().toLowerCase().startsWith("!")) {
String reply = SQLConnection.returnCom(Chan.getName().toLowerCase().replace("#",""), event.getMessage().toLowerCase() );
if(reply!=null) {
event.getChannel().send().message(reply);
}
}
}