Skip to content

Response Context Decorators

Alper Kürşat edited this page Feb 23, 2022 · 1 revision

Methods

Following methods are decorating send parameters in response context.

Method Description
.to(chat_id) Sets chat_id
.wait(miliseconds) Allows waiting before sending message
.silent Sets disable_notification: true
.allow Sets allow_sending_without_reply: true
.protect Sets protect_content: true
  • These decorators will not inherited by the new context created

Understanding Wait Method

  • Wait should used before sending.
  • Sending a message resets waiting timeout.
res.wait(1000).send("Hello")

Wait after send (no-effect)

🗑 Wait after send has no effect.

res.send("Hello").wait(1000)

Repetitive Wait (overwrites)

Following code waits 1500ms before sent

res.wait(1000).wait(1500).send("Hello")

Consecutive calls (where bugs occur)

At the following example; both "Hello" and "World" waits 1000ms before sent.

res.wait(1000).send("Hello")
  .wait(1000).send("World")

Program immediately sends "World" and waits 1000ms before sending "Hello".

res.wait(1000).send("Hello")
  .send("World")

Consecutive calls (the proper way)

Program waits 1000ms before sending "Hello".

After telegram responds, program waits 1000ms again

then sends "World"

res.wait(1000).send("Hello")
  .sent.wait(1000).send("World")