Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
Prochain SlideShare
What to Upload to SlideShare
Suivant
Télécharger pour lire hors ligne et voir en mode plein écran

2

Partager

Télécharger pour lire hors ligne

Telegram bots

Télécharger pour lire hors ligne

It Rally 2019

Livres associés

Gratuit avec un essai de 30 jours de Scribd

Tout voir

Telegram bots

  1. 1. Telegram bots Theory and practice Bohdan Pashkovskyi, Ph.D., Senior .NET Developer at Perfectial
  2. 2. Bots: An introduction for developers Bots are third-party applications that run inside Telegram. Users can interact with bots by sending them messages, commands and inline requests. You control your bots using HTTPS requests to our bot API.
  3. 3. How do I create a bot? Just talk to BotFather and follow a few simple steps. Once you've created a bot and received your authorization token, head down to the Bot API manual to see what you can teach your bot to do.
  4. 4. How are bots different from humans? Bots have no online status and no last seen timestamps, the interface shows the label ‘bot’ instead.
  5. 5. How are bots different from humans? Bots have limited cloud storage — older messages may be removed by the server shortly after they have been processed.
  6. 6. How are bots different from humans? Bots can't initiate conversations with users. A user must either add them to a group or send them a message first. People can use telegram.me/<bot_username> links or username search to find your bot.
  7. 7. How are bots different from humans? Bot usernames always end in ‘bot’ (e.g. @TriviaBot, @GitHub_bot).
  8. 8. How are bots different from humans? When added to a group, bots do not receive all messages by default.
  9. 9. How are bots different from humans? Bots never eat, sleep or complain (unless expressly programmed otherwise).
  10. 10. Privacy mode A bot running in privacy mode will not receive all messages that people send to the group. Instead, it will only receive:
  11. 11. Privacy mode Messages that start with a slash ‘/’
  12. 12. Privacy mode Replies to the bot's own messages
  13. 13. Privacy mode Service messages (people added or removed from the group, etc.)
  14. 14. Privacy mode Messages from channels where it's a member
  15. 15. Commands Commands present a more flexible way to communicate with your bot. The following syntax may be used: /command
  16. 16. Commands A command must always start with the ‘/’ symbol and may not be longer than 32 characters. Commands can use latin letters, numbers and underscores. Here are a few examples: /get_messages_stats /set_timer 10min Alarm! /get_timezone London, UK
  17. 17. Commands
  18. 18. Authorizing your bot Each bot is given a unique authentication token when it is created. The token looks something like 123456:ABC-DEF1234ghIkl- zyx57W2v1u123ew11, but we'll use simply <token> in this document instead.
  19. 19. Making requests All queries to the Telegram Bot API must be served over HTTPS and need to be presented in this form: https://api.telegram.org/bot<token>/METHOD_NAME.
  20. 20. Getting updates There are two mutually exclusive ways of receiving updates for your bot — the getUpdates method on one hand and Webhooks on the other. Incoming updates are stored on the server until the bot receives them either way, but they will not be kept longer than 24 hours. Regardless of which option you choose, you will receive JSON- serialized Update objects as a result.
  21. 21. getUpdates Use this method to receive incoming updates using long polling (wiki). An Array of Update objects is returned.
  22. 22. setWebhook Use this method to specify a url and receive incoming updates via an outgoing webhook. Whenever there is an update for the bot, we will send an HTTPS POST request to the specified url, containing a JSON- serialized Update. In case of an unsuccessful request, we will give up after a reasonable amount of attempts. Returns True on success.
  23. 23. .NET Client https://github.com/TelegramBots/Telegram.Bot
  24. 24. Initialize .NET client
  25. 25. CommandHandler Example
  26. 26. @ivanofrankivsk_130_bot
  27. 27. @ivanofrankivsk_130_bot
  28. 28. @IF112_bot Додавання водяного знаку Можливість адміністрації писати в чаті від імені бота
  29. 29. @ifpolice_bot Відправка повідомлення поліції Можливість поліції писати в чаті 112 від імені бота
  30. 30. @plusser_bot Вам набридло збирати плюсики у чаті і підраховувати хто ж прийде? Плюсуватор це зробить за вас.
  31. 31. @plusser_bot Вам набридло збирати плюсики у чаті і підраховувати хто ж прийде? Плюсуватор це зробить за вас.
  32. 32. Thank you Questions? Bohdan Pashkovskyi, Ph.D., Senior .NET Developer at Perfectial
  • TarasPetr

    Jul. 8, 2020
  • SvitlanaDolinovska

    May. 20, 2019

It Rally 2019

Vues

Nombre de vues

143

Sur Slideshare

0

À partir des intégrations

0

Nombre d'intégrations

3

Actions

Téléchargements

2

Partages

0

Commentaires

0

Mentions J'aime

2

×