vysheng / tg

telegram-cli
GNU General Public License v2.0
6.49k stars 1.54k forks source link

Sending messages with tg-cli #1587

Open BonefaceJohnson opened 5 years ago

BonefaceJohnson commented 5 years ago

I want to send a message with tg-cli, depending on an input event, e.g. a high GPIO Pin, with lua. But i can't find any "write message function" in lua, which can write a msg independently from any incoming msg.

Thanks for any help, cheers.

Paulchen232 commented 5 years ago

Write in "function on_msg_receive (msg)" this "send_msg (msg.from.print_name, res, ok_cb, false)" where res = message what you liked write. How you can it depending on GPIO Pin?

BonefaceJohnson commented 5 years ago

Thanks for your answer, but with your solution the Raspi will just answer on a received messsage. My aim is to let Raspi send a message by itself. To read or control the gpio with Lua I'm using the lua-peripherie library.

Paulchen232 commented 5 years ago

Ok perhaps you can use the cron function. This function works all seconds. You have to remember that. For "msg.from.print_name" you must use the name whom send the message. I don't now the lua-peripherie. Have you a link where i can find Infos.

Paulchen232 commented 5 years ago

I think you can send_msg (... in all function with name whom send the message as "msg.from.print_name" use.

BonefaceJohnson commented 5 years ago

Alright i will try it, thanks. For Lua-periphery visit https://luarocks.org/modules/vsergeev/lua-periphery but in order to install it you need lua rocks https://github.com/luarocks/luarocks/wiki/Download

Paulchen232 commented 5 years ago

Thank you!

BonefaceJohnson commented 5 years ago

send_msg (...) alone, isn't working... It seems it must be inside a function_on... (...) ... end

Paulchen232 commented 5 years ago

@BonefaceJohnson I have try it with the cron function. And it work! I have used a boolean variable. I set it true with a message. I use the startoption -W. If you use the username then forget not the @ sign.