Tutorial fixes

This commit is contained in:
Abbas Abou Daya 2017-10-30 21:21:13 -04:00
parent f5cbe8b953
commit c67d68dcf7
5 changed files with 16 additions and 16 deletions

View File

@ -5,4 +5,4 @@ Once you /backup, the bot will respond back with a valid JSON object that repres
On /recover, the bot will ask for the JSON file. A reply to the message with the file attached will recover the bot with the previous state DB.
Try to experiment using the counter ability introduced in [Database Handling](Database-Handling.md)!
Try to experiment using the counter ability introduced in [[Database Handling|Database-Handling]]!

View File

@ -1,8 +1,8 @@
#Database Handling
# Database Handling
AbilityBots come with an embedded DB. Users are free to implement their own databases via implementing the [DBContext](../../telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/db/DBContext.java) class.
The abstraction has multiple constructors to accommodate user-defined implementations of [DBContext](../../telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/db/DBContext.java) and [MessageSender](../../telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/sender/MessageSender.java). We'll talk about the message sender interface in the [bot testing](Bot-Testing.md) section.
The abstraction has multiple constructors to accommodate user-defined implementations of [DBContext](../../telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/db/DBContext.java) and [MessageSender](../../telegrambots-abilities/src/main/java/org/telegram/abilitybots/api/sender/MessageSender.java). We'll talk about the message sender interface in the [[Bot Testing|Bot-Testing]] section.
##Example
## Example
We'll be introducing an ability that maintains a special counter for every user. At every /increment, the user will receive a message with the previous number + 1. We'll initially start from zero and increment onwards.
```java

View File

@ -72,10 +72,10 @@ The `silent` object is created with every AbilityBot. It provides helper and uti
manage errors by checking for the presence of the optional `.isPresent()`. This decreases verboseness while still being able to execute routines correctly.
Do note that:
* You can still access the bot's methods and functions inside the lambda function in your action definition. That includes all the DefaultAbsSender methods execute, executeAsync, setChatPhoto, etc....
* `silent` uses another accessible object named `sender`. Refer to [[Bot Testing]] for the main use case of sender as an interface to all bot methods.
* `silent` uses another accessible object named `sender`. Refer to [[Bot Testing|Bot-Testing]] for the main use case of sender as an interface to all bot methods.
With abilities, you can specify the context of the feature. If you only want the command to be available for groups, then you can set `.locality(GROUP)`. If it is a very sensitive command that only admins should have access to, then set `.privacy(ADMIN)`.
This allows for abilities with protection guarantees on who can use and where it can be used.
This allows for abilities with protection guarantees on who can use it and where it can be used.
The following is a snippet of how this would look like with the plain basic API.
```java

View File

@ -1,7 +1,7 @@
#AbilityBot
This section of the tutorial will present a barebone example on creating your first AbilityBot! It is highly recommended to write your very first bot via the [simple users guide](./Simple-Example.md). That will give you a sense of how the basic API allows you to handle commands and features.
# AbilityBot
This section of the tutorial will present a barebone example on creating your first AbilityBot! It is highly recommended to write your very first bot via the [[Getting Started|Getting-Started]]. That will give you a sense of how the basic API allows you to handle commands and features.
##Dependencies
## Dependencies
As with any Java project, you will need to set your dependencies.
* **Maven**
@ -20,7 +20,7 @@ As with any Java project, you will need to set your dependencies.
* [Plain Imports/Jars](https://github.com/rubenlagus/TelegramBots/releases)
##Bot Declaration
## Bot Declaration
To use the abilities module, you will need to extend AbilityBot.
```java
import org.telegram.abilitybots.api.bot.AbilityBot;
@ -30,7 +30,7 @@ public class HelloBot extends AbilityBot {
}
```
##Bot Implementation
## Bot Implementation
Bot token and nickname are passed via the constructor and don't require an override.
```java
public HelloBot(String token, String username) {
@ -59,7 +59,7 @@ So, if your Telegram ID Is 123456789, then add the following method:
That's it to have a valid, compilable and ready to be deployed bot. However, your bot doesn't have a single command to use. Let's declare one!
##Hello Ability
## Hello Ability
To add a feature to your bot, you add an ability. That's it! No routing from onUpdateReceived, no separate checks and no crossovers. Let's write our first ability that simply says hello!
```java
@ -97,7 +97,7 @@ public class Application {
}
```
If you're in doubt that you're missing some code, the full code example can be inspected [Here]()
If you're in doubt that you're missing some code, the full code example can be inspected [here](https://github.com/addo37/ExampleBots/tree/master/src/main/java/org/telegram/examplebots).
## Testing Your Bot
Go ahead and "/hello" to your bot. It should respond back with "Hello World!".

View File

@ -1,8 +1,8 @@
#Replies
# Replies
A reply is AbilityBot's swiss army knife. It comes in two variants and is able to handle all possible use cases.
##Standalone Reply
## Standalone Reply
Standalone replies are replies declared on their own without being attached to an ability. Here's an example of a possible reply declaration:
```java
/**
@ -20,7 +20,7 @@ Let's break this down. Replies require a lambda function (consumer) that is able
from the update and sends a "Yuck" message. `Reply.of(upd)` would be enough. However, replies accept a var-arg of type `Predicate<Update>`. These predicates are the necessary conditions so that the bot acts the reply. We specify Flag.PHOTO to let the bot know
that we only want the reply to act on images only! The Flag is a public enum at your disposal. It contains other conditionals like checking for videos, messages, voice, documents, etc...
##Ability Reply
## Ability Reply
In exactly the same manner, you are able to attach replies to abilities. This way you can localize replies that relate to the same ability.
```java
public Ability playWithMe() {