Open j-ed opened 8 years ago
Using daemon mode works:
bemod@wohnpi:~$ /usr/bin/telegram-cli -W -k /etc/telegram-cli/server.pub -vvvRC -d
bemod@wohnpi:~$ echo "create_secret_chat be_handy" | nc -q 1 localhost 1234
bemod@wohnpi:~$ echo 'msg !_be_handy hurz' | nc -q 1 localhost 1234
bemod@wohnpi:~$ echo "safe_quit" | nc -q 1 localhost 1234
results in:
*** restarting query 3698697603188564
*** outbound rpc connection from dc #1 becomed ready
*** outbound rpc connection from dc #3 becomed ready
*** adjusting CLOCK_MONOTONIC delta to -0.609796
*** bad_msg_notification: msg_id = 6237134855663813632, seq = 2, error = 64
*** bad_msg_notification: msg_id = 6237134855663813632, seq = 2, error = 64
*** failing session -3866091081797299784
*** adjusting CLOCK_MONOTONIC delta to -0.604828
*** outbound rpc connection from dc #5 becomed ready
*** adjusting CLOCK_MONOTONIC delta to 0.659910
*** Accepting incoming connection
*** Read from incoming connection
*** Closing incoming connection
*** lua: attempt to call a nil value
*** lua: attempt to call a nil value
Secret chat !_be_handy updated access_hash
*** Secret chat in ok state
*** lua: attempt to call a nil value
Secret chat !_be_handy updated status
[20:49] !_be_handy be Pi updated layer to 17
*** qts = 991048472, qts_count = 1
[20:49] !_be_handy be handy updated layer to 23
*** Accepting incoming connection
*** Read from incoming connection
*** Closing incoming connection
[20:49] !_be_handy <<< hurz
*** Accepting incoming connection
*** Read from incoming connection
*** Closing incoming connection
[warn] Epoll MOD(4) on fd 12 failed. Old events were 6; read change was 2 (del); write change was 0 (none): Bad file descriptor
[warn] Epoll MOD(1) on fd 12 failed. Old events were 6; read change was 0 (none); write change was 2 (del): Bad file descriptor
All done. Exit
ยดยดยด
I've run several tests now on my server but running telegram-cli as a deamon doesn't solve the problem for me. As soon as I send the create_secret_chat
command to the deamon, it returns the following error:
ANSWER 31
FAIL: 38: can not parse arg #1
The deamon itself displays the following messages:
*** Accepting incoming connection
*** Read from incoming connection
*** Closing incoming connection
Have you used the -W argument to run the daemon? What does contact_list
show?
@beMoD You're right, -W did the trick. Thank you very much :-) Nevertheless shouldn't it be possible to send secret chat messages on the command line too?
I just realized that using the create_secret_chat
command in a batch file always creates new chats. One way would be to read the reply of that command and save the chat id of the created chat for the future, e.g. '!_TOM#1'. Is there any way to show a list of already created chats before a create_secret_chat command is initiated again?
I currently am not able to test, but perhaps dialog_list
?
Unfortunately not, because it only returns
ANSWER 19
User TOM: 0 unread
I've now created a wrapper script which first eavaluates if a secret chat should be initiated. Next it tries to send a secret chat message. If that fails with the following error
# echo "msg !_TOM#1 'Hello world!'" | nc -q 1 localhost 1234
ANSWER 38
FAIL: 22: secret chat not in ok state
it sends a create_secret_chat TOM
command first and resends the previous message again.
Is it a shell script? If so, I would like to have it :-)
Here it is: send-telegram-message.txt
Thank you :-)
Hi @j-ed and @beMoD
Kind of on the same topic, how can I read a message received through a secret chat? On the CLI I see this when a message is received:
*** 1497377792.640274 qts = 2353109, qts_count = 1
{"id": "04000000d01e7a01cfd95c01baf25c6b8322f490a0f06f92", "event": "message"}
But how do I actually get the contents of it? I've tried with get_message <msg-id>
and view <msg-id>
but both return nothing useful.
Hope you can help me out, thanks! ๐
@noplanman I think you're misinterpreting the given id, it's not the a message id from my point of view.
The message number display need to be enabled first by executing set msg_num 1
. Then you can show all available message by executing history <user-name>
. The first number in each row is the message id which can be used to select a specific message, e.g. get_message <msg-id>
.
With normal messages it works fine, but not with secret chat ones.
I see the messages in history !_<user-name>
but I can't access the decrypted version ๐
Have you tried and tested it with a secret chat? What version of tg-cli are you using?
> version
Telegram-cli version 1.4.1 (uses tgl version 2.1.0)
uses libopenssl for encryption
@noplanman I don't now how it works with secret chats. BTW, I think this is not a general issue ticket to ask non-related questions. Best would be to open a new ticket for your question.
I think this is not a general issue ticket
Yes I know, but since the topic was about sending secret chats via CLI, it fit quite well ๐
Will do some more testing and then possibly make a new issue, thanks for your responses by the way ๐
I've compiled the telegram-cli binary, based on todays source code. If I try to send a secure chat message from the command line, it usually fails and an error message is displayed. (Using telegram-cli in interactive mode works like a charme)
Based on what I've found on the Internet, in the documentation or on GitHub, I've tried to send a message using several different ways, but without success:
I've also tried to separate the two commands using a semi-colon or using '-e' multiple times, but without success. So if someone could shed some light on how the command need to be called, I would appreciate it.