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

Wishlist - include a cmd line switch to disable color-codes #30

Open
malfino opened this issue Aug 3, 2016 · 2 comments
Open

Wishlist - include a cmd line switch to disable color-codes #30

malfino opened this issue Aug 3, 2016 · 2 comments

Comments

@malfino
Copy link

malfino commented Aug 3, 2016

there is this home automation service "fhem" that is widely used in Germany. We have managed to integrate your cmdline tool in a way, that your home can send status updates to your phone via signal.. A fellow user raised the question, if it'd be possible to have a bidirectional communication via signal.

We have come up with the following solution, that works.
/opt/textsecure/bin/textsecure -to="+49157xxxxxxxxx" | while read line; do mes=$(echo $line| sed -r "s/\x1B\[([0-9]{1,3}((;[0-9]{1,3})*)?)?[m|K]//g" | awk '{ print substr($0, index($0,$5)) }'); $process_in_other_application $mes ; done
As you can see, we need to filter out the color-codes (sed) and suppress columns 1-4 in order to receive the plain responses and act on it.

It'd be much easier, if you could add a -raw cmd-line switch that only outputs the plain message.

Additionally someone could easily tunnel a telnet or ssh session through signal, if the additional characters could be suppressed.

The following almost works, but the color-codes and other text are problematic.

mkfifo ts
nc server 23 < ts | /opt/textsecure/bin/textsecure -raw -to="+4915xxxx" > ts

It might seem purely cosmetic, but it would make shell integration much easier, if you could implement that raw mode.

@malfino malfino changed the title Wishlist - include switches to disable color-codes Wishlist - include a cmd line switch to disable color-codes Aug 3, 2016
@janimo
Copy link
Owner

janimo commented Aug 4, 2016

The included cmdline client is not meant to be more than a simple demo, a test of the API and an example of how to build task specific ones if one so wishes. So maybe forking the tool (having a simple go cmd in a repo depending on the lib is enough) is another option, especially if further features needed for such a use case are foreseen.

OTOH a raw mode is possible to add I guess, not sure when I can get around to it.

morph027 referenced this issue in signal-golang/textsecure Aug 13, 2017
@morph027
Copy link

Trying the same here ;)

Having a bot for fun (and useful purposes later for sure). However, i'm no good programmer, so my attempt is similar to @malfino , just using existent linux stuff to mis-use your program. I could probably create my own cmd, but this would be copy and pasting your code pretty much.

I also added a little -hook cmd line switch to my local fork so textsecure is now running as daemon and sends messages to an external parser to deal with.

Communication is done via named pipe (pulled up by systemd), so the flow is:

Incoming Message > textsecure cmd > parser script (which can do stuff and answer by talking to the named pipe)

Lastly, i've added a little keyword parser into the message part which scans for slashed commands and execute other stuff based on it (all ugly, but works). Example: If i send \attachment:/tmp/whatever.jpg this one gets sent as file attachment instead of text message.

@morph027 morph027 mentioned this issue Aug 13, 2017
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

3 participants