Package com.mcawful.social
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 Summary
Modifier and TypeMethodDescriptioncreatePost(String text, SocialLinkCard card, boolean truncate) Creates a post on the linked accountfetch(SocialPollType type, String watermark) Fetches the activity of one poll type that is newer than the watermarkReturns the name of the linked accountReturns the script of the Discord module for this platformReturns the name of the platform as shown to usersgetId()Returns the id of the platform, used as its database table, its lang key prefix and its registry keyReturns the script of the chat module for this platformReturns the kinds of activity the platform can be polled forReturns the web address of the linked account's profilebooleanIndicates if credentials for the platform are presentChecks the credentials and, if they work, saves them to the bot propertiesresolveAccountId(String accountName) Looks up the permanent id of an accountvoidshutdown()Releases resources on shutdownvoidunlink()Removes the saved credentials and ends the session
-
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:
trueif 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
Fetches the activity of one poll type that is newer than the watermark- Parameters:
type- the poll typewatermark- the watermark returned by the previous fetch;nullon 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
Creates a post on the linked account- Parameters:
text- the text of the postcard- a link card to attach;nullfor nonetruncate- iftrue, text that is too long is shortened; otherwise the post is refused- Returns:
- the result
-
resolveAccountId
Looks up the permanent id of an account- Parameters:
accountName- the account name, such as a handle- Returns:
- the account id;
nullif the account was not found
-
link
Checks the credentials and, if they work, saves them to the bot properties- Parameters:
account- the account namesecret- the password or tokenservice- 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
-