Skip to content

Commit

Permalink
Initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenlagus committed Mar 16, 2024
1 parent a70cad7 commit 212f1f6
Show file tree
Hide file tree
Showing 16 changed files with 15 additions and 15 deletions.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
2 changes: 1 addition & 1 deletion Writerside/topics/Abilities.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Abilities

<p align="center">
<img src="API BOT-03.png" alt="abilities" />
<img src="api_bot_03.png" alt="abilities" />
</p>

The AbilityBot abstraction defines a new object, named Ability. An ability combines conditions, flags, action, post-action and replies.
Expand Down
2 changes: 1 addition & 1 deletion Writerside/topics/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ You don't need to spend a lot of money into hosting your own telegram bot. Basic

1. Hosting on your own hardware. It can be a Mini-PC like a Raspberry Pi. The costs for the hardware (~35€) and annual costs for power (~7-8€) are low. Keep in mind that your internet connection might be limited and a Mini-Pc is not ideal for a large users base.
2. Run your bot in a Virtual Server/dedicated root server. There are many hosters out there that are providing cheap servers that fit your needs. The cheapest one should be openVZ-Containers or a KVM vServer. Example providers are [Hetzner](https://www.hetzner.de/ot/), [DigitalOcean](https://www.digitalocean.com/), (are providing systems that have a high availability but cost's a bit more) and [OVH](https://ovh.com)
For a deeper explanation for deploying your bot on DigitalOcean please see the [Lesson 5. Deploy your bot](https://monsterdeveloper.gitbooks.io/writing-telegram-bots-on-java/content/lesson-5.-deploy-your-bot.html) chapter in [MonsterDeveloper](https://github.com/MonsterDeveloper)'s book
For a deeper explanation for deploying your bot on DigitalOcean please see the [Lesson 5. Deploy your bot](Lesson-5.md) in the tutorials.

## Method ```sendMessage()``` (or other) is deprecated, what should I do?
Please use `TelegramClient::execute()` instead.
Expand Down
4 changes: 2 additions & 2 deletions Writerside/topics/Lesson-1.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,15 @@ public class MyAmazingBot implements LongPollingSingleThreadUpdateConsumer {

Well done! Now we can pack our project into runnable `.jar` file and run it on our computer/server!

You can find all sources to this lesson in [GitHub repository](https://github.com/MonsterDeveloper/java-telegram-bot-tutorial/).
You can find all sources to this lesson in [GitHub repository](https://github.com/rubenlagus/TelegramBotsDocumentation/tree/main/java-telegram-bot-tutorial).

```text
java -jar MyAmazingBot.jar
```

Now we can see our bot running:

<img src="Bot_Reply.jpg" alt="Bot Reply" />
<img src="bot_reply.jpg" alt="Bot Reply" />

Well, that's all for now. Hope to see you soon! :)

8 changes: 4 additions & 4 deletions Writerside/topics/Lesson-2.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ else if (update.hasMessage() && update.getMessage().hasPhoto()) {

Let's take a look:

![Bot sends file\_id](https://github.com/MonsterDeveloper/java-telegram-bot-tutorial/raw/master/media/Bot_sends_photo.png)
![Bot sends file\_id](bot_sends_photo.png)

Amazing! Now we know photo's file\_id, so we can send them by file\_id. Let's make our bot answer with that photo when we send command `/pic`.

Expand Down Expand Up @@ -182,7 +182,7 @@ if (update.hasMessage() && update.getMessage().hasText()) {

Now bot sends photo like this:

![Bot sends photo by command /pic](Bot_sends_photo_command.png)
![Bot sends photo by command /pic](bot_sends_photo_command.png)

And he can even reply to unknown command!

Expand Down Expand Up @@ -242,7 +242,7 @@ else if (message_text.equals("Row 1 Button 1")) {

Now, when user press button with "Row 1 Button 1" text on it, bot will send picture by `file_id` to user:

![Bot sends photo from keyboard](https://github.com/MonsterDeveloper/java-telegram-bot-tutorial/raw/master/media/Bot_custom_keyboard_photo.png)
![Bot sends photo from keyboard](bot_sends_photo_command.png)

And let's add "Hide keyboard" function when user send `/hide` command to bot. This can be done with `ReplyMarkupRemove`.

Expand All @@ -264,7 +264,7 @@ else if (message_text.equals("/hide")) {
}
```

Here is code of our files. You can also find all sources at [GitHub repository](https://github.com/MonsterDeveloper/java-telegram-bot-tutorial/).
Here is code of our files. You can also find all sources at [GitHub repository](https://github.com/rubenlagus/TelegramBotsDocumentation/tree/main/java-telegram-bot-tutorial).

> src/Main.java
Expand Down
6 changes: 3 additions & 3 deletions Writerside/topics/Lesson-3.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,13 +227,13 @@ public class LoggingTestBot extends TelegramLongPollingBot {
}
```

You can also find all sources at [GitHub repository](https://github.com/MonsterDeveloper/java-telegram-bot-tutorial/).
You can also find all sources at [GitHub repository](https://github.com/rubenlagus/TelegramBotsDocumentation/tree/main/java-telegram-bot-tutorial).

Now it will do ~~ugly~~ log for us.

![Beautiful Logging 1](https://github.com/MonsterDeveloper/java-telegram-bot-tutorial/raw/master/media/Bot_Logging_1.png)
![Beautiful Logging 1](bot_logging_1.png)

![Beautiful Logging 2](https://github.com/MonsterDeveloper/java-telegram-bot-tutorial/raw/master/media/Bot_Logging_2.png)
![Beautiful Logging 2](bot_logging_2.png)

Well, that's all for now. In the next lesson we will learn how to make your messages more beautiful with [unicode emojis](https://en.wikipedia.org/wiki/Emoji).

4 changes: 2 additions & 2 deletions Writerside/topics/Lesson-4.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ String answer = EmojiParser.parseToUnicode("Here is a smile emoji: :smile:\n\n H

Where `:smile:` or `:alien:` is emoji alias or emoji short code. You can also view them at EmojiPedia or Emoji Cheat Sheet.

Here is source code. You can also find it on [GitHub](https://github.com/MonsterDeveloper/java-telegram-bot-tutorial).
Here is source code. You can also find it on [GitHub](https://github.com/rubenlagus/TelegramBotsDocumentation/tree/main/java-telegram-bot-tutorial).

> `src/Main.java`
Expand Down Expand Up @@ -176,7 +176,7 @@ public class EmojiTestBot extends TelegramLongPollingBot {

Now you can see our beautiful messages:

![Bot sends messages with emoji](Bot_emoji.png)
![Bot sends messages with emoji](bot_emoji.png)

Our lesson came to an end. Thank you for reading this. See you soon!

2 changes: 1 addition & 1 deletion Writerside/topics/Lesson-6.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,6 @@ public class BotApi20 implements LongPollingSingleThreadUpdateConsumer {

```

You can also find all source code to all of my lessons at [GitHub](https://github.com/MonsterDeveloper/java-telegram-bot-tutorial).
You can also find all source code to all of my lessons at [GitHub](https://github.com/rubenlagus/TelegramBotsDocumentation/tree/main/java-telegram-bot-tutorial).

Thank you for reading this! Now you can send Inline Keyboards and edit message's text and extra: handle callback queries. I hope you liked this lesson. Next time I will show how to create users database using MongoDB. Bye!
2 changes: 1 addition & 1 deletion Writerside/topics/Lesson-7.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

# Lesson 7. Creating users database with MongoDB

Hey! As you're reading this, you know that I returned from Italy. It was very nice, but ok - you want to create users database for your bot. Disputes about what DB is better can live very long time, but I will choose MongoDB. It is [high-performance, schema-free document-oriented database](https://mongodb.com). Let's create actual 'body' of our bot. Well, as always. I will skip this step as I know you have your own bot and there is no need to pollute the great lesson unnecessary amount of code. If not, you can find all sources at [GitHub repo](https://github.com/MonsterDeveloper/java-telegram-bot-tutorial/). Now, import MongoDB's driver for Java. You can download it [here](http://mongodb.github.io/mongo-java-driver/) or import it from Maven. With IntelliJ Idea it is easier than you expect. Just go to **File &lt; Project Structure... &lt; Libraries &lt; + &lt; From Maven** and search for `org.mongodb:mongo-java-driver`. That's all. Import it in your bot file:
Hey! As you're reading this, you know that I returned from Italy. It was very nice, but ok - you want to create users database for your bot. Disputes about what DB is better can live very long time, but I will choose MongoDB. It is [high-performance, schema-free document-oriented database](https://mongodb.com). Let's create actual 'body' of our bot. Well, as always. I will skip this step as I know you have your own bot and there is no need to pollute the great lesson unnecessary amount of code. If not, you can find all sources at [GitHub repo](https://github.com/rubenlagus/TelegramBotsDocumentation/tree/main/java-telegram-bot-tutorial). Now, import MongoDB's driver for Java. You can download it [here](http://mongodb.github.io/mongo-java-driver/) or import it from Maven. With IntelliJ Idea it is easier than you expect. Just go to **File &lt; Project Structure... &lt; Libraries &lt; + &lt; From Maven** and search for `org.mongodb:mongo-java-driver`. That's all. Import it in your bot file:

```java
import com.mongodb.MongoClient;
Expand Down

0 comments on commit 212f1f6

Please sign in to comment.