Preskoči na glavno vsebino

Objave

Prikaz objav, dodanih na november, 2023

Talking in Rye over Telegram

Telegram is a popular messaging app that offers a variety of solid clients and features, including chatbots. In this blog post, we will explore how to create a Telegram chatbot that we can communicate with, in Rye language - yeah, we’re fans :=). Starting with an Echo Bot Our first step in creating a Telegram chatbot will be to create a simple Echo bot. An Echo bot simply echoes back whatever message it receives. This is a good starting point for learning how to create more complex bots. Setting up a new bot in Telegram involves interacting with the BotFather on Telegram itself to get a token, which you’ll save in a .token file. Rye uses Go’s telegram-bot-api library quite direct. With a few helper functions the example code could be shorter and more high level, but this better shows us what is going on behind the scenes.   So we load the API token, create an instance of the Telegram-bot and define its on-update method. In it we parse the ‘Message’ out of the JSON mess