Interface Bot


  • public interface Bot
    This class is used to define a Mirai Bot Instance
    • Method Detail

      • relogin

        boolean relogin()
                 throws BotLoginException
        Relogin the bot
        Returns:
        true if the bot is online, false otherwise
        Throws:
        BotLoginException - throw if the bot login failed
      • login

        boolean login()
               throws BotLoginException
        Login the bot
        Returns:
        true if the bot is not online, false otherwise
        Throws:
        BotLoginException - throw if the bot login failed
      • logout

        boolean logout()
        Logout the bot
        Returns:
        true if the bot is online, false otherwise
      • getFriendOrFail

        default @NonNull Friend getFriendOrFail​(long id)
        Get the friend with special id
        Parameters:
        id - the friend id
        Returns:
        the friend with special id
        Throws:
        NullPointerException - throw if the friend with special id does not exist
      • getGroupOrFail

        default @NonNull Group getGroupOrFail​(long id)
        Get the group with special id
        Parameters:
        id - the group id
        Returns:
        the group with special id
        Throws:
        NullPointerException - throw if the group with special id does not exist
      • getGroup

        @Nullable Group getGroup​(long id)
        Get the group with special id
        Parameters:
        id - the group id
        Returns:
        the group with special id
      • getFriend

        @Nullable Friend getFriend​(long id)
        Get the friend with special id
        Parameters:
        id - the friend id
        Returns:
        the friend with special id
      • getFriends

        @NonNull @UnmodifiableView List<Friend> getFriends()
        Get all the friends
        Returns:
        all the friends
      • getGroups

        @NonNull @UnmodifiableView List<Group> getGroups()
        Get all the groups
        Returns:
        all the groups
      • isOnline

        boolean isOnline()
        Indicate the bot is online
        Returns:
        true if the bot is online, false otherwise
      • getAsFriend

        @NonNull Friend getAsFriend()
        Get the bot itself as a friend
        Returns:
        the bot itself as a friend
      • getId

        long getId()
        Get the id of the bot
        Returns:
        the id of the bot
      • isDefaultBot

        boolean isDefaultBot()
        Indicate this is the default bot
        Returns:
        true if this is the default bot, false otherwise
      • getPlugin

        Plugin getPlugin()
        Get the plugin of the bot
        Returns:
        the plugin of the bot
      • isAdministrator

        boolean isAdministrator()
        Indicate this is the Administrator
        Returns:
        true if this is the Administrator, false otherwise
      • isOffline

        default boolean isOffline()
        Indicate the bot is offline
        Returns:
        true if the bot is offline, false otherwise
      • getBotManager

        BotManager getBotManager()
        Get the Bot Manager of the bot
        Returns:
        the Bot Manager of the bot
      • sendMessage

        void sendMessage​(Transmitter transmitter,
                         Message message)
        Send a message to the transmitter
        Parameters:
        transmitter - the transmitter
        message - the message
      • sendMessage

        default void sendMessage​(Transmitter transmitter,
                                 String message)
        Send a string message to the transmitter
        Parameters:
        transmitter - the transmitter
        message - the message
      • uploadImage

        Image uploadImage​(Transmitter transmitter,
                          InputStream resource)
        Upload an image to the transmitter
        Parameters:
        transmitter - the transmitter
        resource - the image resource
        Returns:
        the image message or null if the image is not available
      • uploadAudio

        @Nullable Audio uploadAudio​(Speaker speaker,
                                    InputStream inputStream)
        Upload an audio to the speaker
        Parameters:
        speaker - the speaker
        inputStream - the audio resource
        Returns:
        the audio message or null if the audio is not available
      • deleteFriend

        void deleteFriend​(Friend friend)
        Delete a friend
        Parameters:
        friend - the friend
      • quitGroup

        void quitGroup​(Group group)
        Quit a group
        Parameters:
        group - the group
      • getMember

        @Nullable Member getMember​(Group group,
                                   long id)
        Get the member by its group and id
        Parameters:
        group - the group
        id - the member id
        Returns:
        the member or null if not found
      • getMemberOrFail

        default Member getMemberOrFail​(Group group,
                                       long id)
        Get the member by its group and id
        Parameters:
        group - the group
        id - the member id
        Returns:
        the member
        Throws:
        NullPointerException - if the member is not found
      • getAsMember

        Member getAsMember​(Group group)
        Get the bot as a member in the group
        Parameters:
        group - the group
        Returns:
        the bot as a member in the group
      • getMembers

        List<Member> getMembers​(Group group)
        Get all the members in the group
        Parameters:
        group - the group
        Returns:
        all the members as a list
      • getStranger

        @Nullable Stranger getStranger​(long id)
        Get the stranger by its specific id
        Parameters:
        id - the id
        Returns:
        the stranger or null if not found
      • getStrangerOrFail

        default Stranger getStrangerOrFail​(long id)
        Get the stranger by its specific id
        Parameters:
        id - the id
        Returns:
        the stranger
        Throws:
        NullPointerException - if the stranger is not found
      • getOtherClientOrFail

        default OtherClient getOtherClientOrFail​(long id)
        Get the other client by its specific id
        Parameters:
        id - the id
        Returns:
        the other client
        Throws:
        NullPointerException - if the other client is not found
      • getOtherClient

        @Nullable OtherClient getOtherClient​(long id)
        Get the other client by its specific id
        Parameters:
        id - the id
        Returns:
        the other client or null if not found