Closed bilago closed 1 year ago
If this documentation helps: https://dev.twitch.tv/docs/v5/reference/users#check-user-follows-by-channel
It's not easy to add this natively without using a 3rd party API and we try not to do that. Adding Twitch API support is on the backlog and the extent of that integration is not yet decided.
You could add this functionality currently using API GET
and If
statements to check the response.
I've implemented the chat control commands in Kruiz Control as suggested by @Kruiser8
###################################################################################################################################
# Twitch User
# - Save your Twitch username in /settings/twitch/user.txt
#
# User Token
# - Create a user token here https://twitchtokengenerator.com/
# - Save the API oauth token in /settings/twitch/user-bearer.txt
# - Save the Client-ID in /settings/twitch/user-clientid.txt
# - Save the Refresh token in /settings/twitch/user-refresh.txt
#
# App Token
# - Create an App here https://dev.twitch.tv/console/apps
# - Save the Secret the API oauth token in /settings/twitch/app-secret.txt
# - Save the Client-ID /settings/twitch/app-clientid.txt
###################################################################################################################################
OnInit
# User
API GET "./settings/twitch/user.txt"
Function 'return {api_data: [api_data].trim()}'
Variable Set twitchUser {api_data}
API GET "https://decapi.me/twitch/id/{twitchUser}"
Function 'return {api_data: [api_data].trim()}'
Variable Set twitchUserID {api_data}
# User Token
API GET "./settings/twitch/user-bearer.txt"
Function 'return {api_data: [api_data].trim()}'
Variable Set twitchUserToken {api_data}
API GET "./settings/twitch/user-clientid.txt"
Function 'return {api_data: [api_data].trim()}'
Variable Set twitchUserClientID {api_data}
API GET "./settings/twitch/user-refresh.txt"
Function 'return {api_data: [api_data].trim()}'
Variable Set twitchUserRefresh {api_data}
ValidateUserToken
OnAction ValidateUserToken
Variable Load twitchUserToken
API Clear APIUserTokenValidate
API URL APIUserTokenValidate "https://id.twitch.tv/oauth2/validate"
API Method APIUserTokenValidate GET
API Header APIUserTokenValidate "Authorization" "Bearer {twitchUserToken}"
API Send APIUserTokenValidate
If 1 {api_data} = "error"
Chat Send "Twitch API User Token invalid ⛔ Time to get a new one 🪪"
OnCommand bm 0 !announce
Action ChatAnnouncement {after}
OnAction ChatAnnouncement
Variable Set action_name "ChatAnnouncement"
If 2 {in1} = ""
Error "{action_name} was not provided an announcement"
Exit
Variable Load twitchUserID
Variable Load twitchUserToken
Variable Load twitchUserClientID
API Clear APIChatAnnouncement
API URL APIChatAnnouncement "https://api.twitch.tv/helix/chat/announcements?broadcaster_id={twitchUserID}&moderator_id={twitchUserID}"
API Method APIChatAnnouncement POST
API Header APIChatAnnouncement "Authorization" "Bearer {twitchUserToken}"
API Header APIChatAnnouncement "Client-Id" "{twitchUserClientID}"
API Data APIChatAnnouncement "message" "{in1}"
API Send APIChatAnnouncement
If 1 {api_data} = "error"
Error "{action_name} failed while calling Twitch API"
OnCommand b 0 !emoteonly !emotemode !emotechat
Chat Send "🙂 Emote Only Chat enabled"
Action EmoteChat true
OnCommand b 0 !emoteonlyoff !emotemodeoff !emotechatoff
Chat Send "🙂 Emote Only Chat disable"
Action EmoteChat false
OnAction EmoteChat
Variable Set action_name "EmoteChat"
Param Exists in1
If 2 {exists} = "false"
Error "{action_name} was not provided a state"
Exit
Variable Load twitchUserID
Variable Load twitchUserToken
Variable Load twitchUserClientID
API Clear APIEmoteChat
API URL APIEmoteChat "https://api.twitch.tv/helix/chat/settings?broadcaster_id={twitchUserID}&moderator_id={twitchUserID}"
API Method APIEmoteChat PATCH
API Header APIEmoteChat "Authorization" "Bearer {twitchUserToken}"
API Header APIEmoteChat "Client-Id" "{twitchUserClientID}"
API Data APIEmoteChat "emote_mode" "{in1}"
API Send APIEmoteChat
If 1 {api_data} = "error"
Error "{action_name} failed set to {in1} while calling Twitch API"
OnCommand b 0 !followersonly !followeronly !followmode !followchat !followermode !followerchat
Chat Send "💖 Follower Only Chat enabled"
Action FollowerChat true
OnCommand b 0 !followersonlyoff !followeronlyoff !followmodeoff !followchatoff
Chat Send "💖 Follower Only Chat disabled"
Action FollowerChat false
OnAction FollowerChat
Variable Set action_name "FollowerChat"
Param Exists in1
If 2 {exists} = "false"
Error "{action_name} was not provided a state"
Exit
Variable Load twitchUserID
Variable Load twitchUserToken
Variable Load twitchUserClientID
API Clear APIFollowerChat
API URL APIFollowerChat "https://api.twitch.tv/helix/chat/settings?broadcaster_id={twitchUserID}&moderator_id={twitchUserID}"
API Method APIFollowerChat PATCH
API Header APIFollowerChat "Authorization" "Bearer {twitchUserToken}"
API Header APIFollowerChat "Client-Id" "{twitchUserClientID}"
API Data APIFollowerChat "follower_mode" "{in1}"
API Send APIFollowerChat
If 1 {api_data} = "error"
Error "{action_name} failed set to {in1} while calling Twitch API"
OnCommand b 0 !slow !slowchat !slowmode
Chat Send "🐢 Slow Chat enabled"
Action SlowChat true
OnCommand b 0 !slowoff !slowchatoff !slowmodeoff
Chat Send "🐢 Slow Chat disabled"
Action SlowChat false
OnAction SlowChat
Variable Set action_name "SlowChat"
Param Exists in1
If 2 {exists} = "false"
Error "{action_name} was not provided a state"
Exit
Variable Load twitchUserID
Variable Load twitchUserToken
Variable Load twitchUserClientID
API Clear APISlowChat
API URL APISlowChat "https://api.twitch.tv/helix/chat/settings?broadcaster_id={twitchUserID}&moderator_id={twitchUserID}"
API Method APISlowChat PATCH
API Header APISlowChat "Authorization" "Bearer {twitchUserToken}"
API Header APISlowChat "Client-Id" "{twitchUserClientID}"
API Data APISlowChat "slow_mode" "{in1}"
API Send APISlowChat
If 1 {api_data} = "error"
Error "{action_name} failed set to {in1} while calling Twitch API"
OnCommand b 0 !subscribersonly !subscriberonly !submode !subchat
Chat Send "🤑 Subscriber Only Chat enabled"
Action SubscriberChat true
OnCommand b 0 !subscribersonlyoff !subscriberonlyoff !submodeoff !subchatoff
Chat Send "🤑 Subscriber Only Chat disabled"
Action SubscriberChat false
OnAction SubscriberChat
Variable Set action_name "SubscriberChat"
Param Exists in1
If 2 {exists} = "false"
Error "{action_name} was not provided a state"
Exit
Variable Load twitchUserID
Variable Load twitchUserToken
Variable Load twitchUserClientID
API Clear APISubscriberChat
API URL APISubscriberChat "https://api.twitch.tv/helix/chat/settings?broadcaster_id={twitchUserID}&moderator_id={twitchUserID}"
API Method APISubscriberChat PATCH
API Header APISubscriberChat "Authorization" "Bearer {twitchUserToken}"
API Header APISubscriberChat "Client-Id" "{twitchUserClientID}"
API Data APISubscriberChat "subscriber_mode" "{in1}"
API Send APISubscriberChat
If 1 {api_data} = "error"
Error "{action_name} failed set to {in1} while calling Twitch API"
OnCommand b 0 !uniquechat !r9k !r9kbeta
Chat Send "🦄 Unique Chat enabled"
Action UniqueChat true
OnCommand b 0 !uniquechatoff !r9koff !r9kbetaoff
Chat Send "🦄 Unique Chat disabled"
Action UniqueChat false
OnAction UniqueChat
Variable Set action_name "UniqueChat"
Param Exists in1
If 2 {exists} = "false"
Error "{action_name} was not provided a state"
Exit
Variable Load twitchUserID
Variable Load twitchUserToken
Variable Load twitchUserClientID
API Clear APIUniqueChat
API URL APIUniqueChat "https://api.twitch.tv/helix/chat/settings?broadcaster_id={twitchUserID}&moderator_id={twitchUserID}"
API Method APIUniqueChat PATCH
API Header APIUniqueChat "Authorization" "Bearer {twitchUserToken}"
API Header APIUniqueChat "Client-Id" "{twitchUserClientID}"
API Data APIUniqueChat "unique_chat_mode" "{in1}"
API Send APIUniqueChat
If 1 {api_data} = "error"
Error "{action_name} failed set to {in1} while calling Twitch API"
OnCommand bm 0 !clear
Action DeleteChatMessages
OnAction DeleteChatMessages
Variable Set action_name "DeleteChatMessages"
Variable Load twitchUserID
Variable Load twitchUserToken
Variable Load twitchUserClientID
API Clear APIDeleteChatMessages
API URL APIDeleteChatMessages "https://api.twitch.tv/helix/moderation/chat?broadcaster_id={twitchUserID}&moderator_id={twitchUserID}"
API Method APIDeleteChatMessages DELETE
API Header APIDeleteChatMessages "Authorization" "Bearer {twitchUserToken}"
API Header APIDeleteChatMessages "Client-Id" "{twitchUserClientID}"
API Send APIDeleteChatMessages
If 1 {api_data} = "error"
Error "{action_name} failed while calling Twitch API"
This is added in the upcoming release.
As a twitch streamer, I would like the ability to limit the use of certain commands to those who are following the channel. Currently based on the documentation, this isn't available.