Skip to content

Arguments

Nill edited this page Sep 10, 2021 · 2 revisions

The Arguments type is provided by Telefrag to help handle parameters provided by humans on Telegram which will always be provided as a string but may not only need to be interpretted as integers, longs, dates, but may also need to be split into parameters based on a delimiter.

Any time Telefrag parses text it knows is from a Telegram user it is often presented as an Arguments object so that it can be queried easily.

Let's take this example input provided by a user:

var a = new Arguments("/kick @bob 40 Go Away");

, here are some example evaluations and their results:

Expression Type Example Result
a[0] Argument "/kick"
a[1] Argument "@bob"
a[2] Argument "40"
(int)a[2] int 40 (implicit conversion avail)
a[2].ValueAsInt int 40
a[2].IsNumber bool true
a[4] Argument "Away"
a[5] Argument null
a[4].Exists bool true
a[5].Exists bool false
a[2] as string string "@bob" (implicit conversion avail)
a[2].Value string "@bob"
a[3..] Argument "Go Away"
a[^1] Argument "Away"

Clone this wiki locally