I'm using a library for accessing telegram via command line in bash linux ubuntu. It is telegram-cli. REFERENCE https://github.com/vysheng/tg
It is an interactive program, which can be launched by
./bin/telegram-cli -k tg-server.pub
It outputs these lines:
Telegram-cli version 1.1.1, Copyright (C) 2013-2014 Vitaly Valtman
Telegram-cli comes with ABSOLUTELY NO WARRANTY; for details type `show_license'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show_license' for details.
I: config dir=[/home/utonto/.telegram-cli]
>
With the ">" prompt. To send a msg, at this prompt you have to type
msg USERNAME This is a test message
I would like to make a script running on my pc, telling me the room temperature when i'm at work. How can I do that? I searched SO and found a similar question. It was advised to use the "expect" command, I made so but it didn't work. Maybe -Surely- cos i'm a beginner. I also tried
echo "msg USERNAME this is a message |
telegram-cli -k ......"
but it didn't work. For your knowledge,on my android i have a telephone number which i use for telegram, but i registered to telegram-cli using another phone. Can someone help me?
See here: remote control with Telegram
To intercept a new incoming message we create a file action.lua
"Lua is a powerful, fast, lightweight, embeddable scripting language.
Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. Lua is dynamically typed, runs by interpreting bytecode for a register-based virtual machine, and has automatic memory management with incremental garbage collection, making it ideal for configuration, scripting, and rapid prototyping."
From http://www.lua.org.
sudo nano /home/pi/tg/action.lua
with this content
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
Save and exit, when incoming text message is "ping", Telegram answers us with a text message containing "pong".
move in tg
cd /home/pi/tg
Then type
bin/telegram-cli -k tg-server.pub -W -s action.lua
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With