informatica:telegram:bot
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| informatica:telegram:bot [2021/12/01 21:15] – jose | informatica:telegram:bot [2023/03/20 14:13] (current) – jose | ||
|---|---|---|---|
| Line 8: | Line 8: | ||
| Escribimos | Escribimos | ||
| /newbot | /newbot | ||
| - | Nos contesta que ahora le tenemos que poner un nombre | + | Nos contesta que ahora le tenemos que poner un nombre. El nombre puede ser largo y tener espacios: |
| Alright, a new bot. How are we going to call it? Please choose a name for your bot. | Alright, a new bot. How are we going to call it? Please choose a name for your bot. | ||
| - | Ponemos el nombre | + | Ponemos el nombre: |
| - | | + | |
| Nos contesta: | Nos contesta: | ||
| Good. Now let's choose a username for your bot. It must end in `bot`. Like this, for example: TetrisBot or tetris_bot. | Good. Now let's choose a username for your bot. It must end in `bot`. Like this, for example: TetrisBot or tetris_bot. | ||
| - | Le ponemos: | + | El username no puede tener espacios y tiene que acaba con la palabra **bot**:Le ponemos: |
| jurjurbot | jurjurbot | ||
| Nos dice que está creado y nos da el token del bot que debemos guardar. | Nos dice que está creado y nos da el token del bot que debemos guardar. | ||
| Line 27: | Line 27: | ||
| </ | </ | ||
| - | Metemos usuario en el grupo y sacamos el nombre del grupo con el comando: | + | Metemos usuario |
| curl -X GET https:// | curl -X GET https:// | ||
| Por ejemplo: | Por ejemplo: | ||
| Line 70: | Line 70: | ||
| </ | </ | ||
| - | ====== | + | ====== |
| Podemos ver las actualizaciones del bot con la API getUpdates como hemos visto antes: | Podemos ver las actualizaciones del bot con la API getUpdates como hemos visto antes: | ||
| curl -X GET https:// | curl -X GET https:// | ||
| Line 223: | Line 223: | ||
| Si lo lanzamos a la API de PHP haría el comando **/ | Si lo lanzamos a la API de PHP haría el comando **/ | ||
| curl -X POST -d@peticion.json " | curl -X POST -d@peticion.json " | ||
| + | | ||
| + | ====== ERRORES ====== | ||
| + | El bot no da respuesta y en nginx da 499 | ||
| + | curl -s -X GET https:// | ||
| + | Da error "Read timeout expired", | ||
| + | |||
| + | < | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | Era un problema de DNS pero para vaciar los mensajes pendientes he puesto en el fichero bot.php | ||
| + | < | ||
| + | $update = json_decode(file_get_contents(' | ||
| + | | ||
| + | if(time()-((@$update-> | ||
| + | | ||
| + | } | ||
| + | } | ||
| + | |||
| + | </ | ||
informatica/telegram/bot.1638393311.txt.gz · Last modified: by jose
