From c67d68dcf74eac481553001ea3335416004c145f Mon Sep 17 00:00:00 2001 From: Abbas Abou Daya Date: Mon, 30 Oct 2017 21:21:13 -0400 Subject: [PATCH] Tutorial fixes --- TelegramBots.wiki/abilities/Bot-Recovery.md | 2 +- TelegramBots.wiki/abilities/Database-Handling.md | 6 +++--- TelegramBots.wiki/abilities/Hello-Ability.md | 4 ++-- TelegramBots.wiki/abilities/Simple-Example.md | 14 +++++++------- TelegramBots.wiki/abilities/Using-Replies.md | 6 +++--- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/TelegramBots.wiki/abilities/Bot-Recovery.md b/TelegramBots.wiki/abilities/Bot-Recovery.md index 4796b2a3..498e818f 100644 --- a/TelegramBots.wiki/abilities/Bot-Recovery.md +++ b/TelegramBots.wiki/abilities/Bot-Recovery.md @@ -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)! \ No newline at end of file +Try to experiment using the counter ability introduced in [[Database Handling|Database-Handling]]! \ No newline at end of file diff --git a/TelegramBots.wiki/abilities/Database-Handling.md b/TelegramBots.wiki/abilities/Database-Handling.md index cd6fa6f9..69a59a62 100644 --- a/TelegramBots.wiki/abilities/Database-Handling.md +++ b/TelegramBots.wiki/abilities/Database-Handling.md @@ -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 diff --git a/TelegramBots.wiki/abilities/Hello-Ability.md b/TelegramBots.wiki/abilities/Hello-Ability.md index 75f99fb5..9516cc32 100644 --- a/TelegramBots.wiki/abilities/Hello-Ability.md +++ b/TelegramBots.wiki/abilities/Hello-Ability.md @@ -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 diff --git a/TelegramBots.wiki/abilities/Simple-Example.md b/TelegramBots.wiki/abilities/Simple-Example.md index 9462d30c..dfe7c7f1 100644 --- a/TelegramBots.wiki/abilities/Simple-Example.md +++ b/TelegramBots.wiki/abilities/Simple-Example.md @@ -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!". diff --git a/TelegramBots.wiki/abilities/Using-Replies.md b/TelegramBots.wiki/abilities/Using-Replies.md index 37883be9..d9b1c6ef 100644 --- a/TelegramBots.wiki/abilities/Using-Replies.md +++ b/TelegramBots.wiki/abilities/Using-Replies.md @@ -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`. 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() {