command
Catches a Telegram command, which has been specified as an argument.
command(name=String|Symbol, &block)
command(name=String|Symbol, &block)
Platforms
Platform
Supported
Messenger
Telegram
Usage
class MainContext < Conversation
def blocks
command :start do
@reply.text "Hello and welcome!"
end
end
Configuration
In order to be implemented in Kogno, the commands must be created first in Telegram through the BotFather or well, by defining them in the configuration file config/platforms/telegram.rb
by modifying config.telegram.commands
field.
config.telegram.commands = [
{
scope: :default,
commands:{
start: "Start chat",
featured_products: "List featured products."
}
},
{
scope: :all_chat_administrators,
commands:{
update_products: "Update products from server.",
purchase_count: "Sales today."
}
}
]
Available scopes are: :default
, :all_private_chats
, :all_group_chats
and :all_chat_administrators
. Read more about Commands Scopes on Telegram.
Command Line
Once configured, these changes must be sent to Telegram by running the following command in terminal.
Update all scopes
kogno telegram set_commands all
Update the scopes individually
kogno telegram set_commands all_chat_administrators
Routing to Context
Each command can be routed to a specific context, learn how in Routing Chapter.
Last updated
Was this helpful?