Browse Source

HELP: Check topics exist at startup, fix a bug

tags/v0.4.0
Daniel Oaks 7 years ago
parent
commit
194fa9af9f
3 changed files with 71 additions and 30 deletions
  1. 1
    0
      CHANGELOG.md
  2. 62
    30
      irc/help.go
  3. 8
    0
      irc/server.go

+ 1
- 0
CHANGELOG.md View File

@@ -19,6 +19,7 @@ New release of Oragono!
19 19
 ### Removed
20 20
 
21 21
 ### Fixed
22
+* Fixed bug where `HELP` wouldn't correctly display for operators, and added more help topics.
22 23
 
23 24
 
24 25
 ## [0.3.0] - 2016-10-23

+ 62
- 30
irc/help.go View File

@@ -18,7 +18,7 @@ type HelpEntry struct {
18 18
 // used for duplicates
19 19
 var (
20 20
 	cmodeHelpText = `== Channel Modes ==
21
-        
21
+
22 22
 Oragono supports the following channel modes:
23 23
 
24 24
 = Type A - list modes =
@@ -38,7 +38,7 @@ Oragono supports the following channel modes:
38 38
   +m  |  Moderated mode, only privileged clients can talk on the channel.
39 39
   +n  |  No-outside-messages mode, only users that are on the channel can send the channel messages.
40 40
   +t  |  Only channel opers can modify the topic.
41
-  +s  |  Secret mode, channel won't show up in /LIST or whois replies.  
41
+  +s  |  Secret mode, channel won't show up in /LIST or whois replies.
42 42
 
43 43
 = Prefixes =
44 44
 
@@ -48,7 +48,7 @@ Oragono supports the following channel modes:
48 48
   +h (%)  |  Halfop channel mode.
49 49
   +v (+)  |  Voice channel mode.`
50 50
 	umodeHelpText = `== User Modes ==
51
-        
51
+
52 52
 Oragono supports the following user modes:
53 53
 
54 54
   +a  |  User is marked as being away. This mode is set with the /AWAY command.
@@ -62,7 +62,7 @@ var Help = map[string]HelpEntry{
62 62
 	// Commands
63 63
 	"authenticate": {
64 64
 		text: `AUTHENTICATE
65
-        
65
+
66 66
 Used during SASL authentication. See the IRCv3 specs for more info:
67 67
 http://ircv3.net/specs/extensions/sasl-3.1.html`,
68 68
 	},
@@ -74,7 +74,7 @@ longer away.`,
74 74
 	},
75 75
 	"cap": {
76 76
 		text: `CAP <subcommand> [:<capabilities>]
77
-        
77
+
78 78
 Used in capability negotiation. See the IRCv3 specs for more info:
79 79
 http://ircv3.net/specs/core/capability-negotiation-3.1.html
80 80
 http://ircv3.net/specs/core/capability-negotiation-3.2.html`,
@@ -82,7 +82,7 @@ http://ircv3.net/specs/core/capability-negotiation-3.2.html`,
82 82
 	"debug": {
83 83
 		oper: true,
84 84
 		text: `DEBUG <option>
85
-        
85
+
86 86
 Prints debug information about the IRCd. <option> can be one of:
87 87
 
88 88
 * GCSTATS: Garbage control statistics.
@@ -90,6 +90,11 @@ Prints debug information about the IRCd. <option> can be one of:
90 90
 * STARTCPUPROFILE: Starts the CPU profiler.
91 91
 * STOPCPUPROFILE: Stops the CPU profiler.
92 92
 * PROFILEHEAP: Writes out the CPU profiler info.`,
93
+	},
94
+	"help": {
95
+		text: `HELP <argument>
96
+
97
+Get an explanation of <argument>.`,
93 98
 	},
94 99
 	"invite": {
95 100
 		text: `INVITE <nickname> <channel>
@@ -99,7 +104,7 @@ appropriate channel privs.`,
99 104
 	},
100 105
 	"ison": {
101 106
 		text: `ISON <nickname>{ <nickname>}
102
-        
107
+
103 108
 Returns whether the given nicks exist on the network.`,
104 109
 	},
105 110
 	"join": {
@@ -111,55 +116,76 @@ parts all channels instead.`,
111 116
 	},
112 117
 	"kick": {
113 118
 		text: `KICK <channel> <user> [reason]
114
-        
119
+
115 120
 Removes the user from the given channel, so long as you have the appropriate
116 121
 channel privs.`,
117 122
 	},
118 123
 	"kill": {
119 124
 		oper: true,
120 125
 		text: `KILL <nickname> [reason]
121
-        
126
+
122 127
 Removes the given user from the network, showing them the reason if it is
123 128
 supplied.`,
124 129
 	},
125 130
 	"list": {
126 131
 		text: `LIST [<channel>{,<channel>}] [<elistcond>{,<elistcond>}]
127
-        
132
+
128 133
 Shows information on the given channels (or if none are given, then on all
129 134
 channels). <elistcond>s modify how the channels are selected.`,
130 135
 		//TODO(dan): Explain <elistcond>s in more specific detail
131 136
 	},
132 137
 	"mode": {
133 138
 		text: `MODE <target> [<modestring> [<mode arguments>...]]
134
-        
139
+
135 140
 Sets and removes modes from the given target. For more specific information on
136 141
 mode characters, see the help for "cmode" and "umode".`,
142
+	},
143
+	"monitor": {
144
+		text: `MONITOR <subcmd>
145
+
146
+Allows the monitoring of nicknames, for alerts when they are online and
147
+offline. The subcommands are:
148
+
149
+    MONITOR + target{,target}
150
+Adds the given names to your list of monitored nicknames.
151
+
152
+    MONITOR - target{,target}
153
+Removes the given names from your list of monitored nicknames.
154
+
155
+    MONITOR C
156
+Clears your list of monitored nicknames.
157
+
158
+    MONITOR L
159
+Lists all the nicknames you are currently monitoring.
160
+
161
+    MONITOR S
162
+Lists whether each nick in your MONITOR list is online or offline.`,
137 163
 	},
138 164
 	"motd": {
139 165
 		text: `MOTD [server]
140
-        
166
+
141 167
 Returns the message of the day for this, or the given, server.`,
142 168
 	},
143 169
 	"names": {
144 170
 		text: `NAMES [<channel>{,<channel>}]
145
-        
171
+
146 172
 Views the clients joined to a channel and their channel membership prefixes. To
147 173
 view the channel membership prefixes supported by this server, see the help for
148 174
 "PREFIX".`,
149 175
 	},
150 176
 	"nick": {
151 177
 		text: `NICK <newnick>
152
-        
178
+
153 179
 Sets your nickname to the new given one.`,
154 180
 	},
155 181
 	"notice": {
156 182
 		text: `NOTICE <target>{,<target>} <text to be sent>
157
-        
183
+
158 184
 Sends the text to the given targets as a NOTICE.`,
159 185
 	},
160 186
 	"oper": {
161 187
 		text: `OPER <name> <password>
162
-        
188
+
163 189
 If the correct details are given, gives you IRCop privs.`,
164 190
 	},
165 191
 	"part": {
@@ -169,23 +195,23 @@ Leaves the given channels and shows people the given reason.`,
169 195
 	},
170 196
 	"pass": {
171 197
 		text: `PASS <password>
172
-        
198
+
173 199
 When the server requires a connection password to join, used to send us the
174 200
 password.`,
175 201
 	},
176 202
 	"ping": {
177 203
 		text: `PING <args>...
178
-        
204
+
179 205
 Requests a PONG. Used to check link connectivity.`,
180 206
 	},
181 207
 	"pong": {
182 208
 		text: `PONG <args>...
183
-        
209
+
184 210
 Replies to a PING. Used to check link connectivity.`,
185 211
 	},
186 212
 	"privmsg": {
187 213
 		text: `PRIVMSG <target>{,<target>} <text to be sent>
188
-        
214
+
189 215
 Sends the text to the given targets as a PRIVMSG.`,
190 216
 	},
191 217
 	"sanick": {
@@ -196,7 +222,7 @@ Gives the given user a new nickname.`,
196 222
 	},
197 223
 	"quit": {
198 224
 		text: `QUIT [reason]
199
-        
225
+
200 226
 Indicates that you're leaving the server, and shows everyone the given reason.`,
201 227
 	},
202 228
 	"reg": {
@@ -205,27 +231,33 @@ REG VERIFY <accountname> <auth_code>
205 231
 
206 232
 Used in account registration. See the relevant specs for more info:
207 233
 https://github.com/DanielOaks/ircv3-specifications/blob/register-and-verify/extensions/reg-core-3.3.md`,
234
+	},
235
+	"rehash": {
236
+		oper: true,
237
+		text: `REHASH
238
+
239
+Reloads the config file and updates TLS certificates on listeners`,
208 240
 	},
209 241
 	"time": {
210 242
 		text: `TIME [server]
211
-        
243
+
212 244
 Shows the time of the current, or the given, server.`,
213 245
 	},
214 246
 	"topic": {
215 247
 		text: `TOPIC <channel> [topic]
216
-        
248
+
217 249
 If [topic] is given, sets the topic in the channel to that. If [topic] is not
218 250
 given, views the current topic on the channel.`,
219 251
 	},
220 252
 	"user": {
221 253
 		text: `USER <username> 0 * <realname>
222
-        
254
+
223 255
 Used in connection registration, sets your username and realname to the given
224 256
 values (though your username may also be looked up with Ident).`,
225 257
 	},
226 258
 	"version": {
227 259
 		text: `VERSION [server]
228
-        
260
+
229 261
 Views the version of software and the RPL_ISUPPORT tokens for the given server.`,
230 262
 	},
231 263
 	"who": {
@@ -235,12 +267,12 @@ Returns information for the given user.`,
235 267
 	},
236 268
 	"whois": {
237 269
 		text: `WHOIS <client>{,<client>}
238
-        
270
+
239 271
 Returns information for the given user(s).`,
240 272
 	},
241 273
 	"whowas": {
242 274
 		text: `WHOWAS <nickname>
243
-        
275
+
244 276
 Returns historical information on the last user with the given nickname.`,
245 277
 	},
246 278
 
@@ -261,7 +293,7 @@ Returns historical information on the last user with the given nickname.`,
261 293
 	// RPL_ISUPPORT
262 294
 	"casemapping": {
263 295
 		text: `RPL_ISUPPORT CASEMAPPING
264
-        
296
+
265 297
 Oragono supports an experimental unicode casemapping designed for extended
266 298
 Unicode support. This casemapping is based off RFC 7700 and the draft rfc7700
267 299
 casemapping spec here:
@@ -305,14 +337,14 @@ func helpHandler(server *Server, client *Client, msg ircmsg.IrcMessage) bool {
305 337
 
306 338
 	if len(argument) < 1 {
307 339
 		client.sendHelp("HELP", `HELP <argument>
308
-        
340
+
309 341
 Get an explanation of <argument>.`)
310 342
 		return false
311 343
 	}
312 344
 
313 345
 	helpHandler, exists := Help[argument]
314 346
 
315
-	if exists && (!client.flags[Operator] || (helpHandler.oper && client.flags[Operator])) {
347
+	if exists && (!helpHandler.oper || (helpHandler.oper && client.flags[Operator])) {
316 348
 		client.sendHelp(strings.ToUpper(argument), helpHandler.text)
317 349
 	} else {
318 350
 		args := msg.Params

+ 8
- 0
irc/server.go View File

@@ -114,6 +114,14 @@ func NewServer(configFilename string, config *Config) *Server {
114 114
 		return nil
115 115
 	}
116 116
 
117
+	// startup check that we have HELP entries for every command
118
+	for name := range Commands {
119
+		_, exists := Help[strings.ToLower(name)]
120
+		if !exists {
121
+			log.Fatal("Help entry does not exist for ", name)
122
+		}
123
+	}
124
+
117 125
 	if config.AuthenticationEnabled {
118 126
 		SupportedCapabilities[SASL] = true
119 127
 	}

Loading…
Cancel
Save