Interface SocialPlatform

All Known Implementing Classes:
BlueskyPlatform

public interface SocialPlatform
A social media platform the bot can post to and read activity from

A platform is registered in SocialPlatformRegistry. SocialPoller calls fetch(SocialPollType, String) for each of its poll types and fires the social events, and ./core/social.js provides the chat command, automatic posts and repost rewards for every platform. The settings of a platform are kept in the database table named after its id.

Methods that send requests block, so scripts should call them from a timer rather than from an event hook

Author:
mcawful
  • Method Details

    • getId

      String getId()
      Returns the id of the platform, used as its database table, its lang key prefix and its registry key
      Returns:
      the lowercase id, such as bluesky
    • getDisplayName

      String getDisplayName()
      Returns the name of the platform as shown to users
      Returns:
      the display name, such as Bluesky
    • getModuleScript

      String getModuleScript()
      Returns the script of the chat module for this platform
      Returns:
      the module script path, such as ./handlers/blueskyHandler.js
    • getDiscordModuleScript

      String getDiscordModuleScript()
      Returns the script of the Discord module for this platform
      Returns:
      the module script path, such as ./discord/handlers/blueskyHandler.js
    • isConfigured

      boolean isConfigured()
      Indicates if credentials for the platform are present
      Returns:
      true if an account is linked
    • getAccountName

      String getAccountName()
      Returns the name of the linked account
      Returns:
      the account name, such as a handle; an empty string if no account is linked
    • getProfileUrl

      String getProfileUrl()
      Returns the web address of the linked account's profile
      Returns:
      the profile URL; an empty string if no account is linked
    • getPollTypes

      List<SocialPollType> getPollTypes()
      Returns the kinds of activity the platform can be polled for
      Returns:
      the poll types
    • fetch

      SocialFetchResult fetch(SocialPollType type, String watermark) throws Exception
      Fetches the activity of one poll type that is newer than the watermark
      Parameters:
      type - the poll type
      watermark - the watermark returned by the previous fetch; null on the first fetch, which only needs to return a watermark
      Returns:
      the new items, newest first, and the new watermark
      Throws:
      Exception - if the activity could not be fetched
    • createPost

      SocialPostResult createPost(String text, SocialLinkCard card, boolean truncate)
      Creates a post on the linked account
      Parameters:
      text - the text of the post
      card - a link card to attach; null for none
      truncate - if true, text that is too long is shortened; otherwise the post is refused
      Returns:
      the result
    • resolveAccountId

      String resolveAccountId(String accountName)
      Looks up the permanent id of an account
      Parameters:
      accountName - the account name, such as a handle
      Returns:
      the account id; null if the account was not found
    • link

      SocialPostResult link(String account, String secret, String service)
      Checks the credentials and, if they work, saves them to the bot properties
      Parameters:
      account - the account name
      secret - the password or token
      service - the address of the service to sign in to; empty for the default
      Returns:
      the result; on success, SocialPostResult.url() is the profile URL
    • unlink

      void unlink()
      Removes the saved credentials and ends the session
    • shutdown

      void shutdown()
      Releases resources on shutdown