TwitchLinkGuard - Block unwanted links
This script is designed to help Twitch streamers to maintain a safe and clean chat environment by automatically detecting and handling suspicious links.
I’m still a big Noob at coding, you’re welcome to let me know if there are things to do better or if there are issues. I try my best to help
This script works with stable
and beta
branch of streamer.bot
The project is in constant development. Errors, bugs and non-functioning or suddenly removed features are therefore very likely to occur. Please pay attention to misbehavior and I’m happy to get feedback from you!
Key Features:
- Role-Based Bypass
- Automatically exempts moderators, VIPs, and members of designated trusted groups from all moderation steps, ensuring critical team members and known contributors remain uninterrupted.
- Dynamic Permissions
- Temporarily permit a specific user to bypass moderation, offering flexible and time-bound exceptions for important guests or special events.
- Advanced Normalization & Detection
- Converts all incoming messages into a standardized ASCII form and instantly flags any attempt to circumvent standard character sets. Suspicious content leads directly to immediate enforcement actions, maintaining a clean and professional environment.
- Seamless Twitch Auto-Moderation Integration (testing stage)
- Effortlessly syncs with Twitch’s native moderation tools to deny harmful, auto-flagged messages. The script automatically bans offenders when necessary, reducing manual workload and response times.
- Sophisticated Keyword & Domain Analysis
- Employs an expansive list of known suspicious keywords and TLDs to identify malicious intent. Instantly removes problematic messages and, in extreme cases, bans offenders, preserving brand integrity and user trust.
- Precise Whitelist Control
- Only allow explicitly approved URLs. The script supports optional protocols and “www.” prefixes without requiring wildcard patterns. This ensures total control over permissible link sharing and eliminates accidental oversights.
- Obfuscation Resistance
- Identifies and neutralizes attempts to conceal harmful URLs through spacing, punctuation, or misleading “dot” replacements. Malicious links never slip through disguised formatting.
Example:
Installation
Import File
TwitchLinkGuard-3.5.sb (22.8 KB)
Step 1: Import Script
- In Streamer.bot click the
Import
button in the top menu. Drag the .sb file into theImport String
field. - Enable the
TwitchLinkGuard - Permit
command in theCommands
tab.
Step 2: TLG-Options
Editing your whitelist is important to keep your viewers safe from getting penalized by the script
- Edit
%whitelist%
so users can use links from you without being punished by the script. If the args is missing/disabled, no links are 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.
Argument | Value | Description | Reason |
---|---|---|---|
groupName | example: TLG-TrustedUsers | Use this to exclude a specific group of users from being handled by the script | |
useBot | True | Your bot account sends out any messages and handles bans/timeouts | SB default setting since 0.2.5 |
useBot | False | Your broadcaster account sends out any messages and handles bans/timeouts | SB default setting till 0.2.4 |
sendAction | True | Messages appears like this in chat. Similar to twitch’s own “/me” command | |
sendAction | False | Messages will appear as a normal text in chat | |
useTwitchWarn | True/False | if True additionally ‘warn’ a user for posting links |
Step 3: Edit Messages
You can edit the standard messages if you want. All message examples are predefined as default if the argument is disabled or missing
Step 4: Permit Options
Argument | Value | Description | Info |
---|---|---|---|
useBot | True | Your bot account sends out any messages and handles bans/timeouts | SB default setting since 0.2.5 |
useBot | False | Your broadcaster account sends out any messages and handles bans/timeouts | SB default setting till 0.2.4 |
sendAction | True | Messages appears like this in chat. Similar to twitch’s own “/me” command | |
sendAction | False | Messages will appear as a normal text in chat | |
permitTime | eg.: 120 | Define the time a user is allowed to post links |
Step 5: Permit Messages
Add {user}
to tag a user directly and {permitTime}
for the specific permitted time.
Argument | Value | Description |
---|---|---|
grantMessage | Informs the permitted user the amount of time allowed to post links | |
revokeMessage | Informs the user when the permitted time is over | |
existingPermissionMessage | Informs if there is already a user permitted | |
Labels | eg: min | for example: min, minutes, Minuten, etc. |
Usable Commands
Command | Example | Description |
---|---|---|
!permit | !permit ExampleUser | A specific user now has ‘x’ seconds to post a link |
Contributors
Changelog:
v3.5
This version stands out with excessive changes done to the script. Regardless, the script can now be seen as stable. Only the AutoMod Message
logic of twitch is still in testing, since i can’t test it forcefully
- 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.
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”.
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.
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
This version stands out with excessive changes done to the script
hence why i skipped a version, so v2.7 can be seen as the first stable release
- 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
Please let me know any issues
- 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
- 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
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