定时流 (timing.co)#
与定时和对静默期做出反应相关的流。
- wait $time_s $timer_id="wait_timer_{uid()}"
等待指定的秒数,然后继续
示例
import timing import core flow delayed bot say $text wait 0.5 bot say $text flow main user said something start delayed bot say "I say this later" start bot say "I say this first" wait indefinitely
> hello I say this first I say this later
- repeating timer $timer_id $interval_s
启动重复计时器
示例
import timing import core flow reacting to my timer match TimerBotAction.Finished(timer_name="my_timer") bot say "tick" flow main activate reacting to my timer user said something start repeating timer "my_timer" 0.4 wait 1.0
> test tick tick
- user was silent $time_s
等待用户静默 $time_s 秒
示例
import timing import core flow reacting to user silence user was silent 5.0 bot say "Can I help you with anything else?" flow main activate reacting to user silence while True user said something bot say "sounds interesting"
> I am going to the zoo sounds interesting # (Wait for more than 5 seconds) Can I help you with anything else?
- user didnt respond $time_s
等待用户在 Bot 静默时静默 $time_s 秒
示例
import timing import core flow repeating if no user response global $last_bot_script user didnt respond 5.0 bot say $last_bot_script flow main activate tracking bot talking state activate repeating if no user response user said something bot say "How can I help you today?" user said something
> hi How can I help you today? # (Wait for more than 5 seconds) How can I help you today?
- bot was silent $time_s
等待 Bot 静默(无话语)给定时间
示例
import timing import core flow inform processing time user said something bot was silent 2.0 bot say "This is taking a bit longer" flow processing user request user said "place the order" wait 4.0 bot say "order was placed successfully" flow main activate inform processing time activate processing user request
> place the order # After about 2 seconds: This is taking a bit longer # After and additional 2 seconds: order was placed successfully