TwitchLinkGuard - Block unwanted links
TwitchLinkGuard is designed to help Twitch streamers and moderators maintain a safe and clean chat environment. TLG provides comprehensive tools for automated moderation, making it an essential solution for Twitch streamers looking to enhance and streamline their chat moderation. Its robust features and easy customization make it ideal for maintaining a safe and engaging community.
Key Features:
- URL Detection and Filtering:
- Optimized Regex Patterns: Quickly identify URLs with precompiled regular expressions.
- Whitelist Support: Exempt trusted domains from moderation.
- Observed TLDs: Filter URLs with questionable top-level domains.
- Failure Safe: URLs not explicitly flagged by the script will be ignored, ensuring users who accidentally write URL-like messages are not penalized (e.g., â
hi.how
â, âoh...my
â).
- Voucher Code Detection:
- Automatic Identification: Recognize voucher, gaming key codes, or promo codes.
- User Sanctioning: Warn or ban users sharing unwanted code patterns.
- Obfuscation Detection:
- Hidden Links: Spot intentionally obfuscated URLs (e.g., â
example [dot] com
â) to prevent spam and phishing.
- Hidden Links: Spot intentionally obfuscated URLs (e.g., â
- User Group Exemptions:
- Group-Based Rules: Allow specific and optional multiple groups (e.g., â
VIPs
â, âTLG-TrustedUsers
â) to bypass moderation. - Temporary Exemptions: Temporarily grant permissions to users within a specified time limit.
- Group-Based Rules: Allow specific and optional multiple groups (e.g., â
- Keyword Filtering:
- Filter Customization: Define and monitor a set of customizable keywords and TLDs as action indicators.
- Accurate Matching: Reduce false positives with exact matches and word boundaries.
- Twitch Integration:
- Automated Actions: Delete messages, send alerts, or ban users through the Twitch API.
- Twitch Warn System: Issue optional warnings for rule violations.
- Custom Messages:
- Templates: Create personalized messages for different moderation actions.
- Appearance: Choose the account and writing style for response messages.
Example:
TwitchLinkGuard works with stable
and beta
branch of streamer.bot
Import File
Full Stable: v4.1
TwitchLinkGuard-v4.1.sb (25.8 KB)
Light Stable: v1
TwitchLinkGuard-Light-v1.sb (16.8 KB)
(only detect real URLs and obfuscated URLs)
Install TwitchLinkGuard
Step 1
Import TwitchLinkGuard
- In Streamer.bot click the
Import
button in the top menu. Drag the .sb file into theImport String
field.
- Enable the
TwitchLinkGuard - PermitUser
command in theCommands
tab.
Step 2
Editing your whitelist is important to keep your viewers safe from getting penalized by the script
Edit TLG-Options
- Edit
%whitelist%
so users can use links from you without being punished by the script. If the argument is missing or disabled, no links will be whitelisted. - Edit
%SuspiciousKeywords%
if you need other words as the default set as example in the value. - Edit
%SuspiciousEndings%
if you need other TLDs (top-level-domain) as the default set as example in the value. %skipVipModeration%
and%skipSubModeration%
keep your VIPs and Subs safe from being handled by the script. If you donât trust all of them, or maybe just some of them, set them to âFalseâ or disable them and use%groupName%
with a specified list to exempt trusted users.
Arguments | Value | Description | Reason |
---|---|---|---|
%useTimeout% | True/False | If you donât wan to ban users directly for violating chat rules | |
%duration% | e.g. 60 | Set the timeout duration in seconds | |
%requiredKeywordCount% | e.g. 2 | Define the amount of detected suspiciousKeywords are needed to trigger a ban/timeout |
suspiciousEndings arenât affected by this |
%useBot% | True | The bot account manages messages, bans, and timeouts. | SB default setting since 0.2.5 |
%useBot% | False | The broadcaster account manages messages, bans, and timeouts. | SB default setting till 0.2.4 |
%sendAction% | True | Messages appear like this in chat | Like twitchâs own â/meâ command |
%sendAction% | False | Messages will appear as a normal text in chat |
|
%useTwitchWarn% | True/False | if True , additionally isse a Twitch âwarnâ for posting links |
Step 3
Edit TLG Messages
Customize the standard messages to translate them into your language or modify them to suit your preferences.
Adjust TLG-PermitUser
Step 1
Edit PermitUser Options
Argument | Value | Description | Info |
---|---|---|---|
useBot | True | The bot account manages messages, bans, and timeouts. | SB default setting since 0.2.5 |
useBot | False | The broadcaster account manages messages, bans, and timeouts. | SB default setting till 0.2.4 |
sendAction | True | Messages appear like this in chat | Like twitchâs own â/meâ command |
sendAction | False | Messages will appear as a normal text in chat |
|
permitTime | e.g. 30 | Define the time a user is allowed to post links | permitTime is always in seconds. |
Step 2
Edit PermitUser Messages
Add {user}
to tag a user directly and {permitTime}
for the specific permitted time.
Argument | Value | Description |
---|---|---|
grantMessage | Informs users to be granted to send links | |
revokeMessage | Informs users when the permitted time is over | |
existingPermissionMessage | Informs if there is already a user permitted | |
Labels | **eg: min, minutes, Minuten, etc. ** | Edit the desired time label after each â=â |
Usable Commands
Command | Example | Description |
---|---|---|
!permit | !permit ExampleUser | A specific user now has âxâ seconds to post a link |
Contributors
Changelog:
Update v4.1
- Logs got a little cleared up.
- Better checks to prevent Helix issues.
- Updated
denyAutoHeldMessage
logic to skip if there is no message waiting for approval.
Older Changelogs
v4
- Changed the behavior of TLG
- TLG now only ban if a certain amount of matching keywords is reached. You can set the amount of keywords needed.
- You can choose if TLG should ban or only timeout users
- Timeout duration is also a matter of your choice.
- Reintroduced the twitch AutoMod Logic that automatically denies messages held back by twitch
- Removed âallowesSpecialCharactersâ logic. i was a little on the wrong track with this system and the goal i tried to reach with it
- The Script got more comments to understand whats going on in case someone wants to tinker with it.
- Log messages got a little unified to find them faster
v3.9
Stable Version
- Added inbuild detection for
Vip
andSubscribers
to be optionally exempt from moderation. Vip
andSubscribers
can be exempt from moderation individually. If a user has both roles, either one of the exemptions will match on'True'
.- Twitch bot account is now exempt by default, regardless of itâs role.
- Globally, URL detection does now look for indicators in messages, rather then banning straight forward for just finding a blacklisted word.
- Since the script normalize any input, you can exempt certain characters from detection e.g.:
Ă, ĂĄ, Ă , Ă, ĂŹ, Ăź, #, |, ', +,
in the TLG-Options.
v3.9
Stable Version
- Added inbuild detection for
Vip
andSubscribers
to be optionally exempt from moderation. Vip
andSubscribers
can be exempt from moderation individually. If a user has both roles, either one of the exemptions will match on'True'
.- Twitch bot account is now exempt by default, regardless of itâs role.
- Globally, URL detection does now look for indicators in messages, rather then banning straight forward for just finding a blacklisted word.
- Since the script normalize any input, you can exempt certain characters from detection e.g.:
Ă, ĂĄ, Ă , Ă, ĂŹ, Ăź, #, |, ', +,
in the TLG-Options.
v3.8
I decided to make 2 versions of the script. A Light
version that only blocks/bans urls/obfuscated urls and the stable
version.
Stable Version
- Reworked the Code for better detection and differentiation between the systems
- Revised the appearance of the script structure and made it more understandable
- All chat messages and Logs have been revised and unified to be more informative
- Removed the filter for specialCharacters since it was pretty unpredictable.
- Voucher Code detection is fully integrated.
Light Version
- Added a âlight versionâ that only delete/bans normal urls or obfuscated urls while ignoring urls concealed with â***â or anything else.
- Offers the same customization options as the stable version.
- This Version is âas isâ, since itâs pretty forward and as long twitch or SB donât do groundbreaking changes to APIs, there is nothing to do here.
v3.7
- Again refined the detection for special characters to avoid issues.
- Added more editable messages according to new features.
- Added
Killswitches
for new features to bypass them if there are any issues - The
special characters
andvoucher code pattern
detection, both now can differentiate between spam messages and normal messages and only ban typical spam messages - At the moment, you need to go into the code to edit the exclude lists for special characters if youâre using a language using other chars then predefined
- Added previous versions in the Changelog area so older versions are available if needed
- Message args in the
Permit User
action are also now mandatory to be active and set
TwitchLinkGuard-3.7.sb (24.9 KB)
v3.6
- Refined the detection for special characters to leave out some common characters to avoid issues in some languages.
- All Chat Messages are now directly handled by the corresponding arguments that were disabled by default and optional till now.
- All Mod-Action log messages are now editable.
- In the TLG-Options the args
%whitelist%
,%suspiciousKeywords%
and%suspiciousEndings%
needs to be active. isVip
is reintroduced as if/else statement since not everyone trusts their own VIPs.- TLG now detects messages containing âvoucher codeâ like structures like:
GVP-1KJN-VM12-2QNG
and ban users without roles/trusted group/not permitted. - Performance of the
Permit User
script was optimized.
TwitchLinkGuard-3.6.sb (23.4 KB)
v3.5
- The script was once again completely overhauled to have a better reaction performance in some cases.
- Removed the useless
if/else
logic since an optional group system was introduced long time ago. The script skips any moderation forVIPs
andmoderators
since those roles are supposed to be trusted users. - Whitelist is now even more flexible and doesnât require asterisks anymore.
- Obfuscated messages with special characters are now fully filtered. Messages like â
GĂŤt cheap Subs͢cÍĄrÍibers example. com
â is now handled correctly. - All default chat messages have been revised.
- Protocols and ban reasons have been adjusted to provide as much information as possible about why actions occurred.
TwitchLinkGuard-3.5.sb (22.8 KB)
v3.4
- Fix: Somehow old code sneaked into the permit system that didnât belong there and messages werenât editable
- Added more default detected keywords using special characters. i tried to add a automated detection for unicode patterns but i wasnât satisfied with itâs performance, so you can instead manually add special character words to the
%SuspiciousKeywords%
list (e.g.BĚžuĚžyĚž, đđđđ¤đ , đđľđ˛đŹđ´, GÍĚ˝rÍĚ˝oÍĚ˝w
) - Removed some useless code actions
- Ban reasons and respectively log messages now give even more details about why a user message was banned/warned/deleted.
E.g.Posted an obfuscated URL along with a prohibited keyword: Keyword: 'nezhna', SuspiciousEnding: 'com'.
- Code got some kind of a âstructureâ.
TwitchLinkGuard-3.4.sb (24.5 KB)
v3.3
- No touching the script to edit the whitelist anymore!
- Whitelist now use the same system as
suspiciousEndings/keywords
but without a predfined default list, so if the argument is disabled/missing, no links are whitelisted.
- Whitelist now use the same system as
- Removed many TLDs (Top-Level-Domains) since they arenât frequently used anyways (like
.at
) and focused more on commonly used TLDs appearing in spam messages - Fixed some typos again.
- The
isBlockedByTwitch
System now bans users posting links with suspicious keywords instead of just deleting any message regardless. isBlockedByTwitch
is now removed from the KillSwitch System since there is basically no way of malfunctioning.- Removed âlightâ edition since main script is now stable enough.
- Updated the Instructions.
TwitchLinkGuard-3.3.sb (23.0 KB)
v3.2
- Made myself more clear where to go with the script and ditched the idea of a âSpam Protectionâ that give the possibility of a delayed penality since twitch only deletes the last message with TwitchWarn and it just would clutter the mod-action list for no reason
- Optionally, you can set
useTwitchWarn
toTrue
if you want to give out a âwarnâ additionally to users posting links in the TLG-Options Group - Refined the whitelist logic to be more dynamically and accept wildcard placeholder asterisks at any position in the link (e.g.
*twich.tv
,www.discord.*
) so URLs donât have to be strict. - Adjusted the regular expression used in the
IsObfuscatedMessage
function to be more flexible - Fixed many typos
- Removed deprecated lines
- Removed
IsObfuscatedMessage
function from Killswitch since there is basically no way of malfunctioning - TLG-Permit User now has editable chat messages
v3.1
- Spam Protection is temporarily removed from release version since i was not satisfied with its performance and state at the moment.
- The permit system got some enhancements and has now more configurations.
- Added three âKillswitchâ arguments if something goes wrong (which should not actually but who knows) for a certain period.
- Once again some rearangements and added colors to make it more appealing
- Updated the Instructions
v3.0
- Sub-actions are now more clearly arranged and grouped.
- All messages output by the script are now customizable in the âChat messagesâ group.
%suspiciousKeywords%
and%suspiciousEndings%
can now both be directly edited in the âOptionsâ group, allowing the script to be more easily adapted to individual needs. Both options are disabled by default, with the previously known list serving as the default until the arguments are activated. - Spam protection is now fully optional, with all related functions grouped together (and probably took me more time and nerves than it was probably worth :D).
- Spam protection can now be modular, specifying how many links can be spammed before an official âWarnâ is triggered by Twitch. (Messages are still deleted and the user is warned.)
- Also optional:
%usePenality%
allows you to decide whether a timeout or ban should occur if a user continues to post links after a Twitch warning. - The duration of the timeout or the alternative ban can also be set.
- Also optional:
- The script has been slightly adjusted and now shows where the âTouchy Zoneâ begins upon opening.
v2.8
- removed the broadcaster if/else logic since it doesnât make really sense
- added more explanations in the new rearranged sub-actions and in the code
- added more Logs to steps i thought theyâre necessary
- TLG now features an optional Spam Protection:
- If a user spam more then 5 links (with non-suspicious text) twitch sends out an official âwarnâ, broadcaster and moderators can see in the users history
- If the same user proceed to spam links, a timeout or ban occur based on your settings.
- The argument
%useTimeout%
handles if a timeout or ban happens for Spam Protection. - If you set the value of
%timeoutDuration%
to0
it will ban users. - Regardless of your above setting, a user will receive a official âwarnâ from twitch after posting 5 links that is tracked in the users history. So itâs easy to inspect warns/timeouts/bans for Broadcaster and moderators by clicking on the name of the user
v2.7
âStableâ/Light verion
- Made the
%groupName%
argument optional and added SBâs own if/else logic again, to skip broadcaster, moderators and VIPs since itâs easier to implement. Anyway, you can enable%groupName%
and add trusted users to this list for exemption. - Removed the
%groupName%
logic from the!permit
Action since they are exempt anyways if activated
TwitchLinkGuard 2.7.sb (12.5 KB)
v2.6
- Added new subaction folder called âOptionsâ with some QoL arguments to both actions
%groupName%
now uses the predefined groupTLG-TrustedUsers
to detect if users are trusted to post links. You can edit the argument to user another group aswell.%useBot%
now let you decide if you want to use yourbot
(true) orbroadcaster account
(false) for messages and bans%sendAction%
now let you decide if you want to useSendAction
(true) orSendMessage
(false)
v2.5
- Added a check using
CPH.UserInGroup
to determine if a user belongs to theTLG-TrustedUsers
group. - Add a argument to use another group then the predefined
TLG-TrustedUsers
group. - If the user is in the trusted group, the script skips the
!permit
command and sends an informational message indicating the user is already allowed to post links.
v2.4
- fixed an issue were the script would delete messages tagging users only with emotes
- refined the obfuscation detection
- script is now completely commented
- permit messages are now completely in english
- Still watch out for messages held back by twitch
v2.3
- The script now detects messages flagged by Twitchâs built-in
AutoMod
feature using theTwitchDenyAutoHeldMessage
flag. It denies these messages, bans the user and provide an explanation in the ban reason. No further messages are posted in the chat, as only the broadcaster and moderators can view these flagged messages. (Needs some testing since itâs not easy to test this alone, prepare for failures ) - The script now exempts common bots from being punished for posting links
(e.g. sery_bot)
, provided they do not hold moderator or VIP roles. This exemption can be customized by modifying a list in the code. - Messages now have
, true);
at the end, so you can better decide if bot or broadcaster account should be used by usingtrue
for bot andfalse
for broadcaster account.
v2.2
- Detects now URLs that get replaced with
***
by Twitchâs own link block system and warns the user to do not post links - Ban reasons are even more detailed now: explains why the ban happened and what keyword was used:
banned by BOTNAME, reason: Posted an obfuscated URL with prohibited keyword: example
v2.1
- Completely reworked the script
- Way more robust script structure handling different Links in messages
- Warnings/Bans are now explained afterwards and there should be no failures anymore
- For everything else: please read the overhauled Opener for all Key Features
- For people disliking
sendAction
i now added a âbâ-Version usingsendMessage