Sending a json message with /tellraw with a cron expression

Hello all,

I’ve been trying at this for a little while now. My aim is to send a json message via /tellraw to my server on a fixed interval using the Scheduling tab. Here is an example message:

/tellraw @a ["",{"text":"[Server] ","color":"dark_red","bold":true,"hoverEvent":{"action":"show_text","value":{"text":"","extra":[{"text":"This is a scheduled server message.","color":"gray"}]}}},{"text":"Please put all community items back in a chest before logging off!","color":"aqua","bold":false}]

Digging through the forums, I found that not only did I have to escape each ", I also had to escape each \ as well. So, I ended up with this:

/tellraw @a [\\"\\",{\\"text\\":\\"[Server] \\",\\"color\\":\\"dark_red\\",\\"bold\\":true,\\"hoverEvent\\":{\\"action\\":\\"show_text\\",\\"value\\":{\\"text\\":\\"\\",\\"extra\\":[{\\"text\\":\\"This is a scheduled server message.\\",\\"color\\":\\"gray\\"}]}}},{\\"text\\":\\"Please put all community items back in a chest before logging off!\\",\\"color\\":\\"aqua\\",\\"bold\\":false}]/tellraw @a [\\"\\",{\\"text\\":\\"[Server] \\",\\"color\\":\\"dark_red\\",\\"bold\\":true,\\"hoverEvent\\":{\\"action\\":\\"show_text\\",\\"value\\":{\\"text\\":\\"\\",\\"extra\\":[{\\"text\\":\\"This is a scheduled server message.\\",\\"color\\":\\"gray\\"}]}}},{\\"text\\":\\"Please put all community items back in a chest before logging off!\\",\\"color\\":\\"aqua\\",\\"bold\\":false}]

This works fine if I manually send it via the console. However, whenever I attempt to put this into a cron expression, like this:

[hash]
command=stuff
source=* * * * *
msg=tellraw @a [\"\",{\"text\":\"[Server] \",\"color\":\"dark_red\",\"bold\":true,\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"This is a scheduled server message.\",\"color\":\"gray\"}]}}},{\"text\":\"Please remember to put all community items in a chest before logging off!\",\"color\":\"aqua\",\"bold\":false}]
enabled=true

no matter how many \s I put, it always boils down to one . I figured I need 4 \s (to boil down to 2 for the command). Then, since the "s are not properly escaped, the message never sends (nor do I get an error). I have tried creating these cron expressions via the web UI and directly editing cron.config. In both cases, once the cron job is started or another one is edited, I always end up with one \s.

Is there a workaround to have whatever interprets the cron expressions and command literally or to somehow not treat the \ as an escape character? I have tried quotes, and this did fix the escape character issue. But, Minecraft then did not recognize '/tellraw as a command.

My final goal is to put this:

/tellraw @a [\\"\\",{\\"text\\":\\"[Server] \\",\\"color\\":\\"dark_red\\",\\"bold\\":true,\\"hoverEvent\\":{\\"action\\":\\"show_text\\",\\"value\\":{\\"text\\":\\"\\",\\"extra\\":[{\\"text\\":\\"This is a scheduled server message.\\",\\"color\\":\\"gray\\"}]}}},{\\"text\\":\\"Please put all community items back in a chest before logging off!\\",\\"color\\":\\"aqua\\",\\"bold\\":false}]/tellraw @a [\\"\\",{\\"text\\":\\"[Server] \\",\\"color\\":\\"dark_red\\",\\"bold\\":true,\\"hoverEvent\\":{\\"action\\":\\"show_text\\",\\"value\\":{\\"text\\":\\"\\",\\"extra\\":[{\\"text\\":\\"This is a scheduled server message.\\",\\"color\\":\\"gray\\"}]}}},{\\"text\\":\\"Please put all community items back in a chest before logging off!\\",\\"color\\":\\"aqua\\",\\"bold\\":false}]

into a scheduled task.

I don’t know anything about working with JSON, but if you are trying to send a command to the world server, how are you specifying that in the OS console?
Are you using the correct permissions?
Is the script even executable?

Hi! Sorry for the delayed response.

I was using a scheduled task with the “Send to console” command to run on the web UI. The main issue was not getting the task to execute, rather, have the ‘’ characters not interpreted as escape characters. I ended up adding crontabs in the OS’s built-in crontab manager sending commands to the MineOS console with the json message.

I’m not much into coding, but found this link: https://www.freeformatter.com/json-escape.html

I’m not even sure if it’s useful.

Hey there.
If you are not afraid of ssh then i suggest you to try it out as a root with the following command:
/usr/games/minecraft/mineos_console.js -s *yourserversname* stuff '/tellraw *massage*'
If this works then your best option would be the linux’s crontab directly. Escaping in linux is more tracable so try to echo *massage* if you are unsure about the escaping.

Edit:
If this does not work then copy this massage into a text file and in the first command line instead of your massage write $(cat *path to your txt file*)

Edit2:
You do not need to escape the escape . So you need only one \ everywhere.

Edit3:
On third thought you do not even need any escape just put your whole massage in '-s. So your command should look like /usr/games/minecraft/mineos_console.js -s *yourserversname* stuff '/tellraw @a *massage*' where the massage is the clean json text.

1 Like

Hi!

That’s exactly what I was trying, but however MineOS parses the escape sequences was messing something up! Thanks for the response however!

Thanks! I did end up using Linux’s crontab directly, however, escape characters were still needed. I will look into your third edit however. Definitely not afraid of using shh :slight_smile: