-
-
Notifications
You must be signed in to change notification settings - Fork 452
/
to_chat.dm
89 lines (80 loc) · 2.28 KB
/
to_chat.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
/*!
* Copyright (c) 2020 Aleksej Komarov
* SPDX-License-Identifier: MIT
*/
/**
* Circumvents the message queue and sends the message
* to the recipient (target) as soon as possible.
*/
/proc/to_chat_immediate(
target,
html,
type = null,
text = null,
avoid_highlighting = FALSE,
allow_linkify = FALSE,
// FIXME: These flags are now pointless and have no effect
handle_whitespace = TRUE,
trailing_newline = TRUE,
confidential = FALSE,
)
// Useful where the integer 0 is the entire message. Use case is enabling to_chat(target, some_boolean) while preventing to_chat(target, "")
html = "[html]"
text = "[text]"
if(!target)
return
if(!html && !text)
CRASH("Empty or null string in to_chat proc call.")
if(target == world)
target = GLOB.clients
// Build a message
var/message = list()
if(type) message["type"] = type
if(text) message["text"] = text
if(html) message["html"] = html
if(avoid_highlighting) message["avoidHighlighting"] = avoid_highlighting
if(!confidential)
SSdemo.write_chat(target, message)
// send it immediately
SSchat.send_immediate(target, message)
/**
* Sends the message to the recipient (target).
*
* Recommended way to write to_chat calls:
* ```
* to_chat(client,
* type = MESSAGE_TYPE_INFO,
* html = "You have found <strong>[object]</strong>")
* ```
*/
/proc/to_chat(
target,
html,
type = null,
text = null,
avoid_highlighting = FALSE,
allow_linkify = FALSE,
// FIXME: These flags are now pointless and have no effect
handle_whitespace = TRUE,
trailing_newline = TRUE,
confidential = FALSE
)
if(isnull(Master) || !Master.current_runlevel || !MC_RUNNING(SSchat.init_stage))
to_chat_immediate(target, html, type, text, avoid_highlighting, allow_linkify)
return
// Useful where the integer 0 is the entire message. Use case is enabling to_chat(target, some_boolean) while preventing to_chat(target, "")
html = "[html]"
text = "[text]"
if(!target)
return
if(!html && !text)
CRASH("Empty or null string in to_chat proc call.")
if(target == world)
target = GLOB.clients
// Build a message
var/message = list()
if(type) message["type"] = type
if(text) message["text"] = text
if(html) message["html"] = html
if(avoid_highlighting) message["avoidHighlighting"] = avoid_highlighting
SSchat.queue(target, message, confidential)