From 9cb6c34b8dec4498f31018b387a08f5ba15a0cf7 Mon Sep 17 00:00:00 2001 From: Sreelal TS Date: Mon, 8 Jul 2024 22:34:20 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=98=87=20Updated=20the=20README=20with=20?= =?UTF-8?q?correct=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 8aa842a..917096b 100644 --- a/README.md +++ b/README.md @@ -81,11 +81,16 @@ Now, you can start listening for updates such as messages, commands, etc. To start polling updates from Telegram servers, simply call: ```dart -bot.start(); +await bot.start(); ``` That's it! Your bot is now ready to receive updates from Telegram. +> [!NOTE] +> Remember to await the `bot.start()` call! This call initializes the bot and +> fetches details like its username. Starting the bot without awaiting could +> lead to unexpected behavior if initialization fails. + If you want to handle a specific command, such as the `/start` command, you can use the `bot.command` method. For example: @@ -95,16 +100,6 @@ bot.command('start', (ctx) async { }); ``` -Starting from Televerse 1.3.1, you can use the `bot.start` method to start -listening for updates and also set up a command listener for the `/start` -command. That means you can simplify the code above like this: - -```dart -bot.start((ctx) async { - await ctx.reply('Hello, World!'); -}); -``` - And that's all you need to get started with Televerse! ## 📚 Documentation @@ -225,7 +220,7 @@ Easily create Keyboard Reply Markup and Inline Keyboard Markup with Televerse's intuitive utility classes. Easy as it sounds. ```dart -bot.start((ctx) async { +bot.command('keyboard', (ctx) async { final keyboard = Keyboard() .text("Account") .text("Referral") @@ -311,7 +306,7 @@ final bot = Bot( // Create the Conversation API instance final conv = Conversation(bot); -bot.start((ctx) async { +bot.command('start', (ctx) async { await ctx.reply("Hello, I am ${ctx.me.firstName}. What should I call you?"); // Now wait you can wait for the user's reply message. Easy, right? @@ -343,7 +338,7 @@ final menu = KeyboardMenu() bot.attachMenu(menu); // Start bot -bot.start((ctx) async { +bot.command('start', (ctx) async { await ctx.reply( "Hello, I am ${ctx.me.firstName}. Let's start.", replyMarkup: menu,