소스 검색

Allow formatting codes in the MOTD

tags/v0.9.2-beta
Daniel Oaks 6 년 전
부모
커밋
695faefd93
6개의 변경된 파일82개의 추가작업 그리고 2개의 파일을 삭제
  1. 1
    0
      Makefile
  2. 56
    0
      docs/FORMATTING.md
  3. 1
    0
      irc/config.go
  4. 7
    2
      irc/server.go
  5. 13
    0
      oragono.motd
  6. 4
    0
      oragono.yaml

+ 1
- 0
Makefile 파일 보기

@@ -15,6 +15,7 @@ add-files = mkdir -p $1; \
15 15
 	cp ./docs/README $1; \
16 16
 	mkdir -p $1/docs; \
17 17
 	cp ./CHANGELOG.md $1/docs/; \
18
+	cp ./docs/*.md $1/docs/; \
18 19
 	cp ./docs/logo* $1/docs/;
19 20
 
20 21
 all: clean windows osx linux arm6

+ 56
- 0
docs/FORMATTING.md 파일 보기

@@ -0,0 +1,56 @@
1
+# MOTD Formatting Codes
2
+
3
+If `motd-formatting` is enabled in the config file, you can use special escape codes to
4
+easily get bold, coloured, italic, and other types of specially-formatted text.
5
+
6
+Our formatting character is '$', and this followed by specific letters means that the text
7
+after it is formatted in the given way. Here are the character pairs and what they output:
8
+
9
+    --------------------------
10
+     Escape | Output
11
+    --------------------------
12
+       $$   | Dollar sign ($)
13
+       $b   | Bold
14
+       $c   | Color code
15
+       $i   | Italics
16
+       $u   | Underscore
17
+       $r   | Reset
18
+    --------------------------
19
+
20
+
21
+## Color codes
22
+
23
+After the color code (`$c`), you can use square brackets to specify which foreground and
24
+background colors to output. For example:
25
+
26
+This line outputs red text:
27
+    `This is $c[red]really cool text!`
28
+
29
+This line outputs red text with a light blue background:
30
+    `This is $c[red,light blue]22% cooler!`
31
+
32
+If you're familiar with IRC colors you can also use the raw numbers you're used to:
33
+    `This is $c13pink text`
34
+
35
+Here are the color names we support, and which IRC colors they map to:
36
+
37
+    --------------------
38
+     Code | Name
39
+    --------------------
40
+      00  | white
41
+      01  | black
42
+      02  | blue
43
+      03  | green
44
+      04  | red
45
+      05  | brown
46
+      06  | magenta
47
+      07  | orange
48
+      08  | yellow
49
+      09  | light green
50
+      10  | cyan
51
+      11  | light cyan
52
+      12  | light blue
53
+      13  | pink
54
+      14  | grey
55
+      15  | light grey
56
+    --------------------

+ 1
- 0
irc/config.go 파일 보기

@@ -180,6 +180,7 @@ type Config struct {
180 180
 		STS                STSConfig
181 181
 		CheckIdent         bool `yaml:"check-ident"`
182 182
 		MOTD               string
183
+		MOTDFormatting     bool     `yaml:"motd-formatting"`
183 184
 		ProxyAllowedFrom   []string `yaml:"proxy-allowed-from"`
184 185
 		MaxSendQString     string   `yaml:"max-sendq"`
185 186
 		MaxSendQBytes      uint64

+ 7
- 2
irc/server.go 파일 보기

@@ -1423,7 +1423,7 @@ func (server *Server) applyConfig(config *Config, initial bool) error {
1423 1423
 		newISupportReplies = oldISupportList.GetDifference(server.isupport)
1424 1424
 	}
1425 1425
 
1426
-	server.loadMOTD(config.Server.MOTD)
1426
+	server.loadMOTD(config.Server.MOTD, config.Server.MOTDFormatting)
1427 1427
 
1428 1428
 	// reload logging config
1429 1429
 	err = server.logger.ApplyConfig(config.Logging)
@@ -1462,7 +1462,7 @@ func (server *Server) applyConfig(config *Config, initial bool) error {
1462 1462
 	return nil
1463 1463
 }
1464 1464
 
1465
-func (server *Server) loadMOTD(motdPath string) error {
1465
+func (server *Server) loadMOTD(motdPath string, useFormatting bool) error {
1466 1466
 	server.logger.Debug("rehash", "Loading MOTD")
1467 1467
 	motdLines := make([]string, 0)
1468 1468
 	if motdPath != "" {
@@ -1477,6 +1477,11 @@ func (server *Server) loadMOTD(motdPath string) error {
1477 1477
 					break
1478 1478
 				}
1479 1479
 				line = strings.TrimRight(line, "\r\n")
1480
+
1481
+				if useFormatting {
1482
+					line = ircfmt.Unescape(line)
1483
+				}
1484
+
1480 1485
 				// "- " is the required prefix for MOTD, we just add it here to make
1481 1486
 				// bursting it out to clients easier
1482 1487
 				line = fmt.Sprintf("- %s", line)

+ 13
- 0
oragono.motd 파일 보기

@@ -7,3 +7,16 @@
7 7
 
8 8
 This is the default Oragono MOTD.
9 9
 
10
+
11
+If motd-formatting is enabled in the config file, you can use the dollarsign character to
12
+create special formatting such as bold, italics and color codes.
13
+
14
+For example, here are a few formatted lines (enable motd-formatting to see these in action):
15
+
16
+- this is $bbold text$r.
17
+- this is $iitalics text$r.
18
+- this is $c[red]red$c and $c[blue]blue$c text.
19
+- this is $c[red,light blue]red text with a light blue background$c.
20
+- this is a normal escaped dollarsign: $$
21
+
22
+For more information on using these, see MOTDFORMATTING.md

+ 4
- 0
oragono.yaml 파일 보기

@@ -54,6 +54,10 @@ server:
54 54
     # if you change the motd, you should move it to ircd.motd
55 55
     motd: oragono.motd
56 56
 
57
+    # motd formatting codes
58
+    # if this is true, the motd is escaped using formatting codes like $c, $b, and $i
59
+    #motd-formatting: true
60
+
57 61
     # addresses/hostnames the PROXY command can be used from
58 62
     # this should be restricted to 127.0.0.1 and localhost at most
59 63
     # you should also add these addresses to the connection limits and throttling exemption lists

Loading…
취소
저장