• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ParseMode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中pro.zackpollard.telegrambot.api.chat.message.send.ParseMode的典型用法代码示例。如果您正苦于以下问题:Java ParseMode类的具体用法?Java ParseMode怎么用?Java ParseMode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ParseMode类属于pro.zackpollard.telegrambot.api.chat.message.send包,在下文中一共展示了ParseMode类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onTextMessageReceived

import pro.zackpollard.telegrambot.api.chat.message.send.ParseMode; //导入依赖的package包/类
@Override
public void onTextMessageReceived(TextMessageReceivedEvent event) {

    //This is where we construct a SendableTextMessage
    //You can send any type of SendableMessage
    //The available types of messages can be found here https://github.com/zackpollard/JavaTelegramBot-API/tree/master/src/main/java/pro/zackpollard/telegrambot/api/chat/message/send
    SendableTextMessage sendableMessage = SendableTextMessage.builder()
            .message(event.getContent().getContent())
            .replyTo(event.getMessage())
            .parseMode(ParseMode.MARKDOWN)
            .build();

    //This is how you send a message when you have a chat object.
    //You could also send the message to the same chat by using the following line of code.
    //telegramBot.sendMessage(event.getChat(), sendableMessage);
    event.getChat().sendMessage(sendableMessage, telegramBot);
}
 
开发者ID:zackpollard,项目名称:JavaTelegramBot-API-Examples,代码行数:18,代码来源:EchoListener.java


示例2: check

import pro.zackpollard.telegrambot.api.chat.message.send.ParseMode; //导入依赖的package包/类
private void check() {
    while (true) {
        Reminder reminder = reminderSet.firstEntry().getElement();
        if (!(reminder.getUnixTime() <= System.currentTimeMillis())) {
            return;
        }
        Chat chat = instance.getBot().getChat(reminder.getChatID());
        StringBuilder messageBuilder = new StringBuilder("*You have a new reminder!* \n");

        if (!(chat instanceof IndividualChat)) {
            messageBuilder.append("*Reminder set by* @" + reminder.getUserName() + "\n");
        }

        messageBuilder.append("*Reminder:* ").append(reminder.getReminder());

        SendableTextMessage message = SendableTextMessage.builder()
                .parseMode(ParseMode.MARKDOWN)
                .message(messageBuilder.toString())
                .build();

        instance.getBot().sendMessage(chat, message);
        reminderSet.remove(reminder);
    }
}
 
开发者ID:bo0tzz,项目名称:RemindMeBot,代码行数:25,代码来源:ReminderManager.java


示例3: processCommand

import pro.zackpollard.telegrambot.api.chat.message.send.ParseMode; //导入依赖的package包/类
@Override
public void processCommand(CommandMessageReceivedEvent event) {
    String statusText = "*Scanning new threads...*";

    RedditHandler redditHandler = RedditLiveBot.instance.getRedditHandler();

    // Current bot status
    if (redditHandler.getCurrentLiveThread() != null) {
        statusText = "*Following live thread.* ID: " + redditHandler.getCurrentLiveThread().getThreadID();
    }

    Message message = event.getChat().sendMessage(
            SendableTextMessage.builder()
                    .message(
                            "*Welcome to the RedditLive Admin Control Panel*\n\n" +
                                    "To use the control panel, please click on one of the buttons below.\n\nCurrent Status: " + statusText)
                    .replyMarkup(RedditLiveBot.instance.getAdminControlHandler().getDashboardKeyboardMarkup(event.getChat()))
                    .parseMode(ParseMode.MARKDOWN).build());
}
 
开发者ID:stuntguy3000,项目名称:RedditLiveBot,代码行数:20,代码来源:AdminCommand.java


示例4: live

import pro.zackpollard.telegrambot.api.chat.message.send.ParseMode; //导入依赖的package包/类
public static void live(ReddigramBot bot, Chat chat) {
    List<List<Submission>> submissions = bot.pagesFor("live", Sorting.HOT);
    Message message = chat.sendMessage(SendableTextMessage.plain("Select a live thread to follow:").build());
    InlineMenuBuilder builder = InlineMenu.builder(bot.telegramBot(), chat)
            .message(message);

    submissions.get(0).stream()
            .filter((submission) -> !submission.isStickied())
            .forEach((submission) -> {
                String threadId = bot.liveManager().idFromSubmission(submission);

                if (threadId == null) {
                    return;
                }

                builder.newRow().toggleButton(submission.getTitle())
                        .toggleCallback((button, newValue) -> {
                            // Follow thread and inform the user of that
                            bot.liveManager().subscribeTo(threadId, chat.getId());
                            bot.telegramBot().editMessageText(
                                    message,
                                    "*Following " + threadId + "...*",
                                    ParseMode.MARKDOWN,
                                    false, null
                            );
                            return null;
                        })
                        .build().build();
            });

    InlineMenu menu = builder.buildMenu();

    bot.registerMenu(menu);
    menu.apply();
}
 
开发者ID:mkotb,项目名称:Reddigram,代码行数:36,代码来源:LiveCommands.java


示例5: follow

import pro.zackpollard.telegrambot.api.chat.message.send.ParseMode; //导入依赖的package包/类
public static void follow(ReddigramBot bot, String[] args, Chat chat) {
    if (args.length == 0) {
        // prompt them for a thread id to follow
        Message message = chat.sendMessage(SendableTextMessage.plain("Please send the live thread id you wish to follow (like yeitdh0583mc)\n" +
                "You can also send a link like https://reddit.com/live/yeitdh0583mc")
                .disableWebPagePreview(true).build());

        Conversation.builder(bot.telegramBot()).forWhom(chat)
                .silent(true)
                .prompts()
                .first(new ThreadIdPrompt(bot, (id) -> {
                    bot.liveManager().subscribeTo(id, chat.getId());
                    bot.telegramBot().editMessageText(
                            message,
                            "*Following " + id + "...*",
                            ParseMode.MARKDOWN,
                            false, null
                    );
                })).end()
                .build()
                .begin();
        return;
    }

    String threadId = bot.liveManager().idFromInput(args[0]);

    if (threadId == null) {
        chat.sendMessage(SendableTextMessage.plain("Please send a valid live thread id or link (like yeitdh0583mc or https://reddit.com/live/yeitdh0583mc)")
                .disableWebPagePreview(true).build());
        return;
    }

    bot.liveManager().subscribeTo(threadId, chat.getId());
    chat.sendMessage(SendableTextMessage.markdown("*Following " + threadId + "...*").build());
}
 
开发者ID:mkotb,项目名称:Reddigram,代码行数:36,代码来源:LiveCommands.java


示例6: about

import pro.zackpollard.telegrambot.api.chat.message.send.ParseMode; //导入依赖的package包/类
private void about(CommandMessageReceivedEvent event) {
    event.getChat().sendMessage(SendableTextMessage.builder()
                    .message("This bot was created by @bo0tzz using the @JavaTelegramBotAPI. The source is available on [GitHub](https://github.com/bo0tzz/RemindMeBot)")
                    .parseMode(ParseMode.MARKDOWN)
                    .build()
            );
}
 
开发者ID:bo0tzz,项目名称:RemindMeBot,代码行数:8,代码来源:RemindMeBotListener.java


示例7: help

import pro.zackpollard.telegrambot.api.chat.message.send.ParseMode; //导入依赖的package包/类
private void help(CommandMessageReceivedEvent event) {
    event.getChat().sendMessage(SendableTextMessage.builder()
                    .message("This bot allows you to set reminders. The bot will send you a message on the time you specified, with your reminder. You can specify everything in a natural sentence, like so:\n" +
                            "/remindme on the 2nd of april to call mom\n" +
                            "/remindme in three hours that I need to start making dinner\n" +
                            "\n" +
                            "Make sure to separate the time and the reminder with either \"that\" or \"to\", to make sure the bot can understand which is which. For more information, type /about.")
                    .parseMode(ParseMode.MARKDOWN)
                    .build()
            );
}
 
开发者ID:bo0tzz,项目名称:RemindMeBot,代码行数:12,代码来源:RemindMeBotListener.java


示例8: remindMe

import pro.zackpollard.telegrambot.api.chat.message.send.ParseMode; //导入依赖的package包/类
private void remindMe(CommandMessageReceivedEvent event) {
    if (event.getArgsString().equals("")) {
        event.getChat().sendMessage("Give me ");
        return;
    }

    String str = event.getArgsString();
    int idx, idx2 = -1;
    if ((idx = str.indexOf(" to ")) != -1 && idx < (idx2 = str.indexOf(" that ")) || idx2 == -1) {
        str = str.replaceFirst(" to ", " that ");
    }
    String[] args = str.split("that", 2);

    if (args.length != 2) {
        event.getChat().sendMessage("Something went wrong while processing your reminder! Please try again");
        return;
    }

    DateGroup date = TimeParser.parse(args[0]);
    if (date == null) {
        event.getChat().sendMessage("It seems that the time you entered doesn't make sense. Please try again!");
        return;
    }

    Reminder reminder = new Reminder(
            date.getDates().get(0).getTime(),
            event.getChat().getId(),
            args[1],
            event.getMessage().getSender().getUsername());
    instance.getReminderManager().addReminder(reminder);

    event.getChat().sendMessage(SendableTextMessage.builder()
        .message(String.format("*New reminder added!* \n*Reminded at:* _%s_ \n*Reminder:* _%s_",
                TimeParser.asString(reminder.getUnixTime()),
                reminder.getReminder()))
        .replyTo(event.getMessage())
        .parseMode(ParseMode.MARKDOWN)
        .build());
}
 
开发者ID:bo0tzz,项目名称:RemindMeBot,代码行数:40,代码来源:RemindMeBotListener.java


示例9: onParticipantJoinGroupChat

import pro.zackpollard.telegrambot.api.chat.message.send.ParseMode; //导入依赖的package包/类
@Override
public void onParticipantJoinGroupChat(ParticipantJoinGroupChatEvent event) {
    if (event.getParticipant().getId() == TelegramHook.getBot().getBotID()) {
        event.getChat().sendMessage(SendableTextMessage.builder()
                .message("*Hello!*\n\nThis is a quick message to let you know that @RedditLiveBot is set to monitor all chat messages. We *do not* store or log any user messages, as this feature is for admin controls only.\n\nIf you have any issues, feel free to contact @stuntguy3000 or view the source from /source.")
                .parseMode(ParseMode.MARKDOWN).disableWebPagePreview(true)
                .build()
        );
    }
}
 
开发者ID:stuntguy3000,项目名称:RedditLiveBot,代码行数:11,代码来源:TelegramEventHandler.java


示例10: postNewLiveThread

import pro.zackpollard.telegrambot.api.chat.message.send.ParseMode; //导入依赖的package包/类
/**
 * Posts a new live thread to the admin chat
 *
 * @param redditThread SubredditChildrenData the data to be posted
 * @param threadID     String the id of the thread
 */
public void postNewLiveThread(SubredditChildrenData redditThread, String threadID) {
    Message message = updateMessages.get(threadID);
    String lastMessage = lastMessages.get(threadID);

    String threadInformation = "*Reddit Live Thread*\n\n" +
            "*Thread ID:* " + threadID + "\n" +
            "*Thread URL:* https://reddit.com/live/" + threadID + "\n" +
            "*Thread Title:* " + redditThread.getTitle() + "\n" +
            "*Score:* " + redditThread.getScore() + "\n";

    List<InlineKeyboardButton> buttons = new ArrayList<>();

    buttons.add(InlineKeyboardButton.builder()
            .callbackData("f," + threadID)
            .text("Follow (Normal)").build());

    buttons.add(InlineKeyboardButton.builder()
            .callbackData("fS," + threadID)
            .text("Follow (Silent)").build());

    if (lastMessage != null && lastMessage.equals(threadInformation)) {
        return;
    }

    if (message == null) {
        message = adminChat.sendMessage("Loading new live thread...");
    }

    message = TelegramHook.getBot().editMessageText(message, threadInformation,
            ParseMode.MARKDOWN, false, InlineKeyboardMarkup.builder().addRow(buttons).build());

    updateMessages.put(threadID, message);
    lastMessages.put(threadID, threadInformation);
}
 
开发者ID:stuntguy3000,项目名称:RedditLiveBot,代码行数:41,代码来源:AdminControlHandler.java


示例11: build

import pro.zackpollard.telegrambot.api.chat.message.send.ParseMode; //导入依赖的package包/类
private static SendableMessage build(String message, Object... format) {
    SendableTextMessage.SendableTextMessageBuilder sendableTextMessageBuilder = SendableTextMessage.builder();
    String formatted = String.format(message, format);
    formatted = rigerousReplace(USERNAME_PATTERN, formatted, "[/u/<r>](https://reddit.com/u/<r>)");
    formatted = rigerousReplace(SUBREDDIT_PATTERN, formatted, "[/r/<r>](https://reddit.com/r/<r>)");

    sendableTextMessageBuilder.message(formatted);
    sendableTextMessageBuilder.parseMode(ParseMode.MARKDOWN);

    return sendableTextMessageBuilder.build();
}
 
开发者ID:stuntguy3000,项目名称:RedditLiveBot,代码行数:12,代码来源:Lang.java


示例12: sendHtml

import pro.zackpollard.telegrambot.api.chat.message.send.ParseMode; //导入依赖的package包/类
public static Message sendHtml(Chat chat, String message, Object... format) {
    Object[] newFormat = new Object[format.length];

    for (int i = 0; i < 3; i++) {
        newFormat[i] = format[i].toString().replace("&", "&amp;").replace("<", "&lt;").replace(">", "&gt;");
    }

    message = String.format(message, newFormat);

    SendableTextMessage.SendableTextMessageBuilder sendableTextMessageBuilder = SendableTextMessage.builder();
    sendableTextMessageBuilder.message(message);
    sendableTextMessageBuilder.parseMode(ParseMode.HTML);

    return TelegramHook.getBot().sendMessage(chat, sendableTextMessageBuilder.build());
}
 
开发者ID:stuntguy3000,项目名称:RedditLiveBot,代码行数:16,代码来源:Lang.java


示例13: processCommand

import pro.zackpollard.telegrambot.api.chat.message.send.ParseMode; //导入依赖的package包/类
public void processCommand(CommandMessageReceivedEvent event) {
    StringBuilder commandHelp = new StringBuilder();

    if (event.getArgs().length > 0) {
        if (event.getArgs()[0].equalsIgnoreCase("subscribe")) {
            new SubscribeCommand().processCommand(event);
            return;
        }
    }

    commandHelp.append("*Welcome to RedditLiveBot*\n" +
            "Created by @stuntguy3000, this bot allows you to stay up to date to trending RedditLive threads. " +
            "All the content is monitored constantly by our administration team, ensuring the content is of a high standard.\n\n" +
            "To begin, type /subscribe in a group chat, or join @RedditLive to stay up to date!\n\n" +
            "*Command help:*\n" +
            "/subscribe - Subscribe to updates from @RedditLive\n" +
            "/unsubscribe - Unsubscribe to updates from @RedditLive\n" +
            "/version - Show bot version information, and provide a link to the source code.");

    List<InlineKeyboardButton> buttons = new ArrayList<>();

    buttons.add(InlineKeyboardButton.builder()
            .text(Emoji.GREEN_BOX_TICK.getText() + " Subscribe")
            .callbackData("usrSubscribe:" + event.getChat().getId())
            .build());

    SendableTextMessage sendableTextMessage = SendableTextMessage.builder()
            .message(commandHelp.toString())
            .parseMode(ParseMode.MARKDOWN)
            .replyMarkup(InlineKeyboardMarkup.builder().addRow(buttons).build())
            .build();

    event.getChat().sendMessage(sendableTextMessage);
}
 
开发者ID:stuntguy3000,项目名称:RedditLiveBot,代码行数:35,代码来源:HelpCommand.java


示例14: sendSubreddit

import pro.zackpollard.telegrambot.api.chat.message.send.ParseMode; //导入依赖的package包/类
public static void sendSubreddit(ReddigramBot bot, Message message, Chat chat, String subreddit, Sorting sorting) {
    List<List<Submission>> paginated = bot.pagesFor(subreddit, sorting);
    // edit the message to contain the contents of the first page

    // create a dummy builder to encase all the pages
    InlineMenuBuilder dummyMenuBuilder = InlineMenu.builder(bot.telegramBot());

    dummyMenuBuilder.forWhom(chat);
    dummyMenuBuilder.message(message);

    List<InlineMenu> menus = new ArrayList<>(paginated.size());

    for (int page = 0; page < paginated.size(); page++) {
        /*
         * Create a menu with one row with one or two buttons
         * depending on if there is a page to go to forward or backward
         */
        SubInlineMenuBuilder menuBuilder = dummyMenuBuilder.subMenu();
        InlineMenuRowBuilder<SubInlineMenuBuilder> row = menuBuilder.newRow();

        if (page != 0) {
            int backMenu = page - 1;

            row.toggleButton("⬅️ Back (" + (page) + "/" + paginated.size() + ")")
                    .toggleCallback((button, value) -> {
                        // move to next menu
                        button.getMenu().unregister();
                        bot.registerMenu(menus.get(backMenu));

                        // edit text to match the page
                        bot.telegramBot().editMessageText(
                                message,
                                bot.messageFor(paginated.get(backMenu)),
                                ParseMode.HTML,
                                true,
                                menus.get(backMenu).toKeyboard()
                        );
                        return null;
                    })
                    .build();
        }

        if (page != 3) {
            int nextMenu = page + 1;

            row.toggleButton("➡️ Next (" + (page + 2) + "/" + paginated.size() + ")")
                    .toggleCallback((button, value) -> {
                        // move to next menu
                        button.getMenu().unregister();
                        bot.registerMenu(menus.get(nextMenu));

                        // edit text and menu to match the page
                        bot.telegramBot().editMessageText(
                                message,
                                bot.messageFor(paginated.get(nextMenu)),
                                ParseMode.HTML,
                                true,
                                menus.get(nextMenu).toKeyboard()
                        );
                        return null;
                    })
                    .build();
        }

        menus.add(row.build().buildMenu());
    }

    // start the menu encasing the menus and unregistering it
    dummyMenuBuilder.buildMenu().unregister();
    // start the first page's menu
    bot.registerMenu(menus.get(0));
    bot.telegramBot().editMessageText(
            message,
            bot.messageFor(paginated.get(0)),
            ParseMode.HTML,
            true,
            menus.get(0).toKeyboard()
    );
    bot.dataFile().statistics().incrementRequests();
}
 
开发者ID:mkotb,项目名称:Reddigram,代码行数:81,代码来源:SubredditCommand.java


示例15: sortingMenu

import pro.zackpollard.telegrambot.api.chat.message.send.ParseMode; //导入依赖的package包/类
public void sortingMenu(Message msg, Chat chat,
                        boolean force, BiConsumer<Message, Sorting> consumer) {
    if (msg == null) {
        msg = chat.sendMessage("Please select a category:");
    } else {
        bot.telegramBot().editMessageText(msg, "Please select a category", ParseMode.NONE, false, null);
    }

    UserData data = bot.dataFile().dataFor(chat.getId());

    if (!force && data != null) {
        if (data.preferredSorting() != null) {
            consumer.accept(msg, data.preferredSorting());
            return;
        }
    }

    Message message = msg;
    InlineMenuBuilder menu = InlineMenu.builder(bot.telegramBot())
            .forWhom(chat)
            .message(message);

    for (Sorting sorting : Sorting.values()) {
        menu.newRow()
                .toggleButton(capitalize(sorting.name().toLowerCase()))
                   .toggleCallback((button, value) -> {
                       button.getMenu().unregister();
                       data.setPreferredSorting(sorting);

                       consumer.accept(message, sorting);
                       bot.dataFile().save();
                       return null;
                   })
                .buildRow();
    }

    InlineMenu m = menu.buildMenu();

    if (msg != null) {
        bot.registerMenu(m);
        bot.telegramBot().editMessageText(msg, "Please select a category", ParseMode.NONE, false, m.toKeyboard());
    } else {
        chat.sendMessage(
                SendableTextMessage.plain("Please select a category").replyMarkup(m.toKeyboard()).build()
        );
    }
}
 
开发者ID:mkotb,项目名称:Reddigram,代码行数:48,代码来源:CommandListener.java


示例16: getParseMode

import pro.zackpollard.telegrambot.api.chat.message.send.ParseMode; //导入依赖的package包/类
/**
 * Gets the ParseMode used for this message
 *
 * @return The ParseMode used for this message
 */
public ParseMode getParseMode() {
    return this.parse_mode;
}
 
开发者ID:zackpollard,项目名称:JavaTelegramBot-API,代码行数:9,代码来源:InputTextMessageContent.java



注:本文中的pro.zackpollard.telegrambot.api.chat.message.send.ParseMode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ServerChunkDataPacket类代码示例发布时间:2022-05-22
下一篇:
Java Permission类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap