Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how does the daemon work #255

Open
politieman opened this issue Sep 20, 2014 · 15 comments
Open

how does the daemon work #255

politieman opened this issue Sep 20, 2014 · 15 comments

Comments

@politieman
Copy link

can i run the daemon and for example send and receive messages through a script?

@vysheng
Copy link
Owner

vysheng commented Sep 20, 2014

I am adding listening socket to client right now. Probably it will be done in a couple of days.

Right now client only can work with commands from stdin. Also you can write lua script, that will check some file peridically and make actions depending of file contents.

@vysheng
Copy link
Owner

vysheng commented Sep 21, 2014

Try -P option for opening listening socket. It is untested though.

@trifox83
Copy link

I tried to run the daemon mode as well with the -P option, it says user telegramd cannot be found.
I'm able to do sending and safe_quit via stdin, but when it comes to reading the reply and getting read receipt, I'm still clueless, so I'm hoping the daemon mode is able to, somehow give me that option.

@vysheng
Copy link
Owner

vysheng commented Sep 21, 2014

Telegram-cli tries to setuid if is run as root. If there is no -u option it tries to use user telegramd.

@politieman
Copy link
Author

thanks for the fast reply, not sure yet how to use the daemon but i supose i should look into linux sockets?

@vysheng
Copy link
Owner

vysheng commented Sep 24, 2014

I've written small page about how I run it as daemon. Not sure if it is suitable for you, but at least you can look there

https://github.com/vysheng/tg/wiki/Running-as-daemon

@Abuarif
Copy link

Abuarif commented Sep 26, 2014

Hi,

Alternatively, I am using Screen using the following steps:

yum install screen

upon successful installation, type cmd

screen -S Telegram
./bin/telegram-cli

change_user_group: can't find the user telegramd to switch to
Telegram-cli version 1.0.5, 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; typeshow_license' for details.

The prompt '>' is only appears after Telegram registration.

You can verify your screen is running by

screen -ls

Test sending a message to your screen using

screen -S Telegram -X stuff "msg "
screen -S Telegram -X stuff "$(printf \r)"

Good luck.

@ImTheDeveloper
Copy link

It is useful to also note that if you use screen you can use the logfile and logflush commands to write all contents of the screen session to a log file. I use this to run an irc telegram bot. The logflush is quite happy running at a 0 settings which is "realtime logging". I then parse out any sent/returned messages via regex. Works extremely well!

@ImTheDeveloper
Copy link

Just noticed since the latest commits the log file is dumping a lot of > in the file every time the screen session flushes. It didn't used to do this with the code I had been using a few months ago. Has something been changed? Is the timed lua scripts causing this? It suggests something is firing every few seconds @vysheng any ideas?

@vysheng
Copy link
Owner

vysheng commented Sep 29, 2014

I'll see. Probably prompt update. You can use '-R' key that disables readline. It would alse diable promt

@ImTheDeveloper
Copy link

@vysheng thanks for getting back to me, I'll give the -R key a test tonight. I'm currently running from an old git version which seems to work fine back in April (prior to the big lua changes) but it would be good to use the latest git version with the new features also.

@ImTheDeveloper
Copy link

@vysheng Thanks for the fix the -R key solves the issue for me perfectly. Do you have any examples (maybe in the wiki) of sending messages via telnet or other means to the port and receiving messages back? If I can complete this last bit I can completely ditch my screen logging option 👍

@vysheng
Copy link
Owner

vysheng commented Oct 10, 2014

It is just text protocol. You can use telnet to try. Commands are just the same as from terminal.

@kreuzebek
Copy link

Run telegram-cli as daemon:
bin/telegram-cli -vvvvRC -k tg-server.pub -W -dL tg.log -P 1234 &

Command Line to access
Send msg:
echo -e 'msg Firstname_Lastname Hello World\r\n' | nc.traditional -w 1 127.0.0.1 1234
Get history:
echo -e 'history Firstname_Lastname\r\n' | nc.traditional -w 1 127.0.0.1 1234

<<< or >>> unread
««« or »»» read

@vysheng
Copy link
Owner

vysheng commented Oct 13, 2014

\r is not necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants