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
 ### Removed
19
 ### Removed
20
 
20
 
21
 ### Fixed
21
 ### Fixed
22
+* Fixed bug where `HELP` wouldn't correctly display for operators, and added more help topics.
22
 
23
 
23
 
24
 
24
 ## [0.3.0] - 2016-10-23
25
 ## [0.3.0] - 2016-10-23

+ 62
- 30
irc/help.go View File

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

+ 8
- 0
irc/server.go View File

114
 		return nil
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
 	if config.AuthenticationEnabled {
125
 	if config.AuthenticationEnabled {
118
 		SupportedCapabilities[SASL] = true
126
 		SupportedCapabilities[SASL] = true
119
 	}
127
 	}

Loading…
Cancel
Save