topkecleon / telegram-bot-bash

Telegram bot written in bash
Other
431 stars 123 forks source link

Json2Array broke mutlistring message handling. #133

Closed vevsvevs closed 4 years ago

vevsvevs commented 4 years ago

Describe the bug New Json2Array sed regex pattern doesn't work well with multi-string messages.

To Reproduce Send any multi-string message to the bot and try to see MESSAGE contain.

Expected behavior MESSAGE should contain the whole text.

Screenshots If applicable, add screenshots to help explain your problem.

Bashbot (please complete the following information):

Additional context Add any other context about the problem here.

gnadelwartz commented 4 years ago

can you provide an example JSON content of a multistring message, then I can have a look at the problem.

vevsvevs commented 4 years ago

Do you mean smth like this?

["ok"]  true
["result",0,"update_id"]    115013438
["result",0,"message","message_id"] 1585
["result",0,"message","from","id"]  558398329
["result",0,"message","from","is_bot"]  false
["result",0,"message","from","first_name"]  "vevs"
["result",0,"message","from","username"]    "vevsvevs"
["result",0,"message","from","language_code"]   "ru"
["result",0,"message","chat","id"]  558398329
["result",0,"message","chat","first_name"]  "vevs"
["result",0,"message","chat","username"]    "vevsvevs"
["result",0,"message","chat","type"]    "private"
["result",0,"message","date"]   1592991924
["result",0,"message","text"]   "string 1
string 2
string 3"
gnadelwartz commented 4 years ago

Ok, I see, usually Telegram send this as: ["result",0,"message","text"] "string1\nstring2\nstring3"

I'll have a look

gnadelwartz commented 4 years ago

if I send my bot

test1 test2 test3

I got: ["result",0,"message","text"] "test1\ntest2\ntest3"

how did you create the multi line message?

vevsvevs commented 4 years ago

By writing several words followed by "enter" :) Tested with 2.1.13 desktop and 6.2.0 (1988) Android versions, same result: I get linefeed (newline), not "\n". Maybe you're using non-Unicode client implementation or smth?

gnadelwartz commented 4 years ago

thats really strange, if've test it with with Abdroid 6.2.0 and Telegram web and I got "test\ntest\ntest".

Nevertheless I'll try to implement a solution ...

gnadelwartz commented 4 years ago

even I cannot reproduce it, I implemented a solution to "merge" multiline strings in one line: https://github.com/topkecleon/telegram-bot-bash/commit/ea92c55c0c0a33b31a1f2a79de9802dd9634e41b

to investigate further: pls open a chat with my bot user @Deal_O_Mat_bot name DealOMat and send a multi line message like you described:

multi
line
test
Gnadelwartz

then I can consult my logfiles to see if I find more information about your issue

vevsvevs commented 4 years ago

to investigate further: pls open a chat with my bot user @Deal_O_Mat_bot name DealOMat and send a multi line message like you described:

Done, please check.

gnadelwartz commented 4 years ago

thanks for this, unfortunately my bot was down this afternoon because of connection problems, can you repeat the test again, pls

vevsvevs commented 4 years ago

@gnadelwartz sure, done :)

gnadelwartz commented 4 years ago

thanks, the result is the same as with my tests:

["result",0,"message","text"] "multi\nline\ntest\nGnadelwartz"

I see some possibilities for this:

nevertheless, the fix should hopefully make bashbot working for you. try current master.

vevsvevs commented 4 years ago

@gnadelwartz yep, now it works perfectly, thank you!

vevsvevs commented 4 years ago

Sorry for disturbing, but I've faced probably a related issue: now multi-string replies don't handle properly.

vevsvevs commented 4 years ago

Also, seems like something is wrong with the debug feature: bashbot.log collects every message without debug option, and no log file created at all with this option.

gnadelwartz commented 4 years ago

bashbot shoild log every activity (with the first 50 char of the message text) in all cases.

the difference is: with debug errors und additionally logging is done in debug log and full message content is logged in message log.

I'll check what's happen with and without debug in a fresh Installation

gnadelwartz commented 4 years ago

Sorry for disturbing, but I've faced probably a related issue: now multi-string replies don't handle properly.

hm, really strange, your Telegram server seems to handle Multiline totally different than the one used for my bot. where are you located?

so for example what's te result if send a message like

send_normal_message "CHAT[ID]" "This is\na muli line\nmessage"

or

send_normal_message "CHAT[ID]" "This is
a muli line
message"
gnadelwartz commented 4 years ago

https://github.com/topkecleon/telegram-bot-bash/blob/487deee08cd4e69cb6ad537cfcfefdf8e3cf75a0/modules/sendMessage.sh#L32

try if it's working better if you comment out this line

vevsvevs commented 4 years ago

Sorry for the delay, I have some trouble, I'll try to check in next couple days.

gnadelwartz commented 4 years ago

I'll close the issue until you provide more feedback as it seems very specific to your environment

gnadelwartz commented 4 years ago

154

gnadelwartz commented 4 years ago

removed json.sh flag -s in development version, let's see if it works better...

6ec00d49b3e1510fb3edb2122524dd7c606ddf74

gnadelwartz commented 4 years ago

no response, let's close