Envoyer des messages Telegram
Installer les bibiliothèques nécessaires
pgd@rpi01:~ $ sudo apt install -y libreadline-dev libconfig-dev libssl-dev
pgd@rpi01:~ $ sudo apt install -y lua5.2 liblua5.2-dev
pgd@rpi01:~ $ sudo apt install -y libevent-dev libjansson-dev libpython-dev libssl1.0-dev make git
pgd@rpi01:~ $ cd ~
pgd@rpi01:~ $ git clone --recursive https://github.com/vysheng/tg
Compiler telegram-cli
nano ~/tg/tgl/mtproto-utils.c
-> ctrl+w : BN2ull
-> Change assert (0); by //assert (0);
-> ctrl+x
pgd@rpi01:~ $ cd ~/tg
pgd@rpi01:~ $ ./configure
pgd@rpi01:~ $ ./configure "CFLAGS=-m64" "CXXFLAGS=-m64" "LDFLAGS=-m64"
pgd@rpi01:~ $ make
pgd@rpi01:~ $ cd ~/tg
pgd@rpi01:~ $ bin/telegram-cli -k tg-server.pub -W
Configurer lua
lua est un langage de script puissant et rapide. La syntaxe est simple.
pgd@rpi01:~ $ sudo nano /home/pi/tg/action.lua
function on_msg_receive (msg)
if msg.out then
return
end
if (msg.text=='ping') then
send_msg (msg.from.print_name, 'pong', ok_cb, false)
end
end
function on_our_id (id)
end
function on_secret_chat_created (peer)
end
function on_user_update (user)
end
function on_chat_update (user)
end
function on_get_difference_end ()
end
function on_binlog_replay_end ()
end
Tester
pgd@rpi01:~ $ cd /home/pi/tg
pgd@rpi01:~ $ bin/telegram-cli -k tg-server.pub -W -s action.lua
git clone --recursive https://github.com/kenorb-contrib/tg.git