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


Java Chat.sendMessage方法代码示例

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


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

示例1: live

import pro.zackpollard.telegrambot.api.chat.Chat; //导入方法依赖的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

示例2: follow

import pro.zackpollard.telegrambot.api.chat.Chat; //导入方法依赖的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

示例3: unfollow

import pro.zackpollard.telegrambot.api.chat.Chat; //导入方法依赖的package包/类
public static void unfollow(ReddigramBot bot, Chat chat) {
    LiveFollower follower = bot.liveManager().threadBy(chat.getId());

    if (follower == null) {
        chat.sendMessage("You are not following any threads!");
        return;
    }

    bot.liveManager().unsubscribe(follower.threadId(), chat.getId());
    chat.sendMessage("Unfollowing " + follower.threadId() + "!");
}
 
开发者ID:mkotb,项目名称:Reddigram,代码行数:12,代码来源:LiveCommands.java

示例4: sortingMenu

import pro.zackpollard.telegrambot.api.chat.Chat; //导入方法依赖的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

示例5: sendToMazen

import pro.zackpollard.telegrambot.api.chat.Chat; //导入方法依赖的package包/类
public void sendToMazen(String message) {
    Chat chat = bot.getChat(-1001000055116L);
    if (chat != null)
        chat.sendMessage(message);
}
 
开发者ID:bo0tzz,项目名称:TopKekBot,代码行数:6,代码来源:TopKekBot.java

示例6: forwardMessage

import pro.zackpollard.telegrambot.api.chat.Chat; //导入方法依赖的package包/类
/**
 * A simple method which allows you to forward this Message to another chat simply by providing a Chat object
 *
 * @param chat The Chat you want to send the Message to
 *
 * @return The Message object corresponding to the forwarded version of the original Message
 */
default Message forwardMessage(Chat chat) {

    return chat.sendMessage(SendableForwardMessage.builder().forwardedMessage(this).build());
}
 
开发者ID:zackpollard,项目名称:JavaTelegramBot-API,代码行数:12,代码来源:Message.java


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