Zum Inhalt

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:

$upper($substring($trim(%input0%), 0, 5))$
  1. $trim()$ strippt Spaces
  2. $substring()$ nimmt erste 5 Zeichen
  3. $upper()$ macht uppercase

Beispiel: hello worldHELLO

Praktische Patterns

Stripping @ und Lower-Case in einem Schritt

$lower($replace(%input0%, @, ))$

Aus @Bob wird bob — perfekter Twitch-Login.

Wochentag aus Datum

$date(dddd)$

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:

$date($sub($now(), ~streamStart~), HH:mm)$

(Inline-Function-Math mit DateTimes kann tricky sein — Output testen.)

Truncate + Ellipsis

Lange Twitch-Messages auf max 100 Zeichen kürzen:

$substring(%message%, 0, 100)$...

Percent-Berechnung

$div($mul(%subscriberCount%, 100), %followerCount%)$

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-sensitiveMM (Monat) ≠ mm (Minute)
  • %var% innerhalb Inline-Function — funktioniert meist, aber bei manchen Edge-Cases nicht. Im Zweifel mit Set Argument als Zwischenschritt
  • Locale$date()$ Format/Wochentag-Sprache je nach Windows-Locale. Bei deutschem Windows kommt deutsche Ausgabe

Quellen