Closed schorschfunke closed 2 weeks ago
Explain better please. You are piping something into matrix-commander-rs
and depending where it comes from it has or does not have a newline? I do not understand. Are you referring to Python matrix-commander
?
No im not piping. Im using matrix-commander-rs. Im using one Python script and start matrix-commander-rs from there with the message as argument with subprocess.run. Now i get an extra newline at the end oft the message. I have written a Rust program from where i start matrix-commander-rs as command . Form here i get no extra newline at the end.
Ok, I understand now.
In your Py and Rust programs you use arguments -m
followed by some local value (text). Correct?
Using --code --notice --emote or --markdown or something?
-
and _
are treated differently. Using any of these special chars?
Run both your programs with -d
to see all debug info. Then compare the 2 sets of debug info, where do they start to differ from each other?
I can see that if something is piped in then the program removes a trailing newline. This is on purpose. And that code is new, v04 or v0.4.1.
https://photos.app.goo.gl/QZQisx9BMbuXFCQp6
Some screenshots. Tomorrow i will try with debug enabled
I see, it is adding a newline to EVERY SINGLE LINE not just one at the end. Correct?
That message with some statistics is 1 single message, right. So, every line has its newline duplicated.
Are you using --code or backticks like ```text```
or like `text` ?
What does the actual String look like that you are passing in?
Are you using something like HTML because the first line seems to be in bold?
Ah, I see that different clients (web browser, phone app) display text and messages differently. They insert space between different messages. Try looking at the messages on different clients if you can, e.g. in a web browser.
What is your client? Does not look like Element?
Start testing with something simple: like echo -e "123\n456" | cargo run -- -m - -d
or echo -e "123\n456" | matrix-commander-rs -m - -d
For this example you should get a debug message like this:
2024-09-04... DEBUG matrix_commander_rs::mclient: In message(): roomnames are ["!...:..."], msgs are ["123\n456"]
How does this line differ between Py and Rust invocation? Is the same text showing up in msgs are [...]
?
No the Client is fluffychat. I will test it later today.
I modify my Rust program and the debug output is the same.
[0m message option is ["Tageswerte für 04
.09.2024:
\n Erzeugt (gesamt) : 3.10 kWh
\n `
Erzeugt (vorne) : 1.97 kWh\n
Erzeugt (hinten) : 1.13 kWh```\n
h```\n ```Last :
3.41 kWh```\n ```Netz
: 0.58 kWh```\n ```Ak
ku (ø) : 48.53 %```\n
```Akku (max) : 79 %```<br>\n
```Selbstversorgung : 2.83 kWh```
<br>\n ```Selbstversorgung :
82.99 %```"].
With MC 0.3.1 and 0.6
Maybe its an matrix-sdk problem
Its not an problem for me. I can change my programs and scripts easyly. I use it as status info for some vm
I just ran this command
echo -e 'Tageswerte für 04.09.2024:\n Erzeugt (gesamt) : 3.10 kWh\n ```Erzeugt (vorne) : 1.97 kWh\n Erzeugt (hinten) : 1.13 kWh```\n```Einspeisung : 0.46 kWh```\n ```Last :3.41 kWh```\n ```Netz: 0.58 kWh```\n ```Akku (ø) : 48.53 %```\n```Akku (max) : 79 %```\n```Selbstversorgung : 2.83 kWh```\n ```Selbstversorgung :82.99 %```' | ./matrix-commander-rs -m -
Which gets me this debug line, same as yours I think.
DEBUG matrix_commander_rs::mclient: In message(): roomnames are ["!...:..."], msgs are ["Tageswerte für 04.09.2024:\n Erzeugt (gesamt) : 3.10 kWh\n ```Erzeugt (vorne) : 1.97 kWh\n Erzeugt (hinten) : 1.13 kWh```\n```Einspeisung : 0.46 kWh```\n ```Last :3.41 kWh```\n ```Netz: 0.58 kWh```\n ```Akku (ø) : 48.53 %```\n```Akku (max) : 79 %```\n```Selbstversorgung : 2.83 kWh```\n ```Selbstversorgung :82.99 %```"]
And on Element webpage it looks ugly because Element shows all the backticks.
Same on Element cell phone app, it shows all the backticks.
Style code
in Element it has to be specified in another way.
My conclusion is, that the client (Element, Fluffychat, etc) interpret the text quite differently.
FluffyChat converts the backticks into style code
but it seems it also inserts new lines.
I think the "problem" is in the client.
Try this anyway, better:
'Tageswerte für 04.09.2024:\n Erzeugt (gesamt) : 3.10 kWh\n ```Erzeugt (vorne) : 1.97 kWh\nErzeugt (hinten) : 1.13 kWh\nEinspeisung : 0.46 kWh\nLast :3.41 kWh\nNetz: 0.58 kWh\nAkku (ø) : 48.53 %\nAkku (max) : 79 %\nSelbstversorgung : 2.83 kWh\nSelbstversorgung :82.99 %```'
Block as much as possible together into the backticked portion. You can test the looks with
echo -e 'Tageswerte für 04.09.2024:\n Erzeugt (gesamt) : 3.10 kWh\n ```Erzeugt (vorne) : 1.97 kWh\nErzeugt (hinten) : 1.13 kWh\nEinspeisung : 0.46 kWh\nLast :3.41 kWh\nNetz: 0.58 kWh\nAkku (ø) : 48.53 %\nAkku (max) : 79 %\nSelbstversorgung : 2.83 kWh\nSelbstversorgung :82.99 %```' | ./matrix-commander-rs -m -
On Element clients this looks the best:
echo -e 'Tageswerte für 04.09.2024:\nErzeugt (gesamt) : 3.10 kWh\nErzeugt (vorne) : 1.97 kWh\nErzeugt (hinten) : 1.13 kWh\nEinspeisung : 0.46 kWh\nLast :3.41 kWh\nNetz: 0.58 kWh\nAkku (ø) : 48.53 %\nAkku (max) : 79 %\nSelbstversorgung : 2.83 kWh\nSelbstversorgung :82.99 %' | ./matrix-commander-rs -m - --code
Note the use of --code
If you are satisfied, close the issue. I think there is little I can do.
Thank you for your help! I close the issue
Hi, from version 0.4 or 0.4.1 there is a extra newline at the end of my messages send with matrix-conmander. This happens with messages send from my Python scripts. With messages send from Rust it doesn't