本文整理汇总了Java中org.pircbotx.hooks.events.MessageEvent.respond方法的典型用法代码示例。如果您正苦于以下问题:Java MessageEvent.respond方法的具体用法?Java MessageEvent.respond怎么用?Java MessageEvent.respond使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pircbotx.hooks.events.MessageEvent
的用法示例。
在下文中一共展示了MessageEvent.respond方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
}
}
示例2: handleCommand
import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
@Override
public void handleCommand(String sender, MessageEvent event, String command, String[] args) {
if (command.equals(".seen")) {
try {
PreparedStatement getSeen = RavenBot.getInstance().getPreparedStatement("getLastSeen");
String[] splitMessage = event.getMessage().split(" ");
String target = splitMessage[1];
getSeen.setString(1, target);
ResultSet results = getSeen.executeQuery();
if (results.next()) {
event.respond(target + " was last seen " + formatTime(System.currentTimeMillis() - results.getLong(1)) + "ago.");
} else {
event.respond(target + " has not been seen.");
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
示例3: onMessage
import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
/**
* Honestly, I haven't figured out the difference between OnGenericMessage and OnMessage yet
* A MessageEvent seems to be more useful though, because I can tell what channel it came from
* @param event MessageEvent given when someone says something on a channel the bot is in
*/
@Override
public void onMessage(MessageEvent event){
parseInvite(event);
parseRemind(event);
parsePing(event);
parseSource(event);
parsePart(event);
String message = event.getMessage();
if (message.toLowerCase().startsWith(bot_nick.toLowerCase())) {
String query = message;
if (!query.isEmpty()) {
query = Swiggityspeare_utils.trimNick(query, bot_nick); //trim off `swiggityspeare` from input
if(include_nick_in_query) query = event.getUser().getNick() + ": " + query;
String response = Swiggityspeare_utils.getString(query, neuralNetworkDirectory, neuralNetworkFile);
event.respond(response);
}
}
}
示例4: onMessage
import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
@Override
public void onMessage(MessageEvent event) throws Exception {
if (event.getMessage().startsWith(Helix.botPrefix + Commands.addCmd + " ") && event.getMessage().length() > (Commands.addCmd.length() + 2) && admins.contains(Util.getLogin(event.getUser())) && Util.isVerified(event.getUser())) {
String s[] = event.getMessage().split(" ", 3);
if (Helix.hardCommands.contains(s[1].toLowerCase())) {
event.respond("Can't override hardcoded commands!");
return;
}
Helix.commands.put(s[1].toLowerCase(), s[2]);
try {
BufferedWriter wr = new BufferedWriter(new FileWriter("commands.json", false));
wr.write(Helix.commands.toString(4));
wr.flush();
wr.close();
} catch (IOException e) {
event.respond(Colors.BOLD + Colors.MAGENTA + "Warning! Failed to save commands.");
e.printStackTrace();
}
}
}
示例5: onMessage
import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
@Override
public void onMessage(MessageEvent<PircBotX> event) throws Exception {
String message = event.getMessage();
if (message.charAt(0) == config.getPrefix()) {
int spaceIdx = message.indexOf(' ');
String command = spaceIdx > -1 ? message.substring(1, spaceIdx) : message.substring(1);
Command c = Command.fromString(command);
if (c != null) {
c.handleCommand(event);
} else if (config.isSendNoSuchCommand()) {
event.respond("No such command");
}
} else {
String formatted = config.getPrivmsgFormatString()
.replace("{user}", jsonEscape(event.getUser().getNick()))
.replace("{message}", jsonEscape(message));
ObfuscationHelper.sendMessageFromJson(formatted);
}
}
示例6: exeChan
import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
public void exeChan(MessageEvent event, String[] args) throws Exception {
int rateScale = 5;
try{
rateScale = Integer.parseInt(args[args.length - 1]);
event.respond("I rate " + Utils.arrayToString(Utils.trimArray(args, 1)) + " a " + Utils.getRandomNumber(rateScale, false) + " out of " + rateScale + ".");
}catch(NumberFormatException e){
event.respond("I rate " + Utils.arrayToString(args) + " a " + Utils.getRandomNumber(5, false) + " out of 5.");
}
}
示例7: exeChan
import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
public void exeChan(MessageEvent event, String[] args) throws Exception {
String song = Utils.arrayToString(Utils.trimArray(args, 0));
for(int i = 0; i < FileUtils.getNumberOfLinesInFile(linkFilePath); i++) {
if(FileUtils.readLineFromFile(linkFilePath, i + 1).startsWith(song)) {
event.respond("Enjoy! " + FileUtils.readLineFromFile(linkFilePath, i + 1).replace(song + " | ", ""));
break;
}
}
}
示例8: exeChan
import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
public void exeChan(MessageEvent event, String[] args) throws Exception {
if(args.length > 0) {
event.respond("This command doesn't use any parameters!");
return;
}
int numberOfResponses = FileUtils.getNumberOfLinesInFile(quotesFilePath);
Utils.sendMessage(event, FileUtils.readLineFromFile(quotesFilePath, Utils.getRandomNumber(numberOfResponses, true)));
}
示例9: exeChan
import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
public void exeChan(MessageEvent event, String[] args) throws Exception {
String target = Utils.arrayToString(Utils.trimArray(args, 0));
int numberOfResponses = FileUtils.getNumberOfLinesInFile(responseFilePath);
String response = FileUtils.readLineFromFile(responseFilePath, Utils.getRandomNumber(numberOfResponses, true)).replaceAll("#C", target.substring(0, 1).toUpperCase() + target.substring(1)).replaceAll("#", target);
event.respond(response);
}
示例10: exeChan
import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
public void exeChan(MessageEvent event, String[] args) throws Exception {
if(args.length == 0){
event.respond("Here's a " + Reference.cookieTypes[Utils.getRandomNumber(Reference.cookieTypes.length, true)] + " cookie for you!");
}else if(args.length == 1){
Utils.sendMessage(event, args[0] + ", here's a " + Reference.cookieTypes[Utils.getRandomNumber(Reference.cookieTypes.length, true)] + " cookie for you!");
}
}
示例11: handleCommand
import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
@Override
public void handleCommand(String sender, MessageEvent event, String command, String[] args) {
String filter = null;
switch (command) {
case ".google":
case ".g":
break;
case ".curseforge":
case ".cf":
filter = "site:minecraft.curseforge.com";
break;
case ".wiki":
filter = "wiki";
break;
case ".urban":
filter = "site:urbandictionary.com";
break;
case ".devbukkit":
case ".db":
filter = "site:dev.bukkit.org";
break;
case ".ann":
filter = "site:animenewsnetwork.com";
break;
case ".github":
case ".gh":
filter = "site:github.com";
break;
case ".define":
filter = "site:en.wiktionary.com";
break;
default:
return;
}
event.respond(performSearch(filter, StringUtils.join(args, " ")));
}
示例12: 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)");
}
}
}
示例13: onMessage
import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
@Override
public void onMessage(MessageEvent event) throws Exception {
if (event.getMessage().startsWith(Helix.botPrefix + Commands.shorthenLink + " ") && (event.getMessage().length() > (Commands.shorthenLink.length() + 2))) {
String q = event.getMessage().split(Helix.botPrefix + Commands.shorthenLink + " ", 2)[1];
try {
String l = (new JSONObject(Util.getHTTPResponse("https://api.waa.ai/shorten?url=" + URLEncoder.encode(q, "UTF-8") + "&key=" + Helix.properties.getProperty("waaai.apikey")))).getJSONObject("data").getString("url");
event.respond(l);
} catch (JSONException | IOException e) {
event.respond("Invalid link!");
}
}
}
示例14: displayTrendingList
import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
public void displayTrendingList(String[][] topWords, int count,
MessageEvent<MyPircBotX> event) {
String response = "Trending Words (24 Hours): ";
//for (Entry<String, Integer> entry : topWords.entrySet()) {
for (int i = 0; i<count;i++){
String block = (topWords[i][0] + ":" + topWords[i][1]+ " ");
response= response + block;
}
event.respond(response);
}
示例15: onMessage
import org.pircbotx.hooks.events.MessageEvent; //导入方法依赖的package包/类
@Override
public void onMessage (MessageEvent e) throws Exception {
String message = e.getMessage();
String sender = e.getUser().getNick();
//nick change
if (message.startsWith(prefix + "nick")) {
if (sender.equals(masterUser)) {
String newNick = message.split(" ")[1];
e.respondWith("As you wish, my master");
e.getBot().sendIRC().changeNick(newNick);
actualBotName = newNick;
} else {
e.respond("You little bitch can't change me!");
}
}
//set nick back to the one specified in the config file
if (message.startsWith(prefix + "resetnick")) {
if (sender.equals(masterUser)) {
e.respondWith("I'm glad you want to let me be my true self :-)");
e.getBot().sendIRC().changeNick(defaultBotName);
actualBotName = defaultBotName;
} else {
e.respond("Nope");
}
}
// /me commands
if (message.startsWith(prefix + "act")) {
if (sender.equals(masterUser)) {
String where = message.split(" ") [1];
String action = message.substring((prefix + "act " + where + " ").length());
e.getBot().sendIRC().action(where, action);
} else {
e.respond("You sure can't tell me what to do >:( ");
}
}
//identify with nickserv
if (message.equalsIgnoreCase(prefix + "identify")) {
e.getBot().sendIRC().identify(password);
e.respond("I should now be identified!");
}
}