API_Accounts_Settings - frankischilling/crust GitHub Wiki
Accounts And Settings
These helpers update account state, connection identity, and persisted app preferences.
Account Management
c2.login(token)
Log in with a Twitch token.
c2.logout()
Log out the active account.
c2.add_account(token)
Add another account using a Twitch token.
c2.switch_account(username)
Switch to a saved account by username.
c2.remove_account(username)
Remove a saved account by username.
c2.set_default_account(username)
Set the default saved account.
c2.refresh_auth()
Trigger a refresh of the current authentication state.
Useful callback events:
c2.EventType.Authenticatedc2.EventType.LoggedOutc2.EventType.AccountListUpdatedc2.EventType.AuthExpired
IRC Identity
c2.set_irc_nick(nick)
Set the IRC nickname used by Crust.
c2.set_irc_auth(nickserv_user, nickserv_pass)
Update IRC authentication credentials.
Feature Flags And Shell Preferences
c2.set_beta_features(settings)
settings fields:
kick_enabledirc_enabled
The corresponding callback event, c2.EventType.BetaFeaturesUpdated, also
includes the current IRC NickServ credentials and always-on-top setting because
the runtime emits a broader persisted snapshot than this setter accepts.
c2.set_always_on_top(enabled)
Set the always-on-top preference.
c2.set_theme(theme)
Set the active theme name.
c2.set_chat_ui_behavior(settings)
settings fields:
prevent_overlong_twitch_messagescollapse_long_messagescollapse_long_message_linesanimations_when_focused
c2.set_general_settings(settings)
settings fields:
show_timestampsshow_timestamp_secondsuse_24h_timestampslocal_log_indexing_enabledauto_joinhighlightsignores
The matching event also includes:
desktop_notifications_enabled
c2.set_slash_usage_counts(settings)
settings is a table containing:
usage_counts
Each usage_counts entry includes:
namecount
The Rust parser also accepts command as an alternative to name, but the
event payload always emits name.
c2.set_emote_picker_preferences(settings)
settings fields:
favoritesrecentprovider_boost
c2.set_appearance_settings(settings)
settings fields:
channel_layoutsidebar_visibleanalytics_visibleirc_status_visibletab_styleshow_tab_close_buttonsshow_tab_live_indicatorssplit_header_show_titlesplit_header_show_gamesplit_header_show_viewer_count
c2.set_notification_settings(settings)
settings fields:
desktop_notifications_enabled
Rules And Local Moderation Preferences
c2.set_highlight_rules(rules)
rules is an array of rule tables.
Each rule may include:
patternis_regexcase_sensitiveenabledshow_in_mentionscolorhas_alerthas_soundsound_url
When present, color is a three-item RGB array:
color[1]: redcolor[2]: greencolor[3]: blue
c2.set_filter_records(records)
records is an array of filter tables.
Each record may include:
namepatternis_regexcase_sensitiveenabledchannelscopeactionfilter_sender
action currently maps to:
HideDim
scope currently maps to:
GlobalChannel
When scope is Channel, the emitted callback payload also includes the
resolved channel snapshot table.
c2.set_mod_action_presets(presets)
presets is an array of preset tables.
Each preset may include:
labelcommand_templateicon_url
icon_url is omitted in callback payloads when not set.
Matching Events
Most settings helpers eventually produce one of these callback payloads:
c2.EventType.BetaFeaturesUpdatedc2.EventType.ChatUiBehaviorUpdatedc2.EventType.GeneralSettingsUpdatedc2.EventType.SlashUsageCountsUpdatedc2.EventType.EmotePickerPreferencesUpdatedc2.EventType.AppearanceSettingsUpdatedc2.EventType.HighlightRulesUpdatedc2.EventType.FilterRecordsUpdatedc2.EventType.ModActionPresetsUpdated
Example
local account = c2.current_account()
c2.log(c2.LogLevel.Info, "active account: " .. tostring(account.username or ""))
c2.set_notification_settings({
desktop_notifications_enabled = true,
})