You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
context.respondAsync("I will now reboot the PC.") { _in
390
390
reboot()
391
391
}
392
-
392
+
393
393
returntrue
394
394
}
395
395
```
396
396
397
397
Handler functions can be marked as `throws` and throw exceptions. Router won't process them and will simply pass the exceptions to caller.
398
398
399
399
`Context` is a request context, it contains:
400
-
400
+
401
401
*`bot` - a reference to the bot.
402
402
*`update` - current `Update` structure.
403
403
*`message` - convenience method for accessing `update.message`. If `update.message` is nil, fallbacks to `update.edited_message`, then to `update.callback_query?.message`.
@@ -428,21 +428,21 @@ extension Context {
428
428
var session: Session { return properties["session"] as! Session }
429
429
}
430
430
```
431
-
431
+
432
432
`Context` also contains a few helper methods and variables:
433
-
433
+
434
434
*`privateChat` - true, if this is a private chat with bot, false for all group chat types.
435
435
*`chatId` - shortcut for message?.chat.id. If message is nil, tries to retrieve chatId from other `Update` fields.
436
436
*`fromId` - shortcut for message?.from?.id. If message is nil, tries to retrieve fromId from other `Update` fields.
437
437
*`respondAsync`, `respondSync` - works as `sendMessage(chatId, ...)`
438
438
*`respondPrivatelyAsync/Sync("text", groupText: "text")` - respond to user privately, sending a short message to the group if this was a group chat. For example:
groupText: "Please find a list of commands in a private message.")
443
443
```
444
444
445
-
*`reportErrorAsync/Sync(text: "User text", errorDescription: "Detailed error description for administrator")` - sends a short message to user and prints detailed error description to a console. `text` parameter can be omitted, in which case user will receive a generic error message.
445
+
*`reportErrorAsync/Sync(text: "User text", errorDescription: "Detailed error description for administrator")` - sends a short message to user and prints detailed error description to a console. `text` parameter can be omitted, in which case user will receive a generic error message.
446
446
447
447
**Text commands**
448
448
@@ -603,4 +603,3 @@ Happy coding!
603
603
## License
604
604
605
605
Apache License Version 2.0 with Runtime Library Exception. Please see LICENSE.txt for more information.
0 commit comments