Advertisement
Advertisement

More Related Content

Advertisement

Groogram, bots de telegram con groovy

  1. GROOGRAMGROOGRAM ¡bots de telegram con groovy! @tf_gerson Gerson Cabrera, desarrollador Groovy en b2boost 1
  2. INTRODUCCIÓNINTRODUCCIÓN Como crear un bot y con gurarlo. Arquitectura general del bot y comunicación con nuestra aplicación. Ejemplos de código en Groovy. Review de bots varios. Conclusiones. 2 . 1
  3. Un bot es un programa informático que ejecuta tareas repetitivas a través de internet 2 . 2
  4. CREAR BOTS EN TELEGRAMCREAR BOTS EN TELEGRAM @BotFather
  5. 2 . 3
  6. UN BOT FUNCIONA COMO UN CHATUN BOT FUNCIONA COMO UN CHAT CUALQUIERACUALQUIERA 2 . 4
  7. CUIDADO CON LA PRIVACIDAD CUANDOCUIDADO CON LA PRIVACIDAD CUANDO USES BOTSUSES BOTS 2 . 5
  8. ARQUITECTURA DE UN BOTARQUITECTURA DE UN BOT 2 . 6
  9. TELEGRAM APITELEGRAM API se puede consultar aquí https://api.telegram.org/bot<token>/METHOD_NAME https://api.telegram.org/bot<token>/sendMessage 2 . 7
  10. CONECTAR EL WEBHOOK CON TUCONECTAR EL WEBHOOK CON TU APLICACIÓNAPLICACIÓN post/get: https://api.telegram.org/bot751729:AAFJRaz8sUequ/setWebhook body: {"url":"www.urlbase.com"} 2 . 8
  11. ¡¡PERO DAME CÓDIGO!!!¡¡PERO DAME CÓDIGO!!! 2 . 9
  12. CONTROLLERCONTROLLER @Controller class TelegramController { @Inject TelegramHandler telegramHandler @Post("/webhook") void webhook(@Body Update update) { telegramHandler.messageReceiver(update) } } 2 . 10
  13. UPDATE MODELUPDATE MODEL 2 . 11
  14. TELEGRAM HANDLERTELEGRAM HANDLER @Log @Singleton class TelegramHandler { @Inject MessageService messageService private static final def commands = ['start', 'help'] void messageReceiver(Update params) { String message = params?.message?.text?.drop(1) log.info("message received $message") validateMessage(message) "$message"(params) // invokeMethod(message, params) } 2 . 12
  15. MESSAGE SERVICEMESSAGE SERVICE @Singleton class MessageService { @Client("https://api.telegram.org/bot848542380:AAEjlY6qaxA0eE @Inject RxHttpClient httpClient void sendNotificationToTelegram(String message, String chatId httpClient.toBlocking().exchange("/sendMessage?text=$mess } } 2 . 13
  16. PROBLEMAS QUE ME HE ENCONTRADOPROBLEMAS QUE ME HE ENCONTRADO 2 . 14
  17. 1. Logs y gestión de errores (Telegram reenvía por defecto los mensajes erróneos) 2. Tienes que hablar al bot para que pueda hablarte 3. Jerarquía de bots 4. Tiempo de respuesta de tu servidor 5. Funcionalidades complejas resultan frustrantes para usuarios no técnicos 2 . 15
  18. EJEMPLOS DE USOEJEMPLOS DE USO Algunos bots vienen integrados en telegram por defecto, podemos citarlos usando @ como a cualquier otro bot/usuario: 2 . 16
  19. INLINE QUERIESINLINE QUERIES 2 . 17
  20. Un bot no puede activar comandos pero puede mandar el mensaje con una / como si fuera un link al mismo 2 . 18
  21. @TRANSCRIBER_BOT@TRANSCRIBER_BOT 2 . 19
  22. @NOSPOILERSBOT@NOSPOILERSBOT 2 . 20
  23. @M30MADRIDBOT@M30MADRIDBOT 2 . 21
  24. CONCLUSIONESCONCLUSIONES Los bots son de gran utilidad para el desarrollador Con gurar la privacidad Hay que tener cuidado con la gestión de errores y la jerarquía Potencial ilimitado El proceso de creación de bots se puede automatizar fácilmente 2 . 22
  25. AGRADECIMIENTOS Y, ¿PREGUNTAS?AGRADECIMIENTOS Y, ¿PREGUNTAS? Groogram Github repo 2 . 23
Advertisement