-
Notifications
You must be signed in to change notification settings - Fork 2
Handling Updates
Alper Kürşat edited this page Feb 14, 2022
·
2 revisions
This page explains .get
method. Read Service Messages for documentation about .on
method.
Telegram Bot API has several types of updates.
message
edited_message
channel_post
edited_message
edited_channel_post
inline_query
chosen_inline_result
callback_query
shipping_query
pre_checkout_query
poll
poll_answer
You can catch and process those updates by defining .get(UPDATE_TYPE, callback)
//bot.js
import Botocrat from "@botocrat/core"
const bot = new Botocrat()
.get("message", (req, res) =>
res.reply(`Hello ${ req.from.first_name }!`))
.get("edited_message", (req, res) =>
console.log("Message edited:", req))
req
argument has content of incoming message. You don't have to specify the type, intellisense of your IDE automatically detects from types.
res
argument is an incoming message context
that has specific methods.
Read more about Message Context