Inline Functions Deep-Dive¶
$func(args)$ ist Streamer.bot's mini-DSL für String-Manipulation, Math und Date-Formatting innerhalb von Text-Feldern. Hier die wichtigsten Patterns.
Syntax¶
Format: $funcName(arg1, arg2, ...)$
- Werden VOR Variablen-Interpolation aufgelöst
- Können verschachtelt werden
- Funktionieren in den meisten Text-Feldern (Send Message, Set Argument, etc.)
String-Manipulation¶
| Funktion | Beispiel | Output |
|---|---|---|
$lower(text)$ |
$lower(%user%)$ |
bob (aus Bob) |
$upper(text)$ |
$upper(%user%)$ |
BOB |
$proper(text)$ |
$proper(hello world)$ |
Hello World |
$length(text)$ |
$length(%user%)$ |
3 |
$reverse(text)$ |
$reverse(hello)$ |
olleh |
$trim(text)$ |
$trim( text )$ |
text |
$replace(text, search, replace)$ |
$replace(hello, l, L)$ |
heLLo |
$substring(text, start, length)$ |
$substring(hello, 1, 3)$ |
ell |
$indexOf(text, search)$ |
$indexOf(hello, l)$ |
2 |
$contains(text, search)$ |
$contains(hello, ell)$ |
true |
Math¶
| Funktion | Beispiel | Output |
|---|---|---|
$add(a, b)$ |
$add(5, 3)$ |
8 |
$sub(a, b)$ |
$sub(10, 4)$ |
6 |
$mul(a, b)$ |
$mul(7, 3)$ |
21 |
$div(a, b)$ |
$div(20, 4)$ |
5 |
$mod(a, b)$ |
$mod(10, 3)$ |
1 |
$abs(a)$ |
$abs(-5)$ |
5 |
$round(a)$ |
$round(3.7)$ |
4 |
$floor(a)$ |
$floor(3.7)$ |
3 |
$ceil(a)$ |
$ceil(3.2)$ |
4 |
$min(a, b)$ |
$min(5, 10)$ |
5 |
$max(a, b)$ |
$max(5, 10)$ |
10 |
$random(min, max)$ |
$random(1, 100)$ |
42 (random) |
Date/Time¶
| Funktion | Beispiel | Output |
|---|---|---|
$now()$ |
$now()$ |
2026-05-21T12:34:56 (ISO) |
$date(format)$ |
$date(yyyy-MM-dd)$ |
2026-05-21 |
$date(format, timezone)$ |
$date(HH:mm, UTC)$ |
12:34 |
Format-Strings (.NET-Style):
| Format | Beispiel |
|---|---|
yyyy |
2026 |
MM |
05 |
dd |
21 |
HH |
12 (24h) |
hh |
12 (12h) |
mm |
34 |
ss |
56 |
yyyy-MM-dd HH:mm:ss |
2026-05-21 12:34:56 |
dd.MM.yyyy |
21.05.2026 |
URL-Encoding¶
| Funktion | Beispiel | Output |
|---|---|---|
$urlencode(text)$ |
$urlencode(München)$ |
M%C3%BCnchen |
$urldecode(text)$ |
$urldecode(M%C3%BCnchen)$ |
München |
Wichtig für Fetch URL mit User-Input — siehe API Setup.
Regex (innerhalb Inline-Function)¶
| Funktion | Beispiel | Output |
|---|---|---|
$regex(text, pattern, replacement)$ |
$regex(hello123, [0-9]+, X)$ |
helloX |
Plus Capture-Groups:
| Funktion | Beispiel | Output |
|----------|----------|--------|
| $regex(hello123world, (\w+?)(\d+)(\w+), $1-$2-$3)$ | hello-123-world |
(Genau syntax kann SB-Version-abhängig sein.)
Nesting¶
Funktionen können verschachtelt werden:
$trim()$strippt Spaces$substring()$nimmt erste 5 Zeichen$upper()$macht uppercase
Beispiel: hello world → HELLO
Praktische Patterns¶
Stripping @ und Lower-Case in einem Schritt¶
Aus @Bob wird bob — perfekter Twitch-Login.
Wochentag aus Datum¶
Output: Sonntag (oder Sunday je nach Locale).
Twitch-Stream-Duration in HH:MM¶
Wenn Stream-Start in ~streamStart~ Global und du Diff in HH:MM willst:
(Inline-Function-Math mit DateTimes kann tricky sein — Output testen.)
Truncate + Ellipsis¶
Lange Twitch-Messages auf max 100 Zeichen kürzen:
Percent-Berechnung¶
Sub/Follower-Ratio in Prozent.
Where Inline Functions funktionieren¶
- Send Message (Content)
- Set Argument (Value)
- Global (Set) (Value)
- Fetch URL (URL und Headers)
- Write To File (Content und File)
- Speak (Message)
- Discord Webhook (Content)
- Set GDI Text
- ... fast überall wo Text-Felder sind
NICHT in: - Trigger-Filter (manche) - Bestimmte Sub-Action-Settings die nur statische Strings akzeptieren
Häufige Fallen¶
- Geschachtelt-Klammern — bei tief verschachtelt schnell falsche Klammer-Reihenfolge. Im Notepad++ checken
- Auto-Type-Konflikt —
$add()$will Numbers, wenn Args Strings: Cast oder Auto-Type aktiv - Datum-Format case-sensitive —
MM(Monat) ≠mm(Minute) %var%innerhalb Inline-Function — funktioniert meist, aber bei manchen Edge-Cases nicht. Im Zweifel mitSet Argumentals Zwischenschritt- Locale —
$date()$Format/Wochentag-Sprache je nach Windows-Locale. Bei deutschem Windows kommt deutsche Ausgabe
Quellen¶
- Streamer.bot Inline-Function-Doku: https://docs.streamer.bot/api/inline-functions (eventuell teils unvollständig)
- .NET DateTime Format Strings: https://learn.microsoft.com/dotnet/standard/base-types/custom-date-and-time-format-strings