Files
VOREStation/code/modules/admin/news.dm
T
Kashargul 89fb9871e0 next set of admin verbs (#19260)
* next set of admin verbs

* invoke

* .

* a few more

* few more

* .

* few more

* some more

* move thos

* next

* some debug verbs

* axe the old mod loading

* del

* is local for some verbs

* few more

* .

* .

* .

* Add local narrate.

* Fixes this

Needed to be user.mob, since user is  the client and usr was the old user.mob

* fixes

* .

* .

* .

* .

---------

Co-authored-by: Cameron Lennox <killer65311@gmail.com>
2026-03-21 17:16:41 -04:00

118 lines
5.6 KiB
Plaintext

#define NEWSFILE "data/news.sav" //where the memos are saved
/client/
//var/last_news_hash = null // Stores a hash of the last news window it saw, which gets compared to the current one to see if it is different.
// Returns true if news was updated since last seen.
/client/proc/check_for_new_server_news()
var/savefile/F = get_server_news()
if(F)
if(md5(F["body"]) != prefs.lastnews)
return TRUE
return FALSE
ADMIN_VERB(modify_server_news, R_SERVER|R_EVENT, "Modify Public News", "Modify the public news message.", ADMIN_CATEGORY_SERVER_GAME)
var/savefile/F = new(NEWSFILE)
if(F)
var/title = F["title"]
var/body = html2paper_markup(F["body"])
var/new_title = tgui_input_text(user, "Write a good title for the news update. Note: HTML is NOT supported.", "Write News", title, MAX_MESSAGE_LEN)
if(!new_title)
return
var/new_body = tgui_input_text(user, "Write the body of the news update here. Note: HTML is NOT supported, however paper markup is supported. \n\
Hitting enter will automatically add a line break. \n\
Valid markup includes: \[b\], \[i\], \[u\], \[large\], \[h1\], \[h2\], \[h3\]\ \[*\], \[hr\], \[small\], \[list\], \[table\], \[grid\], \
\[row\], \[cell\], \[logo\], \[talogo\], \[sglogo\].","Write News", body, MAX_MESSAGE_LEN, TRUE, prevent_enter = TRUE)
new_body = paper_markup2html(new_body)
if(findtext(new_body,"<script",1,0) ) // Is this needed with santize()?
return
F["title"] << new_title
F["body"] << new_body
F["author"] << user.key
F["timestamp"] << time2text(world.realtime, "DDD, MMM DD YYYY")
message_admins("[user.key] modified the news to read:<br>[new_title]<br>[new_body]")
/proc/get_server_news()
var/savefile/F = new(NEWSFILE)
if(F)
return F
// This is used when submitting the news input, so the safe markup can get past sanitize.
/proc/paper_markup2html(var/text)
text = replacetext(text, "\n", "<br>")
text = replacetext(text, "\[center\]", "<center>")
text = replacetext(text, "\[/center\]", "</center>")
text = replacetext(text, "\[br\]", "<BR>")
text = replacetext(text, "\[b\]", "<B>")
text = replacetext(text, "\[/b\]", "</B>")
text = replacetext(text, "\[i\]", "<I>")
text = replacetext(text, "\[/i\]", "</I>")
text = replacetext(text, "\[u\]", "<U>")
text = replacetext(text, "\[/u\]", "</U>")
text = replacetext(text, "\[large\]", "<font size=\"4\">")
text = replacetext(text, "\[/large\]", "</font>")
text = replacetext(text, "\[h1\]", "<H1>")
text = replacetext(text, "\[/h1\]", "</H1>")
text = replacetext(text, "\[h2\]", "<H2>")
text = replacetext(text, "\[/h2\]", "</H2>")
text = replacetext(text, "\[h3\]", "<H3>")
text = replacetext(text, "\[/h3\]", "</H3>")
text = replacetext(text, "\[*\]", "<li>")
text = replacetext(text, "\[hr\]", "<HR>")
text = replacetext(text, "\[small\]", "<font size = \"1\">")
text = replacetext(text, "\[/small\]", "</font>")
text = replacetext(text, "\[list\]", "<ul>")
text = replacetext(text, "\[/list\]", "</ul>")
text = replacetext(text, "\[table\]", "<table border=1 cellspacing=0 cellpadding=3 style='border: 1px solid black;'>")
text = replacetext(text, "\[/table\]", "</td></tr></table>")
text = replacetext(text, "\[grid\]", "<table>")
text = replacetext(text, "\[/grid\]", "</td></tr></table>")
text = replacetext(text, "\[row\]", "</td><tr>")
text = replacetext(text, "\[cell\]", "<td>")
text = replacetext(text, "\[logo\]", "<img src=\ref['html/images/ntlogo.png']>") // Not sure if these would get used but why not
text = replacetext(text, "\[talogo\]", "<img src=\ref['html/images/talonlogo.png']>")
text = replacetext(text, "\[sglogo\]", "<img src=\ref['html/images/sglogo.png']>")
return text
// This is used when reading text that went through paper_markup2html(), to reverse it so that edits don't need to replace everything once more to avoid sanitization.
/proc/html2paper_markup(var/text)
text = replacetext(text, "<br>", "\[br\]")
text = replacetext(text, "<center>", "\[center\]")
text = replacetext(text, "</center>", "\[/center\]")
text = replacetext(text, "<BR>", "\[br\]")
text = replacetext(text, "<B>", "\[b\]")
text = replacetext(text, "</B>", "\[/b\]")
text = replacetext(text, "<I>", "\[i\]")
text = replacetext(text, "</I>", "\[/i\]")
text = replacetext(text, "<U>", "\[u\]")
text = replacetext(text, "</U>", "\[/u\]")
text = replacetext(text, "<font size=\"4\">", "\[large\]")
text = replacetext(text, "</font>", "\[/large\]")
text = replacetext(text, "<H1>", "\[h1\]")
text = replacetext(text, "</H1>", "\[/h1\]")
text = replacetext(text, "<H2>", "\[h2\]")
text = replacetext(text, "</H2>", "\[/h2\]")
text = replacetext(text, "<H3>", "\[h3\]")
text = replacetext(text, "</H3>", "\[/h3\]")
text = replacetext(text, "<li>", "\[*\]")
text = replacetext(text, "<HR>", "\[hr\]")
text = replacetext(text, "<font size = \"1\">", "\[small\]")
text = replacetext(text, "</font>", "\[/small\]")
text = replacetext(text, "<ul>", "\[list\]")
text = replacetext(text, "</ul>", "\[/list\]")
text = replacetext(text, "<table border=1 cellspacing=0 cellpadding=3 style='border: 1px solid black;'>", "\[table\]")
text = replacetext(text, "</td></tr></table>", "\[/table\]")
text = replacetext(text, "<table>", "\[grid\]")
text = replacetext(text, "</td></tr></table>", "\[/grid\]")
text = replacetext(text, "</td><tr>", "\[row\]")
text = replacetext(text, "<td>", "\[cell\]")
text = replacetext(text, "<img src=\ref['html/images/ntlogo.png']>", "\[logo\]") // Not sure if these would get used but why not
text = replacetext(text, "<img src=\ref['html/images/talonlogo.png']>", "\[talogo\]")
text = replacetext(text, "<img src=\ref['html/images/sglogo.png']>", "\[sglogo\]")
return text
#undef NEWSFILE