Si vous avez besoin d'un simple robot Telegram capable d'exécuter des scripts (écrits dans n'importe quelle langue) et de répondre avec du texte et des images, alors sous cat. Vous y trouverez une histoire sur un moteur de bot qui fait ce que vous voulez.

Une courte liste des fonctionnalités du moteur:
- Le moteur peut servir plusieurs robots à la fois
- Le bot exécute des scripts (écrits dans n'importe quelle langue)
- , ( )
- ( )
- HTTP, , "" ( cron-)
: , IP-, SSL-… , . , , .
, .
Go. , root-. , , , , .
:
cd tmp
git clone https://github.com/michurin/cnbot.git
cd cnbot
go build ./cmd/...
./cnbot
( ) , . , .
, . : Telegram.
(config.yaml):
bots:
firstBot:
token: "22222222:AAAAAAAAAAAAAA"
script: "/usr/bin/true"
( - , /bin/rm). (-i):
./cnbot -i -c config.yaml
, .
( -i)
./cnbot -c config.yaml
Telegram-.
user 500050880 is not allowed
user_id ( ),
bots:
firstBot:
token: "22222222:AAAAAAAAAAAAAA"
script: "/bin/echo"
allowed_users: [500050880]
, echo script. ( ) echo-. . hi, Hi!, -n hi.
(-n echo). : ; , , , ; .
. /bin/echo :
#!/bin/sh
env
Hello!
BOT_TEXT=Hello!
BOT_FROM_FIRSTNAME=Alexey
BOT_NAME=firstBot
BOT_CHAT=500050880
BOT_FROM=500050880
, , ID , , ( ; , ).
, . , white list . ID — . . demo.sh.
, PATH . , .
#!/bin/sh
echo '%!PRE'
env | sort
. markdown, . demo.sh.
, stdout:
#!/bin/sh
curl -qfs https://golang.org/lib/godoc/images/footer-gopher.jpg
, "empty", , "".
demo-, .
HTTP bind_address :
bots:
firstBot:
token: "22222222:AAAAAAAAAAAAAA"
script: "/bin/echo"
allowed_users: [500050880]
bind_address: ":9091"
:
echo "ok" | curl -qfsX POST --data-binary @- "http://:9091/500050880"
, , . , output . , .
multipart/form-data:
curl -qfsX POST -F to=500050880 -F msg=ok "http://:9091"
, . , , . , demo-. http- . readme , , , .
, , — .
!
...
..., , .
- . , . , , . , . .
, . : , , VPN, … , , - , .
, , , Telegram API . - bash+curl+jq, , .
. . , , - .
, . (), … , , . , , , .
2018 Go , , Go. :-) , , Go . , Go, Go, "" ( ).
. cnbot, .
?
, . . - , — . .
Mais j'aimerais développer le moteur vers l'intégration: pour en distinguer une partie simple qui pourrait être connectée par une bibliothèque à n'importe quel programme Go. Classiquement, si vous avez déjà un microservice pour ... à quoi sert-il ... même pour le rendu de scènes 3D, vous pouvez y intégrer un bot chat en une ou deux lignes pour un diagnostic opérationnel / surveillance / contrôle ... Cela, me semble-t-il, serait utile. En fait, vous pouvez le faire maintenant. Ce n'est tout simplement pas très pratique.