-
-
Notifications
You must be signed in to change notification settings - Fork 444
/
Copy pathworld_topic.dm
315 lines (254 loc) · 9.73 KB
/
world_topic.dm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
// SETUP
/proc/TopicHandlers()
. = list()
var/list/all_handlers = subtypesof(/datum/world_topic)
for(var/I in all_handlers)
var/datum/world_topic/WT = I
var/keyword = initial(WT.keyword)
if(!keyword)
stack_trace("[WT] has no keyword! Ignoring...")
continue
var/existing_path = .[keyword]
if(existing_path)
stack_trace("[existing_path] and [WT] have the same keyword! Ignoring [WT]...")
else if(keyword == "key")
stack_trace("[WT] has keyword 'key'! Ignoring...")
else
.[keyword] = WT
// DATUM
/datum/world_topic
var/keyword
var/log = TRUE
var/key_valid
var/require_comms_key = FALSE
/datum/world_topic/proc/TryRun(list/input)
key_valid = config && (CONFIG_GET(string/comms_key) == input["key"])
if(require_comms_key && !key_valid)
return "Bad Key"
input -= "key"
. = Run(input)
if(islist(.))
. = list2params(.)
/datum/world_topic/proc/Run(list/input)
CRASH("Run() not implemented for [type]!")
// TOPICS
/datum/world_topic/ping
keyword = "ping"
log = FALSE
/datum/world_topic/ping/Run(list/input)
. = 0
for (var/client/C in GLOB.clients)
++.
/datum/world_topic/playing
keyword = "playing"
log = FALSE
/datum/world_topic/playing/Run(list/input)
return GLOB.player_list.len
/datum/world_topic/pr_announce
keyword = "announce"
require_comms_key = TRUE
var/static/list/PRcounts = list() //PR id -> number of times announced this round
/datum/world_topic/pr_announce/Run(list/input)
var/list/payload = json_decode(input["payload"])
var/id = "[payload["pull_request"]["id"]]"
if(!PRcounts[id])
PRcounts[id] = 1
else
++PRcounts[id]
if(PRcounts[id] > PR_ANNOUNCEMENTS_PER_ROUND)
return
var/final_composed = span_announce("PR: [input[keyword]]")
for(var/client/C in GLOB.clients)
C.AnnouncePR(final_composed)
/datum/world_topic/ahelp_relay
keyword = "Ahelp"
require_comms_key = TRUE
/datum/world_topic/ahelp_relay/Run(list/input)
relay_msg_admins(span_adminnotice("<b><font color=red>HELP: </font> [input["source"]] [input["message_sender"]]: [input["message"]]</b>"))
/datum/world_topic/comms_console
keyword = "Comms_Console"
require_comms_key = TRUE
/datum/world_topic/comms_console/Run(list/input)
minor_announce(input["message"], "Incoming message from [input["message_sender"]]")
for(var/obj/machinery/computer/communications/CM in GLOB.machines)
CM.override_cooldown()
/datum/world_topic/news_report
keyword = "News_Report"
require_comms_key = TRUE
/datum/world_topic/news_report/Run(list/input)
minor_announce(input["message"], "Breaking Update From [input["message_sender"]]")
/datum/world_topic/ooc_relay
keyword = "ooc_relay"
require_comms_key = TRUE
/datum/world_topic/ooc_relay/Run(list/input)
var/messages = json_decode(input["message"])
var/oocmsg = messages["normal"]
var/oocmsg_toadmins = messages["admin"]
var/source = json_decode(input["message_sender"])
var/sourceadmin = source["is_admin"]
var/sourcekey = source["key"]
//SENDING THE MESSAGES OUT
for(var/c in GLOB.clients)
var/client/C = c // God bless typeless for-loops
if( (C.prefs.chat_toggles & CHAT_OOC) && (sourceadmin || !(sourcekey in C.prefs.ignoring)) )
var/sentmsg // The message we're sending to this specific person
if(C.holder) // If they're an admin-ish
sentmsg = oocmsg_toadmins // Get the admin one
else
sentmsg = oocmsg
sentmsg = "[span_prefix("RELAY: [input["source"]]")] " + sentmsg
//no pinging across servers, thats intentional
to_chat(C,sentmsg)
/datum/world_topic/server_hop
keyword = "server_hop"
require_comms_key = TRUE
/datum/world_topic/server_hop/Run(list/input)
var/expected_key = input[keyword]
for(var/mob/dead/observer/O in GLOB.player_list)
if(O.key == expected_key)
if(O.client)
new /atom/movable/screen/splash(null, O.client, TRUE)
break
/datum/world_topic/adminmsg
keyword = "adminmsg"
require_comms_key = TRUE
/datum/world_topic/adminmsg/Run(list/input)
return IrcPm(input[keyword], input["msg"], input["sender"])
/datum/world_topic/namecheck
keyword = "namecheck"
require_comms_key = TRUE
/datum/world_topic/namecheck/Run(list/input)
//Oh this is a hack, someone refactor the functionality out of the chat command PLS
var/datum/tgs_chat_command/namecheck/NC = new
var/datum/tgs_chat_user/user = new
user.friendly_name = input["sender"]
user.mention = user.friendly_name
return NC.Run(user, input["namecheck"])
/datum/world_topic/adminwho
keyword = "adminwho"
require_comms_key = TRUE
/datum/world_topic/adminwho/Run(list/input)
return ircadminwho()
/datum/world_topic/mentorwho
keyword = "mentorwho"
require_comms_key = TRUE
/datum/world_topic/mentorwho/Run(list/input)
var/list/message = list("Mentors: ")
for(var/client/mentor in GLOB.mentors)
if(LAZYLEN(message) > 1)
message += ", [mentor.key]"
else
message += "[mentor.key]"
return jointext(message, "")
// Plays a voice announcement, given the ID of a voice annoucnement datum and a filename of a file in the shared folder, among other things
/datum/world_topic/voice_announce
keyword = "voice_announce"
require_comms_key = TRUE
/datum/world_topic/voice_announce/Run(list/input)
var/datum/voice_announce/A = GLOB.voice_announce_list[input["voice_announce"]]
if(istype(A))
A.handle_announce(input["ogg_file"], input["uploaded_file"], input["ip"], text2num(input["duration"]) SECONDS)
// Cancels a voice announcement, given the ID of voice announcement datum, used if the user closes their browser window instead of uploading
/datum/world_topic/voice_announce_cancel
keyword = "voice_announce_cancel"
require_comms_key = TRUE
/datum/world_topic/voice_announce_cancel/Run(list/input)
var/datum/voice_announce/A = GLOB.voice_announce_list[input["voice_announce_cancel"]]
if(istype(A))
qdel(A)
// Queries information about a voice announcement.
/datum/world_topic/voice_announce_query
keyword = "voice_announce_query"
require_comms_key = TRUE
/datum/world_topic/voice_announce_query/Run(list/input)
. = list()
var/datum/voice_announce/A = GLOB.voice_announce_list[input["voice_announce_query"]]
if(istype(A))
A.was_queried = TRUE
.["exists"] = TRUE
.["is_ai"] = A.is_ai
else
.["exists"] = FALSE
/datum/world_topic/status
keyword = "status"
/datum/world_topic/status/Run(list/input)
. = list()
.["version"] = GLOB.game_version
.["mode"] = GLOB.master_mode
.["respawn"] = config ? !CONFIG_GET(flag/norespawn) : FALSE
.["enter"] = GLOB.enter_allowed
.["vote"] = CONFIG_GET(flag/allow_vote_mode)
.["ai"] = CONFIG_GET(flag/allow_ai)
.["host"] = world.host ? world.host : null
.["round_id"] = GLOB.round_id
.["players"] = GLOB.clients.len
.["revision"] = GLOB.revdata?.commit
.["revision_date"] = GLOB.revdata?.date
var/list/adm = get_admin_counts()
var/list/presentmins = adm["present"]
var/list/afkmins = adm["afk"]
.["admins"] = presentmins.len + afkmins.len //equivalent to the info gotten from adminwho
.["gamestate"] = SSticker.current_state
.["map_name"] = SSmapping.config?.map_name || "Loading..."
if(key_valid)
.["active_players"] = get_active_player_count()
if(SSticker.HasRoundStarted())
.["real_mode"] = SSgamemode.name
// Key-authed callers may know the truth behind the "secret"
.["security_level"] = SSsecurity_level.get_current_level_as_text()
.["round_duration"] = SSticker ? round((world.time-SSticker.round_start_time)/10) : 0
// Amount of world's ticks in seconds, useful for calculating round duration
//Time dilation stats.
.["time_dilation_current"] = SStime_track.time_dilation_current
.["time_dilation_avg"] = SStime_track.time_dilation_avg
.["time_dilation_avg_slow"] = SStime_track.time_dilation_avg_slow
.["time_dilation_avg_fast"] = SStime_track.time_dilation_avg_fast
//pop cap stats
.["soft_popcap"] = CONFIG_GET(number/soft_popcap) || 0
.["hard_popcap"] = CONFIG_GET(number/hard_popcap) || 0
.["extreme_popcap"] = CONFIG_GET(number/extreme_popcap) || 0
.["popcap"] = max(CONFIG_GET(number/soft_popcap), CONFIG_GET(number/hard_popcap), CONFIG_GET(number/extreme_popcap)) //generalized field for this concept for use across ss13 codebases
if(SSshuttle && SSshuttle.emergency)
.["shuttle_mode"] = SSshuttle.emergency.mode
// Shuttle status, see /__DEFINES/stat.dm
.["shuttle_timer"] = SSshuttle.emergency.timeLeft()
// Shuttle timer, in seconds
/datum/world_topic/systemmsg
keyword = "systemmsg"
require_comms_key = TRUE
/datum/world_topic/systemmsg/Run(list/input)
to_chat(world, span_boldannounce(input["message"]))
//////// Discord Tickets ///////////
/datum/world_topic/ticket_administer
keyword = "ticket_administer"
require_comms_key = TRUE
/datum/world_topic/ticket_administer/Run(list/input)
var/id = text2num(input["id"])
if(!id) return "ERROR: [input["id"]] is not a number"
var/datum/admin_help/ticket = GLOB.ahelp_tickets.TicketByID(id)
if(!ticket) return "ERROR: Ticket not found"
return ticket.DiscordAdminister(input["ckey"], TRUE)
/datum/world_topic/ticket_reply
keyword = "ticket_reply"
require_comms_key = TRUE
/datum/world_topic/ticket_reply/Run(list/input)
var/id = text2num(input["id"])
if(!id) return "ERROR: [input["id"]] is not a number"
var/datum/admin_help/ticket = GLOB.ahelp_tickets.TicketByID(id)
if(!ticket) return "ERROR: Ticket not found"
return ticket.DiscordReply(input["ckey"], url_decode(input["message"]))
/datum/world_topic/ticket_resolve
keyword = "ticket_resolve"
require_comms_key = TRUE
/datum/world_topic/ticket_resolve/Run(list/input)
var/id = text2num(input["id"])
if(!id) return "ERROR: [input["id"]] is not a number"
var/datum/admin_help/ticket = GLOB.ahelp_tickets.TicketByID(id)
if(!ticket) return "ERROR: Ticket not found"
return ticket.DiscordResolve(input["ckey"])
/datum/world_topic/ticket_status
keyword = "ticket_status"
require_comms_key = TRUE
/datum/world_topic/ticket_status/Run(list/input)
webhook_send_ticket_refresh() // Sending by webhook to not break things
return "Data sent"