crowbartools / Firebot

A powerful all-in-one bot for Twitch streamers
https://firebot.app
GNU General Public License v3.0
316 stars 88 forks source link

[Bug] $readFile: Reading the last line of a text file does not work correctly #2589

Open DontCallMeChicken opened 3 days ago

DontCallMeChicken commented 3 days ago

Is there an existing issue for this?

Current Behavior

Expected Behavior

The "last" option should output the last line of the specified text file. The "random" option should also output the last line of the text file.

The variable $readFile[path\to\file.txt] outputs the entire text file completely and correctly. These options read the text file correctly: "first" and "specific line number".

The variable $fileLineCount[path/to/file.txt] shows the correct number of existing lines in the text file.

Steps To Reproduce

No response

Version

5.62.1

What operating system are you using Firebot on?

Linux Distro

Relevant log output

No meaningful log entries available.

Contact Details (Optional)

Discord: DCMC (dontcallmechicken.dcmc)

CKY- commented 3 days ago

is the file ending in a new line ?

DontCallMeChicken commented 3 days ago

is the file ending in a new line ?

No, the end of the file, i.e. the last line, is also the last entry. Not an empty line. I have also tested it with other text files that have existed for a long time and have always worked. The error also occurs there.

The effects and commands that use this variable no longer work correctly.

CKY- commented 3 days ago
  • Variable $readFile[path\to\file.txt, last] don't work. Nothing is output when reading the last line of a text file.
  • Variable $readFile[path\to\file.txt, random]. Only outputs the lines before the last one. If the last line appears to be output, nothing is displayed. Just like with the "last" option.

im going to ping you in discord i cant replicate this. lets see if we can diagnose it a bit?

DontCallMeChicken commented 3 days ago

im going to ping you in discord i cant replicate this. lets see if we can diagnose it a bit?

Okay. I'm excited! :)

CKY- commented 3 days ago

firebot appends a new line on all file writes firebot when firebot tries to read in the last line or a random line the appended NewLine returns a blank entry.

this is a 2 fold issue. with the file write and file read. thank you for the info in discord. the issue is under the same tittle