software:telegram:start

Diferències

Ací es mostren les diferències entre la revisió seleccionada i la versió actual de la pàgina.

Enllaç a la visualització de la comparació

Següent revisió
Revisió prèvia
software:telegram:start [12/08/2019 08:28] – creat matesoftware:telegram:start [01/02/2020 15:03] (actual) mate
Línia 1: Línia 1:
 = telegram = telegram
 == create bot == create bot
 +=== telgram commands
 +  * ''@BotFather''
 +    * ''/newbot''
 +      * -> API TOKEN
 +    * ''/setuserpic''
 +  * ''@userinfobot'' : nos da nuestro ID usuario telegram
 +
 +
 +=== info
   * [[https://www.shellhacks.com/telegram-api-send-message-personal-notification-bot/]]   * [[https://www.shellhacks.com/telegram-api-send-message-personal-notification-bot/]]
   * [[https://ugeek.github.io/blog/post/2019-03-14-crea-un-bot-de-telegram-con-bash-y-una-sola-linea-de-terminal.html]]   * [[https://ugeek.github.io/blog/post/2019-03-14-crea-un-bot-de-telegram-con-bash-y-una-sola-linea-de-terminal.html]]
  
 == shell script == shell script
-<code bash>+<code bash; telegram-test.sh>
 #!/bin/bash #!/bin/bash
 +function sendTelegram {
  
-TOKEN="escribe tu token aquí+local TEXT=$1 
-ID="escribe tu id aquí+local SERVER="K0
-MENSAJE="Esto es un Mensaje de Prueba"+#local MESSAGE=$2 
 + 
 +#[[ ! -z "$MESSAGE]] && \ 
 + curl -s -X POST $URL -d chat_id=$CHAT_ID -d text="*${SERVER}*: $TEXT" -d parse_mode="markdown" >> /tmp/telegram.log 
 + 
 +
 + 
 +TOKEN=<YOUR_TOKEN_HERE> 
 +CHAT_ID=<YOUR_CHAT_ID_HERE> 
 +MESSAGE="Hello World"
 URL="https://api.telegram.org/bot$TOKEN/sendMessage" URL="https://api.telegram.org/bot$TOKEN/sendMessage"
  
-curl -s -X POST $URL -d chat_id=$ID -d text="$MENSAJE"+sendTelegram "testing _markdown_ [enlace](https://miguelangel.torresegea.es/wiki)" 
 +</code> 
 + 
 +<code bash; ovh-test> 
 +#!/bin/bash 
 + 
 +function sendTelegram { 
 +    local ID=$1 
 +    local MESSAGE=$2 
 + 
 +    [[ ! -z "$MESSAGE" ]] &&  curl -s -X POST $URL -d chat_id=$CHAT_ID -d text="$ID disponible" >> /tmp/ovh.log 
 +
 + 
 +TOKEN=<YOUR_TOKEN_HERE> 
 +CHAT_ID=<YOUR_CHAT_ID_HERE> 
 +MESSAGE="Hello World" 
 +URL="https://api.telegram.org/bot$TOKEN/sendMessage" 
 +JQ_PATH="/usr/local/bin/" 
 + 
 +wget -O /dev/shm/ovh.json https://ca.ovh.com/engine/api/dedicated/server/availabilities\?country=es > /dev/null 
 + 
 +jsonfiltrado=$(${JQ_PATH}jq '.[] | select(.hardware == "1801sk13") | select(.region == "europe") | .datacenters | .[] | select(.availability != "unavailable")' /dev/shm/ovh.json) 
 +sendTelegram "1801sk13" $jsonfiltrado 
 + 
 +#curl -s -X POST $URL -d chat_id=$CHAT_ID -d text="$MESSAGE" 
 +</code> 
 + 
 +<code bash whois> 
 +#!/bin/bash 
 + 
 +function sendTelegram { 
 + 
 +local TEXT=$1 
 +local SERVER="K0" 
 +#local MESSAGE=$2 
 + 
 +#[[ ! -z "$MESSAGE" ]] && \ 
 +        curl -s -X POST $URL -d chat_id=$CHAT_ID -d text="*${SERVER}*: $TEXT" -d parse_mode="markdown" >> /tmp/telegram.log 
 + 
 +
 + 
 +TOKEN=<YOUR_TOKEN_HERE> 
 +CHAT_ID=<YOUR_CHAT_ID_HERE> 
 +MESSAGE="Hello World" 
 +UR 
 +L="https://api.telegram.org/bot$TOKEN/sendMessage" 
 + 
 +#whois mate.cat | grep Date > ./mate.cat.tmp 
 +whois mate.cat > ./mate.cat.tmp 
 + 
 +[[ -f ./mate.cat.txt ]] && { 
 +    DIFF=$(diff ./mate.cat.txt ./mate.cat.tmp) 
 +    [[ $? != 0 ]] && { 
 +        mv ./mate.cat.tmp ./mate.cat.txt 
 +        sendTelegram "cambios en mate.cat: \`${DIFF}\`" 
 +    } || { 
 +        rm ./mate.cat.tmp 
 +    } 
 +} || { 
 +    whois mate.cat > ./mate.cat.txt 
 +
 </code> </code>
  • software/telegram/start.1565623735.txt.gz
  • Darrera modificació: 12/08/2019 08:28
  • per mate