當前位置: 首頁>>代碼示例>>Java>>正文


Java Message.getContent方法代碼示例

本文整理匯總了Java中net.dv8tion.jda.core.entities.Message.getContent方法的典型用法代碼示例。如果您正苦於以下問題:Java Message.getContent方法的具體用法?Java Message.getContent怎麽用?Java Message.getContent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.dv8tion.jda.core.entities.Message的用法示例。


在下文中一共展示了Message.getContent方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: commandParser

import net.dv8tion.jda.core.entities.Message; //導入方法依賴的package包/類
public static Optional<Scanner> commandParser(Message message) {
    boolean pm = message.getChannelType().equals(ChannelType.PRIVATE);
    if (!botMentioned(message) && !pm) {
        return Optional.empty();
    }
    Scanner scanner = new Scanner(message.getContent());
    if (pm) {
        // skip the bot prefix if used
        if (scanner.hasNext(BotConfig.getConfig().PREFIX)) {
            scanner.next();
        }
        System.out.println("Mentioned with prefix: " + "private message");
    } else {
        String botPrefix = scanner.next();
        System.out.println("Mentioned with prefix: " + botPrefix);
    }
    return Optional.of(scanner);
}
 
開發者ID:BlackCraze,項目名稱:GameResourceBot,代碼行數:19,代碼來源:CommandUtils.java

示例2: onGuildMessageReceived

import net.dv8tion.jda.core.entities.Message; //導入方法依賴的package包/類
@Override
public void onGuildMessageReceived(GuildMessageReceivedEvent event)
{
    //TODO: Automod!
    /*
    Want the following:
        * Configurable auto deleting of links and file uploads
        * Whitelist/Blacklist for links and bad words
        * Regex on bad words (print to the log what words were matched in the message
        * Configurable muting when someone's done bad enough things:
            * Posted too many bad words within X time (default 5mins?)
            * Posted too many messages (configurable) within X time (default 5 messages in 2s?)
            * Posted too many duplicate characters in a message (default >60% similar characters in a message?)
     */

    Message message = event.getMessage();
    User author = message.getAuthor();

    //Ignore Admins and Moderators
    if(MDCBot.isMemberBotModerator(event.getGuild().getMember(author)))
        return;

    String content = message.getContent();
    TextChannel channel = event.getChannel();
    String channelName = channel.getName();

    if(checkLinks(channelName, message))
        deleteMessage(message, "Deleted message containing link from member %s (%s) in %s (%s):%s", author.getAsMention(), author.getName(), channel.getAsMention(), channelName, content);

    if(checkFiles(channelName, message))
    {
        StringBuilder sb = new StringBuilder();
        for(Message.Attachment a : message.getAttachments())
            sb.append("\n").append(a.getUrl());
        deleteMessage(message, "Deleted file posted by member %s (%s) in %s (%s):%s", author.getAsMention(), author.getName(), channel.getAsMention(), channelName, sb.toString());
    }

    if(checkSpamCharacters(channelName, content))
        deleteMessage(message, "Deleted message containing spammed characters from member %s (%s) in %s (%s):%s", author.getAsMention(), author.getName(), channel.getAsMention(), channelName, content);

    if(checkSpamMessages(channelName, message))
        for(Message m : messageSpamCache.get(author.getIdLong()))
            deleteMessage(m, "Deleted message due to spam from member %s (%s) in %s (%s):%s", author.getAsMention(), author.getName(), channel.getAsMention(), channelName, m.getContent());

    if(checkBadWords(channelName, content))
        deleteMessage(message, "Deleted message due to bad words from member %s (%s) in %s (%s):%s", author.getAsMention(), author.getName(), channel.getAsMention(), channelName, content);
}
 
開發者ID:thebrightspark,項目名稱:MDC-Discord-Bot,代碼行數:48,代碼來源:AutomodListener.java

示例3: step

import net.dv8tion.jda.core.entities.Message; //導入方法依賴的package包/類
/**
 * Step through the options
 * @param msg {@link Message} that triggered this
 */
public void step(Message msg) {
	if (msg.getContent().equalsIgnoreCase("exit")) {
		exit();
		return;
	}
	if (msg.getContent().equalsIgnoreCase(this.getBreakOut()) 
			&& getTypes()[getCurrentStep()].equals(StepType.REPEATER)) {
		incrementStep();
		if (getCurrentStep() >= getSteps().length) {
			finish();
			return;
		}
	}
	switch(getTypes()[getCurrentStep()]) {
	case STRING:
		addResponse(msg.getContent());
		break;
	case INTEGER:
		if (Util.isInteger(msg.getContent())) {
			addResponse(Integer.parseInt(msg.getContent()));
		} else {
			sendMessage("Error: Not a valid numerical input\n" + getSteps()[getCurrentStep()]);
			return;
		}
		break;
	case DOUBLE:
		if (Util.isDouble(msg.getContent())) {
			addResponse(Double.parseDouble(msg.getContent()));
		} else {
			sendMessage("Error: Not a valid decimal input\n" + getSteps()[getCurrentStep()]);
			return;
		}
		break;
	case REPEATER:
		addResponse(msg.getContent());
		sendMessage(getSteps()[getCurrentStep()] + " (to finish, respond with \"" + getBreakOut() + "\")");
		return;
	case YES_NO:
		String s = msg.getContent();
		if (s.equalsIgnoreCase("y") || s.equalsIgnoreCase("yes")) {
			addResponse(true);
		} else if (s.equalsIgnoreCase("n") || s.equalsIgnoreCase("no")) {
			addResponse(false);
		} else {
			sendMessage("Invalid yes/no answer: Please use \"y\" or \"n\"\n" + getSteps()[getCurrentStep()]);
			return;
		}
		break;
	}
	if (getDeletePrevious()) {
		previousEmbed.delete().queue();
	}
	if (getCurrentStep() + 1 >= getSteps().length) {
		finish();
	} else {
		incrementStep();
		sendMessage(getSteps()[getCurrentStep()]);
	}
}
 
開發者ID:paul-io,項目名稱:momo-2,代碼行數:64,代碼來源:ProceduralCommand.java

示例4: handle

import net.dv8tion.jda.core.entities.Message; //導入方法依賴的package包/類
@Override
public void handle(Message message, Event event, String[] args) throws Throwable {
    Language l = kyoko.getI18n().getLanguage(message.getGuild());

    if (args.length == 1) {
        printUsage(kyoko, l, message.getTextChannel());
    } else {
        String msg = message.getContent();
        if (message.getRawContent().startsWith(mention)) {
            msg = msg.substring(name.length()).trim().substring(args[0].length()).trim().substring(args[1].length());
        } else {
            msg = msg.substring(kyoko.getSettings().getPrefix().length() + args[0].length()).trim().substring(args[1].length());
        }

        // https://github.com/nicolas-raoul/jakaroma

        StringBuffer sb = new StringBuffer();
        String lastTokenToMerge = "";

        List<Token> tokens = tokenizer.tokenize(msg);

        for (Token token : tokens) {
            if (token.getAllFeaturesArray()[0].equals("記號")) {
                sb.append(token.getSurface());
                continue;
            }
            switch (token.getAllFeaturesArray()[1]) {
                case "數":
                case "アルファベット":
                case "サ変接続":
                    sb.append(token.getSurface());
                    continue;
                default:
                    String lastFeature = token.getAllFeaturesArray()[8];
                    if (lastFeature.equals("*")) {
                        sb.append(token.getSurface());
                    } else {
                        String romaji = StringUtil.katakana2romaji(token.getAllFeaturesArray()[8]);

                        if (lastFeature.endsWith("ッ")) {
                            lastTokenToMerge = lastFeature;
                            continue;
                        } else {
                            lastTokenToMerge = "";
                        }

                        /*if ( CAPITALIZE_WORDS == true ) {
                            sb.append(romaji.substring(0, 1).toUpperCase());
                            sb.append(romaji.substring(1));
                        } else {*/
                        if (token.getSurface().equals(token.getPronunciation()))
                            romaji = romaji.toUpperCase();
                        sb.append(romaji);
                        //}
                    }
            }
            sb.append(" ");
        }

        msg = sb.toString();

        if (!msg.isEmpty()) {
            message.getTextChannel().sendMessage(msg).queue();
        } else {
            printUsage(kyoko, l, message.getTextChannel());
        }
    }
}
 
開發者ID:gabixdev,項目名稱:Kyoko,代碼行數:69,代碼來源:RomajiCommand.java


注:本文中的net.dv8tion.jda.core.entities.Message.getContent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。