2017-03-27 14:15:02 +02:00
|
|
|
// Copyright (c) 2016-2017 Daniel Oaks <daniel@danieloaks.net>
|
2016-10-14 12:56:44 +02:00
|
|
|
// released under the MIT license
|
|
|
|
|
|
|
|
package irc
|
|
|
|
|
|
|
|
import (
|
2017-04-30 05:53:49 +02:00
|
|
|
"fmt"
|
|
|
|
"sort"
|
2016-10-14 12:56:44 +02:00
|
|
|
"strings"
|
2019-02-19 08:54:57 +01:00
|
|
|
"sync"
|
2018-02-03 10:46:14 +01:00
|
|
|
|
2021-05-25 06:34:38 +02:00
|
|
|
"github.com/ergochat/ergo/irc/languages"
|
2016-10-14 12:56:44 +02:00
|
|
|
)
|
|
|
|
|
2017-04-30 05:53:49 +02:00
|
|
|
// HelpEntryType represents the different sorts of help entries that can exist.
|
|
|
|
type HelpEntryType int
|
|
|
|
|
|
|
|
const (
|
2017-06-19 22:53:16 +02:00
|
|
|
// CommandHelpEntry is a help entry explaining a client command.
|
2018-01-23 12:17:14 +01:00
|
|
|
CommandHelpEntry HelpEntryType = iota
|
2017-06-19 22:53:16 +02:00
|
|
|
// InformationHelpEntry is a help entry explaining general server info.
|
2018-01-23 12:17:14 +01:00
|
|
|
InformationHelpEntry
|
2017-06-19 22:53:16 +02:00
|
|
|
// ISupportHelpEntry is a help entry explaining a specific RPL_ISUPPORT token.
|
2018-01-23 12:17:14 +01:00
|
|
|
ISupportHelpEntry
|
2017-04-30 05:53:49 +02:00
|
|
|
)
|
|
|
|
|
2016-10-14 12:56:44 +02:00
|
|
|
// HelpEntry represents an entry in the Help map.
|
|
|
|
type HelpEntry struct {
|
2018-01-23 12:17:14 +01:00
|
|
|
oper bool
|
|
|
|
text string
|
|
|
|
textGenerator func(*Client) string
|
|
|
|
helpType HelpEntryType
|
|
|
|
duplicate bool
|
2016-10-14 12:56:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// used for duplicates
|
|
|
|
var (
|
|
|
|
cmodeHelpText = `== Channel Modes ==
|
2016-10-23 10:59:13 +02:00
|
|
|
|
2021-05-25 06:34:38 +02:00
|
|
|
Ergo supports the following channel modes:
|
2016-10-14 12:56:44 +02:00
|
|
|
|
2017-03-28 09:32:03 +02:00
|
|
|
+b | Client masks that are banned from the channel (e.g. *!*@127.0.0.1)
|
2016-10-14 12:56:44 +02:00
|
|
|
+e | Client masks that are exempted from bans.
|
|
|
|
+I | Client masks that are exempted from the invite-only flag.
|
|
|
|
+i | Invite-only mode, only invited clients can join the channel.
|
2017-03-28 09:32:03 +02:00
|
|
|
+k | Key required when joining the channel.
|
|
|
|
+l | Client join limit for the channel.
|
2021-06-16 08:52:21 +02:00
|
|
|
+f | Users who are unable to join this channel (due to another mode) are forwarded
|
2021-06-16 05:05:33 +02:00
|
|
|
to the provided channel instead.
|
2016-10-16 12:44:38 +02:00
|
|
|
+m | Moderated mode, only privileged clients can talk on the channel.
|
2016-11-04 03:42:58 +01:00
|
|
|
+n | No-outside-messages mode, only users that are on the channel can send
|
|
|
|
| messages to it.
|
2020-04-06 16:47:55 +02:00
|
|
|
+R | Only registered users can join the channel.
|
2020-09-19 20:01:58 +02:00
|
|
|
+M | Only registered or voiced users can speak in the channel.
|
2016-10-23 10:59:13 +02:00
|
|
|
+s | Secret mode, channel won't show up in /LIST or whois replies.
|
2017-03-28 09:32:03 +02:00
|
|
|
+t | Only channel opers can modify the topic.
|
2020-07-16 03:57:59 +02:00
|
|
|
+E | Roleplaying commands are enabled in the channel.
|
2020-06-08 20:43:58 +02:00
|
|
|
+C | Clients are blocked from sending CTCP messages in the channel.
|
2020-10-02 14:13:52 +02:00
|
|
|
+u | Auditorium mode: JOIN, PART, QUIT, NAMES, and WHO are hidden
|
2020-11-08 23:33:45 +01:00
|
|
|
from unvoiced clients.
|
2020-10-20 19:37:38 +02:00
|
|
|
+U | Op-moderated mode: messages from unprivileged clients are sent
|
|
|
|
only to channel operators.
|
2016-10-14 12:56:44 +02:00
|
|
|
|
|
|
|
= Prefixes =
|
|
|
|
|
|
|
|
+q (~) | Founder channel mode.
|
|
|
|
+a (&) | Admin channel mode.
|
|
|
|
+o (@) | Operator channel mode.
|
|
|
|
+h (%) | Halfop channel mode.
|
|
|
|
+v (+) | Voice channel mode.`
|
|
|
|
umodeHelpText = `== User Modes ==
|
2016-10-23 10:59:13 +02:00
|
|
|
|
2021-05-25 06:34:38 +02:00
|
|
|
Ergo supports the following user modes:
|
2016-10-14 12:56:44 +02:00
|
|
|
|
|
|
|
+a | User is marked as being away. This mode is set with the /AWAY command.
|
|
|
|
+i | User is marked as invisible (their channels are hidden from whois replies).
|
|
|
|
+o | User is an IRC operator.
|
2020-08-13 19:17:31 +02:00
|
|
|
+R | User only accepts messages from other registered users.
|
2017-05-09 13:33:03 +02:00
|
|
|
+s | Server Notice Masks (see help with /HELPOP snomasks).
|
2020-06-08 20:43:58 +02:00
|
|
|
+Z | User is connected via TLS.
|
2020-07-16 03:57:59 +02:00
|
|
|
+B | User is a bot.
|
|
|
|
+E | User can receive roleplaying commands.
|
2020-10-02 14:13:52 +02:00
|
|
|
+T | CTCP messages to the user are blocked.`
|
2017-05-09 13:33:03 +02:00
|
|
|
snomaskHelpText = `== Server Notice Masks ==
|
|
|
|
|
2021-05-25 06:34:38 +02:00
|
|
|
Ergo supports the following server notice masks for operators:
|
2017-05-09 13:33:03 +02:00
|
|
|
|
|
|
|
a | Local announcements.
|
|
|
|
c | Local client connections.
|
2021-07-07 15:13:42 +02:00
|
|
|
d | Local client disconnects.
|
2017-05-09 13:33:03 +02:00
|
|
|
j | Local channel actions.
|
|
|
|
k | Local kills.
|
|
|
|
n | Local nick changes.
|
|
|
|
o | Local oper actions.
|
|
|
|
q | Local quits.
|
|
|
|
t | Local /STATS usage.
|
|
|
|
u | Local client account actions.
|
|
|
|
x | Local X-lines (DLINE/KLINE/etc).
|
2020-05-27 15:57:27 +02:00
|
|
|
v | Local vhost changes.
|
2017-05-09 13:33:03 +02:00
|
|
|
|
|
|
|
To set a snomask, do this with your nickname:
|
|
|
|
|
|
|
|
/MODE <nick> +s <chars>
|
|
|
|
|
|
|
|
For instance, this would set the kill, oper, account and xline snomasks on dan:
|
|
|
|
|
|
|
|
/MODE dan +s koux`
|
2016-10-14 12:56:44 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
// Help contains the help strings distributed with the IRCd.
|
|
|
|
var Help = map[string]HelpEntry{
|
|
|
|
// Commands
|
2022-05-06 04:34:43 +02:00
|
|
|
"accept": {
|
|
|
|
text: `ACCEPT <target>
|
|
|
|
|
|
|
|
ACCEPT allows the target user to send you direct messages, overriding any
|
|
|
|
restrictions that might otherwise prevent this. Currently, the only
|
|
|
|
applicable restriction is the +R registered-only mode.`,
|
|
|
|
},
|
2016-11-01 14:56:21 +01:00
|
|
|
"ambiance": {
|
|
|
|
text: `AMBIANCE <target> <text to be sent>
|
|
|
|
|
|
|
|
The AMBIANCE command is used to send a scene notification to the given target.`,
|
|
|
|
},
|
2016-10-14 12:56:44 +02:00
|
|
|
"authenticate": {
|
|
|
|
text: `AUTHENTICATE
|
2016-10-23 10:59:13 +02:00
|
|
|
|
2016-10-14 12:56:44 +02:00
|
|
|
Used during SASL authentication. See the IRCv3 specs for more info:
|
|
|
|
http://ircv3.net/specs/extensions/sasl-3.1.html`,
|
|
|
|
},
|
|
|
|
"away": {
|
|
|
|
text: `AWAY [message]
|
|
|
|
|
|
|
|
If [message] is sent, marks you away. If [message] is not sent, marks you no
|
|
|
|
longer away.`,
|
2019-12-23 21:26:37 +01:00
|
|
|
},
|
|
|
|
"batch": {
|
|
|
|
text: `BATCH {+,-}reference-tag type [params...]
|
|
|
|
|
|
|
|
BATCH initiates an IRCv3 client-to-server batch. You should never need to
|
|
|
|
issue this command manually.`,
|
2016-10-14 12:56:44 +02:00
|
|
|
},
|
|
|
|
"cap": {
|
|
|
|
text: `CAP <subcommand> [:<capabilities>]
|
2016-10-23 10:59:13 +02:00
|
|
|
|
2016-10-14 12:56:44 +02:00
|
|
|
Used in capability negotiation. See the IRCv3 specs for more info:
|
|
|
|
http://ircv3.net/specs/core/capability-negotiation-3.1.html
|
|
|
|
http://ircv3.net/specs/core/capability-negotiation-3.2.html`,
|
2019-02-04 11:18:17 +01:00
|
|
|
},
|
|
|
|
"chathistory": {
|
|
|
|
text: `CHATHISTORY [params]
|
|
|
|
|
2020-02-21 19:10:08 +01:00
|
|
|
CHATHISTORY is a history replay command associated with the IRCv3
|
2021-12-29 18:45:29 +01:00
|
|
|
chathistory extension. See this document:
|
|
|
|
https://ircv3.net/specs/extensions/chathistory`,
|
2016-10-14 12:56:44 +02:00
|
|
|
},
|
|
|
|
"debug": {
|
|
|
|
oper: true,
|
|
|
|
text: `DEBUG <option>
|
2016-10-23 10:59:13 +02:00
|
|
|
|
2020-02-21 19:07:22 +01:00
|
|
|
Provides various debugging commands for the IRCd. <option> can be one of:
|
2016-10-14 12:56:44 +02:00
|
|
|
|
|
|
|
* GCSTATS: Garbage control statistics.
|
|
|
|
* NUMGOROUTINE: Number of goroutines in use.
|
|
|
|
* STARTCPUPROFILE: Starts the CPU profiler.
|
|
|
|
* STOPCPUPROFILE: Stops the CPU profiler.
|
2020-02-21 19:07:22 +01:00
|
|
|
* PROFILEHEAP: Writes a memory profile.
|
|
|
|
* CRASHSERVER: Crashes the server (for use in failover testing)`,
|
2020-07-08 11:32:14 +02:00
|
|
|
},
|
|
|
|
"defcon": {
|
|
|
|
oper: true,
|
|
|
|
text: `DEFCON [level]
|
|
|
|
|
|
|
|
The DEFCON system can disable server features at runtime, to mitigate
|
|
|
|
spam or other hostile activity. It has five levels, which are cumulative
|
|
|
|
(i.e., level 3 includes all restrictions from level 4 and so on):
|
|
|
|
|
|
|
|
5: Normal operation
|
2020-12-11 11:04:56 +01:00
|
|
|
4: No new account or channel registrations; if Tor is enabled, no new
|
|
|
|
unauthenticated connections from Tor
|
2020-07-09 10:33:09 +02:00
|
|
|
3: All users are +R; no changes to vhosts
|
|
|
|
2: No new unauthenticated connections; all channels are +R
|
2020-07-08 11:32:14 +02:00
|
|
|
1: No new connections except from localhost or other trusted IPs`,
|
2020-02-21 12:10:35 +01:00
|
|
|
},
|
|
|
|
"deoper": {
|
|
|
|
oper: true,
|
|
|
|
text: `DEOPER
|
|
|
|
|
|
|
|
DEOPER removes the IRCop privileges granted to you by a successful /OPER.`,
|
2016-11-04 03:42:58 +01:00
|
|
|
},
|
|
|
|
"dline": {
|
|
|
|
oper: true,
|
2017-05-24 08:58:36 +02:00
|
|
|
text: `DLINE [ANDKILL] [MYSELF] [duration] <ip>/<net> [ON <server>] [reason [| oper reason]]
|
2017-10-14 23:53:13 +02:00
|
|
|
DLINE LIST
|
2016-11-04 03:42:58 +01:00
|
|
|
|
|
|
|
Bans an IP address or network from connecting to the server. If the duration is
|
|
|
|
given then only for that long. The reason is shown to the user themselves, but
|
|
|
|
everyone else will see a standard message. The oper reason is shown to
|
|
|
|
operators getting info about the DLINEs that exist.
|
|
|
|
|
|
|
|
Bans are saved across subsequent launches of the server.
|
|
|
|
|
2017-05-24 08:58:36 +02:00
|
|
|
"ANDKILL" means that all matching clients are also removed from the server.
|
|
|
|
|
2016-11-05 12:44:49 +01:00
|
|
|
"MYSELF" is required when the DLINE matches the address the person applying it is connected
|
|
|
|
from. If "MYSELF" is not given, trying to DLINE yourself will result in an error.
|
|
|
|
|
2016-11-04 03:42:58 +01:00
|
|
|
[duration] can be of the following forms:
|
2017-03-07 10:56:21 +01:00
|
|
|
1y 12mo 31d 10h 8m 13s
|
2016-11-04 03:42:58 +01:00
|
|
|
|
|
|
|
<net> is specified in typical CIDR notation. For example:
|
|
|
|
127.0.0.1/8
|
|
|
|
8.8.8.8/24
|
|
|
|
|
2016-11-05 12:44:49 +01:00
|
|
|
ON <server> specifies that the ban is to be set on that specific server.
|
|
|
|
|
2017-10-14 23:53:13 +02:00
|
|
|
[reason] and [oper reason], if they exist, are separated by a vertical bar (|).
|
|
|
|
|
2020-11-26 18:54:50 +01:00
|
|
|
If "DLINE LIST" is sent, the server sends back a list of our current DLINEs.
|
|
|
|
|
|
|
|
To remove a DLINE, use the "UNDLINE" command.`,
|
2020-04-15 10:14:17 +02:00
|
|
|
},
|
|
|
|
"extjwt": {
|
|
|
|
text: `EXTJWT <target> [service_name]
|
|
|
|
|
|
|
|
Get a JSON Web Token for target (either * or a channel name).`,
|
2016-10-23 10:59:13 +02:00
|
|
|
},
|
|
|
|
"help": {
|
|
|
|
text: `HELP <argument>
|
|
|
|
|
2017-04-30 05:53:49 +02:00
|
|
|
Get an explanation of <argument>, or "index" for a list of help topics.`,
|
|
|
|
},
|
|
|
|
"helpop": {
|
|
|
|
text: `HELPOP <argument>
|
|
|
|
|
|
|
|
Get an explanation of <argument>, or "index" for a list of help topics.`,
|
2019-02-04 11:18:17 +01:00
|
|
|
},
|
|
|
|
"history": {
|
2019-02-04 18:31:44 +01:00
|
|
|
text: `HISTORY <target> [limit]
|
2019-02-04 11:18:17 +01:00
|
|
|
|
2019-02-04 18:31:44 +01:00
|
|
|
Replay message history. <target> can be a channel name, "me" to replay direct
|
|
|
|
message history, or a nickname to replay another client's direct message
|
2020-02-19 01:38:42 +01:00
|
|
|
history (they must be logged into the same account as you). [limit] can be
|
|
|
|
either an integer (the maximum number of messages to replay), or a time
|
|
|
|
duration like 10m or 1h (the time window within which to replay messages).`,
|
2017-10-29 08:59:56 +01:00
|
|
|
},
|
|
|
|
"info": {
|
|
|
|
text: `INFO
|
|
|
|
|
|
|
|
Sends information about the server, developers, etc.`,
|
2016-10-14 12:56:44 +02:00
|
|
|
},
|
|
|
|
"invite": {
|
|
|
|
text: `INVITE <nickname> <channel>
|
|
|
|
|
|
|
|
Invites the given user to the given channel, so long as you have the
|
|
|
|
appropriate channel privs.`,
|
|
|
|
},
|
|
|
|
"ison": {
|
|
|
|
text: `ISON <nickname>{ <nickname>}
|
2016-10-23 10:59:13 +02:00
|
|
|
|
2016-10-14 12:56:44 +02:00
|
|
|
Returns whether the given nicks exist on the network.`,
|
2024-09-27 06:40:56 +02:00
|
|
|
},
|
|
|
|
"isupport": {
|
|
|
|
text: `ISUPPORT
|
|
|
|
|
|
|
|
Returns RPL_ISUPPORT lines describing the server's capabilities.`,
|
2016-10-14 12:56:44 +02:00
|
|
|
},
|
|
|
|
"join": {
|
|
|
|
text: `JOIN <channel>{,<channel>} [<key>{,<key>}]
|
|
|
|
|
2017-06-11 01:03:23 +02:00
|
|
|
Joins the given channels with the matching keys.`,
|
2016-10-14 12:56:44 +02:00
|
|
|
},
|
|
|
|
"kick": {
|
|
|
|
text: `KICK <channel> <user> [reason]
|
2016-10-23 10:59:13 +02:00
|
|
|
|
2016-10-14 12:56:44 +02:00
|
|
|
Removes the user from the given channel, so long as you have the appropriate
|
|
|
|
channel privs.`,
|
|
|
|
},
|
|
|
|
"kill": {
|
|
|
|
oper: true,
|
|
|
|
text: `KILL <nickname> [reason]
|
2016-10-23 10:59:13 +02:00
|
|
|
|
2016-10-14 12:56:44 +02:00
|
|
|
Removes the given user from the network, showing them the reason if it is
|
|
|
|
supplied.`,
|
2017-01-11 13:38:16 +01:00
|
|
|
},
|
|
|
|
"kline": {
|
|
|
|
oper: true,
|
2017-05-24 08:58:36 +02:00
|
|
|
text: `KLINE [ANDKILL] [MYSELF] [duration] <mask> [ON <server>] [reason [| oper reason]]
|
2017-10-14 23:53:13 +02:00
|
|
|
KLINE LIST
|
2017-01-11 13:38:16 +01:00
|
|
|
|
|
|
|
Bans a mask from connecting to the server. If the duration is given then only for that
|
|
|
|
long. The reason is shown to the user themselves, but everyone else will see a standard
|
|
|
|
message. The oper reason is shown to operators getting info about the KLINEs that exist.
|
|
|
|
|
|
|
|
Bans are saved across subsequent launches of the server.
|
|
|
|
|
2017-05-24 08:58:36 +02:00
|
|
|
"ANDKILL" means that all matching clients are also removed from the server.
|
|
|
|
|
2017-01-11 13:38:16 +01:00
|
|
|
"MYSELF" is required when the KLINE matches the address the person applying it is connected
|
|
|
|
from. If "MYSELF" is not given, trying to KLINE yourself will result in an error.
|
|
|
|
|
|
|
|
[duration] can be of the following forms:
|
2017-03-07 10:56:21 +01:00
|
|
|
1y 12mo 31d 10h 8m 13s
|
2017-01-11 13:38:16 +01:00
|
|
|
|
|
|
|
<mask> is specified in typical IRC format. For example:
|
|
|
|
dan
|
|
|
|
dan!5*@127.*
|
|
|
|
|
|
|
|
ON <server> specifies that the ban is to be set on that specific server.
|
|
|
|
|
2017-10-14 23:53:13 +02:00
|
|
|
[reason] and [oper reason], if they exist, are separated by a vertical bar (|).
|
|
|
|
|
2020-11-26 18:54:50 +01:00
|
|
|
If "KLINE LIST" is sent, the server sends back a list of our current KLINEs.
|
|
|
|
|
|
|
|
To remove a KLINE, use the "UNKLINE" command.`,
|
2018-01-22 08:30:31 +01:00
|
|
|
},
|
|
|
|
"language": {
|
|
|
|
text: `LANGUAGE <code>{ <code>}
|
|
|
|
|
|
|
|
Sets your preferred languages to the given ones.`,
|
2016-10-14 12:56:44 +02:00
|
|
|
},
|
|
|
|
"list": {
|
|
|
|
text: `LIST [<channel>{,<channel>}] [<elistcond>{,<elistcond>}]
|
2016-10-23 10:59:13 +02:00
|
|
|
|
2016-10-14 12:56:44 +02:00
|
|
|
Shows information on the given channels (or if none are given, then on all
|
|
|
|
channels). <elistcond>s modify how the channels are selected.`,
|
|
|
|
//TODO(dan): Explain <elistcond>s in more specific detail
|
|
|
|
},
|
2017-01-15 01:48:47 +01:00
|
|
|
"lusers": {
|
2017-01-17 13:49:14 +01:00
|
|
|
text: `LUSERS [<mask> [<server>]]
|
2017-01-15 01:48:47 +01:00
|
|
|
|
2017-01-17 13:49:14 +01:00
|
|
|
Shows statistics about the size of the network. If <mask> is given, only
|
|
|
|
returns stats for servers matching the given mask. If <server> is given, the
|
|
|
|
command is processed by that server.`,
|
2022-03-30 21:35:28 +02:00
|
|
|
},
|
|
|
|
"markread": {
|
|
|
|
text: `MARKREAD <target> [timestamp]
|
|
|
|
|
|
|
|
MARKREAD updates an IRCv3 read message marker. It is not intended for use by
|
|
|
|
end users. For more details, see the latest draft of the read-marker
|
|
|
|
specification.`,
|
2017-01-15 01:48:47 +01:00
|
|
|
},
|
2016-10-14 12:56:44 +02:00
|
|
|
"mode": {
|
|
|
|
text: `MODE <target> [<modestring> [<mode arguments>...]]
|
2016-10-23 10:59:13 +02:00
|
|
|
|
2016-10-14 12:56:44 +02:00
|
|
|
Sets and removes modes from the given target. For more specific information on
|
2017-03-28 09:32:03 +02:00
|
|
|
mode characters, see the help for "modes".`,
|
2016-10-23 10:59:13 +02:00
|
|
|
},
|
|
|
|
"monitor": {
|
|
|
|
text: `MONITOR <subcmd>
|
|
|
|
|
|
|
|
Allows the monitoring of nicknames, for alerts when they are online and
|
|
|
|
offline. The subcommands are:
|
|
|
|
|
|
|
|
MONITOR + target{,target}
|
|
|
|
Adds the given names to your list of monitored nicknames.
|
|
|
|
|
|
|
|
MONITOR - target{,target}
|
|
|
|
Removes the given names from your list of monitored nicknames.
|
|
|
|
|
|
|
|
MONITOR C
|
|
|
|
Clears your list of monitored nicknames.
|
|
|
|
|
|
|
|
MONITOR L
|
|
|
|
Lists all the nicknames you are currently monitoring.
|
|
|
|
|
|
|
|
MONITOR S
|
|
|
|
Lists whether each nick in your MONITOR list is online or offline.`,
|
2016-10-14 12:56:44 +02:00
|
|
|
},
|
|
|
|
"motd": {
|
|
|
|
text: `MOTD [server]
|
2016-10-23 10:59:13 +02:00
|
|
|
|
2016-10-14 12:56:44 +02:00
|
|
|
Returns the message of the day for this, or the given, server.`,
|
|
|
|
},
|
|
|
|
"names": {
|
|
|
|
text: `NAMES [<channel>{,<channel>}]
|
2016-10-23 10:59:13 +02:00
|
|
|
|
2016-10-14 12:56:44 +02:00
|
|
|
Views the clients joined to a channel and their channel membership prefixes. To
|
|
|
|
view the channel membership prefixes supported by this server, see the help for
|
|
|
|
"PREFIX".`,
|
|
|
|
},
|
|
|
|
"nick": {
|
|
|
|
text: `NICK <newnick>
|
2016-10-23 10:59:13 +02:00
|
|
|
|
2016-10-14 12:56:44 +02:00
|
|
|
Sets your nickname to the new given one.`,
|
|
|
|
},
|
|
|
|
"notice": {
|
|
|
|
text: `NOTICE <target>{,<target>} <text to be sent>
|
2016-10-23 10:59:13 +02:00
|
|
|
|
2016-10-14 12:56:44 +02:00
|
|
|
Sends the text to the given targets as a NOTICE.`,
|
2016-11-01 14:56:21 +01:00
|
|
|
},
|
|
|
|
"npc": {
|
|
|
|
text: `NPC <target> <sourcenick> <text to be sent>
|
|
|
|
|
2016-11-14 05:03:48 +01:00
|
|
|
The NPC command is used to send a message to the target as the source.
|
|
|
|
|
|
|
|
Requires the roleplay mode (+E) to be set on the target.`,
|
2016-11-01 14:56:21 +01:00
|
|
|
},
|
|
|
|
"npca": {
|
|
|
|
text: `NPCA <target> <sourcenick> <text to be sent>
|
|
|
|
|
2016-11-14 05:03:48 +01:00
|
|
|
The NPC command is used to send an action to the target as the source.
|
|
|
|
|
|
|
|
Requires the roleplay mode (+E) to be set on the target.`,
|
2016-10-14 12:56:44 +02:00
|
|
|
},
|
|
|
|
"oper": {
|
2019-12-18 21:44:06 +01:00
|
|
|
text: `OPER <name> [password]
|
2016-10-23 10:59:13 +02:00
|
|
|
|
2016-10-14 12:56:44 +02:00
|
|
|
If the correct details are given, gives you IRCop privs.`,
|
|
|
|
},
|
|
|
|
"part": {
|
|
|
|
text: `PART <channel>{,<channel>} [reason]
|
|
|
|
|
|
|
|
Leaves the given channels and shows people the given reason.`,
|
|
|
|
},
|
|
|
|
"pass": {
|
|
|
|
text: `PASS <password>
|
2016-10-23 10:59:13 +02:00
|
|
|
|
2016-10-14 12:56:44 +02:00
|
|
|
When the server requires a connection password to join, used to send us the
|
|
|
|
password.`,
|
2022-07-15 06:04:35 +02:00
|
|
|
},
|
|
|
|
"persistence": {
|
|
|
|
text: `PERSISTENCE [params]
|
|
|
|
|
|
|
|
PERSISTENCE is a command associated with an IRC protocol extension for
|
|
|
|
persistent connections. End users should probably use /NS GET ALWAYS-ON
|
|
|
|
and /NS SET ALWAYS-ON instead.`,
|
2016-10-14 12:56:44 +02:00
|
|
|
},
|
|
|
|
"ping": {
|
|
|
|
text: `PING <args>...
|
2016-10-23 10:59:13 +02:00
|
|
|
|
2016-10-14 12:56:44 +02:00
|
|
|
Requests a PONG. Used to check link connectivity.`,
|
|
|
|
},
|
|
|
|
"pong": {
|
|
|
|
text: `PONG <args>...
|
2016-10-23 10:59:13 +02:00
|
|
|
|
2016-10-14 12:56:44 +02:00
|
|
|
Replies to a PING. Used to check link connectivity.`,
|
|
|
|
},
|
|
|
|
"privmsg": {
|
|
|
|
text: `PRIVMSG <target>{,<target>} <text to be sent>
|
2016-10-23 10:59:13 +02:00
|
|
|
|
2016-10-14 12:56:44 +02:00
|
|
|
Sends the text to the given targets as a PRIVMSG.`,
|
2023-05-31 07:16:14 +02:00
|
|
|
},
|
|
|
|
"redact": {
|
|
|
|
text: `REDACT <target> <targetmsgid> [<reason>]
|
|
|
|
|
|
|
|
Removes the message of the target msgid from the chat history of a channel
|
|
|
|
or target user.`,
|
2020-06-08 02:19:28 +02:00
|
|
|
},
|
|
|
|
"relaymsg": {
|
|
|
|
text: `RELAYMSG <channel> <spoofed nick> :<message>
|
|
|
|
|
|
|
|
This command lets channel operators relay messages to their
|
|
|
|
channel from other messaging systems using relay bots. The
|
|
|
|
spoofed nickname MUST contain a forwardslash.
|
|
|
|
|
|
|
|
For example:
|
|
|
|
RELAYMSG #ircv3 Mallory/D :Welp, we linked Discord...`,
|
2017-06-05 04:01:37 +02:00
|
|
|
},
|
|
|
|
"rename": {
|
|
|
|
text: `RENAME <channel> <newname> [<reason>]
|
|
|
|
|
|
|
|
Renames the given channel with the given reason, if possible.
|
|
|
|
|
|
|
|
For example:
|
|
|
|
RENAME #ircv2 #ircv3 :Protocol upgrades!`,
|
2018-05-25 08:46:36 +02:00
|
|
|
},
|
|
|
|
"sajoin": {
|
|
|
|
oper: true,
|
|
|
|
text: `SAJOIN [nick] #channel{,#channel}
|
|
|
|
|
|
|
|
Forcibly joins a user to a channel, ignoring restrictions like bans, user limits
|
|
|
|
and channel keys. If [nick] is omitted, it defaults to the operator.`,
|
2016-10-14 12:56:44 +02:00
|
|
|
},
|
|
|
|
"sanick": {
|
|
|
|
oper: true,
|
|
|
|
text: `SANICK <currentnick> <newnick>
|
|
|
|
|
|
|
|
Gives the given user a new nickname.`,
|
2017-01-23 00:36:13 +01:00
|
|
|
},
|
|
|
|
"samode": {
|
|
|
|
oper: true,
|
|
|
|
text: `SAMODE <target> [<modestring> [<mode arguments>...]]
|
|
|
|
|
|
|
|
Forcibly sets and removes modes from the given target -- only available to
|
|
|
|
opers. For more specific information on mode characters, see the help for
|
|
|
|
"cmode" and "umode".`,
|
2016-11-01 14:56:21 +01:00
|
|
|
},
|
|
|
|
"scene": {
|
|
|
|
text: `SCENE <target> <text to be sent>
|
|
|
|
|
|
|
|
The SCENE command is used to send a scene notification to the given target.`,
|
2019-02-13 14:22:16 +01:00
|
|
|
},
|
|
|
|
"setname": {
|
|
|
|
text: `SETNAME <realname>
|
|
|
|
|
|
|
|
The SETNAME command updates the realname to be the newly-given one.`,
|
2020-06-02 15:57:51 +02:00
|
|
|
},
|
|
|
|
"summon": {
|
|
|
|
text: `SUMMON [parameters]
|
|
|
|
|
|
|
|
The SUMMON command is not implemented.`,
|
2017-01-14 06:52:32 +01:00
|
|
|
},
|
|
|
|
"tagmsg": {
|
|
|
|
text: `@+client-only-tags TAGMSG <target>{,<target>}
|
|
|
|
|
|
|
|
Sends the given client-only tags to the given targets as a TAGMSG. See the IRCv3
|
|
|
|
specs for more info: http://ircv3.net/specs/core/message-tags-3.3.html`,
|
2016-10-14 12:56:44 +02:00
|
|
|
},
|
|
|
|
"quit": {
|
|
|
|
text: `QUIT [reason]
|
2016-10-23 10:59:13 +02:00
|
|
|
|
2016-10-14 12:56:44 +02:00
|
|
|
Indicates that you're leaving the server, and shows everyone the given reason.`,
|
2020-10-07 00:04:29 +02:00
|
|
|
},
|
|
|
|
"register": {
|
2022-02-08 20:25:41 +01:00
|
|
|
text: `REGISTER <account> <email | *> <password>
|
2020-10-07 00:04:29 +02:00
|
|
|
|
2022-02-08 20:25:41 +01:00
|
|
|
Registers an account in accordance with the draft/account-registration capability.`,
|
2016-10-23 10:59:13 +02:00
|
|
|
},
|
|
|
|
"rehash": {
|
|
|
|
oper: true,
|
|
|
|
text: `REHASH
|
|
|
|
|
|
|
|
Reloads the config file and updates TLS certificates on listeners`,
|
2016-10-14 12:56:44 +02:00
|
|
|
},
|
|
|
|
"time": {
|
|
|
|
text: `TIME [server]
|
2016-10-23 10:59:13 +02:00
|
|
|
|
2016-10-14 12:56:44 +02:00
|
|
|
Shows the time of the current, or the given, server.`,
|
|
|
|
},
|
|
|
|
"topic": {
|
|
|
|
text: `TOPIC <channel> [topic]
|
2016-10-23 10:59:13 +02:00
|
|
|
|
2016-10-14 12:56:44 +02:00
|
|
|
If [topic] is given, sets the topic in the channel to that. If [topic] is not
|
|
|
|
given, views the current topic on the channel.`,
|
2021-01-19 14:49:45 +01:00
|
|
|
},
|
|
|
|
"uban": {
|
|
|
|
text: `UBAN <subcommand> [arguments]
|
|
|
|
|
2021-05-25 06:34:38 +02:00
|
|
|
Ergo's "unified ban" system. Accepts the following subcommands:
|
2021-01-19 14:49:45 +01:00
|
|
|
|
2021-01-22 15:38:40 +01:00
|
|
|
1. UBAN ADD <target> [REQUIRE-SASL] [DURATION <duration>] [REASON...]
|
2021-01-19 14:49:45 +01:00
|
|
|
2. UBAN DEL <target>
|
|
|
|
3. UBAN LIST
|
|
|
|
4. UBAN INFO <target>
|
|
|
|
|
|
|
|
<target> may be an IP, a CIDR, a nickmask with wildcards, or the name of an
|
2021-01-22 15:38:40 +01:00
|
|
|
account to suspend. Note that REQUIRE-SASL is only valid for IP and CIDR bans.`,
|
2016-11-04 03:42:58 +01:00
|
|
|
},
|
|
|
|
"undline": {
|
|
|
|
oper: true,
|
|
|
|
text: `UNDLINE <ip>/<net>
|
|
|
|
|
|
|
|
Removes an existing ban on an IP address or a network.
|
|
|
|
|
|
|
|
<net> is specified in typical CIDR notation. For example:
|
|
|
|
127.0.0.1/8
|
|
|
|
8.8.8.8/24`,
|
2016-10-14 12:56:44 +02:00
|
|
|
},
|
2017-01-11 13:38:16 +01:00
|
|
|
"unkline": {
|
|
|
|
oper: true,
|
|
|
|
text: `UNKLINE <mask>
|
|
|
|
|
|
|
|
Removes an existing ban on a mask.
|
|
|
|
|
|
|
|
For example:
|
|
|
|
dan
|
|
|
|
dan!5*@127.*`,
|
|
|
|
},
|
2016-10-14 12:56:44 +02:00
|
|
|
"user": {
|
|
|
|
text: `USER <username> 0 * <realname>
|
2016-10-23 10:59:13 +02:00
|
|
|
|
2016-10-14 12:56:44 +02:00
|
|
|
Used in connection registration, sets your username and realname to the given
|
|
|
|
values (though your username may also be looked up with Ident).`,
|
2020-10-26 03:16:19 +01:00
|
|
|
},
|
|
|
|
"uninvite": {
|
|
|
|
text: `UNINVITE <nickname> <channel>
|
|
|
|
|
|
|
|
UNINVITE rescinds a channel invitation sent for an invite-only channel.`,
|
2020-06-02 15:57:51 +02:00
|
|
|
},
|
|
|
|
"users": {
|
|
|
|
text: `USERS [parameters]
|
|
|
|
|
|
|
|
The USERS command is not implemented.`,
|
2016-10-14 12:56:44 +02:00
|
|
|
},
|
2017-01-23 17:44:35 +01:00
|
|
|
"userhost": {
|
2017-03-06 00:14:15 +01:00
|
|
|
text: `USERHOST <nickname>{ <nickname>}
|
|
|
|
|
|
|
|
Shows information about the given users. Takes up to 10 nicknames.`,
|
2020-10-07 00:04:29 +02:00
|
|
|
},
|
|
|
|
"verify": {
|
2022-02-08 20:25:41 +01:00
|
|
|
text: `VERIFY <account> <code>
|
2020-10-07 00:04:29 +02:00
|
|
|
|
2022-02-08 20:25:41 +01:00
|
|
|
Verifies an account in accordance with the draft/account-registration capability.`,
|
2017-01-23 17:44:35 +01:00
|
|
|
},
|
2016-10-14 12:56:44 +02:00
|
|
|
"version": {
|
|
|
|
text: `VERSION [server]
|
2016-10-23 10:59:13 +02:00
|
|
|
|
2016-10-14 12:56:44 +02:00
|
|
|
Views the version of software and the RPL_ISUPPORT tokens for the given server.`,
|
2017-10-15 08:18:14 +02:00
|
|
|
},
|
|
|
|
"webirc": {
|
|
|
|
oper: true, // not really, but it's restricted anyways
|
2017-10-16 00:47:49 +02:00
|
|
|
text: `WEBIRC <password> <gateway> <hostname> <ip> [:<flags>]
|
2017-10-15 08:18:14 +02:00
|
|
|
|
|
|
|
Used by web<->IRC gateways and bouncers, the WEBIRC command allows gateways to
|
|
|
|
pass-through the real IP addresses of clients:
|
2017-10-16 00:47:49 +02:00
|
|
|
ircv3.net/specs/extensions/webirc.html
|
|
|
|
|
|
|
|
<flags> is a list of space-separated strings indicating various details about
|
|
|
|
the connection from the client to the gateway, such as:
|
|
|
|
|
|
|
|
- tls: this flag indicates that the client->gateway connection is secure`,
|
2016-10-14 12:56:44 +02:00
|
|
|
},
|
|
|
|
"who": {
|
|
|
|
text: `WHO <name> [o]
|
|
|
|
|
|
|
|
Returns information for the given user.`,
|
|
|
|
},
|
|
|
|
"whois": {
|
|
|
|
text: `WHOIS <client>{,<client>}
|
2016-10-23 10:59:13 +02:00
|
|
|
|
2016-10-14 12:56:44 +02:00
|
|
|
Returns information for the given user(s).`,
|
|
|
|
},
|
|
|
|
"whowas": {
|
|
|
|
text: `WHOWAS <nickname>
|
2016-10-23 10:59:13 +02:00
|
|
|
|
2016-10-14 12:56:44 +02:00
|
|
|
Returns historical information on the last user with the given nickname.`,
|
|
|
|
},
|
2019-05-21 01:08:57 +02:00
|
|
|
"znc": {
|
|
|
|
text: `ZNC <module> [params]
|
|
|
|
|
|
|
|
Used to emulate features of the ZNC bouncer. This command is not intended
|
|
|
|
for direct use by end users.`,
|
|
|
|
duplicate: true,
|
|
|
|
},
|
2016-10-14 12:56:44 +02:00
|
|
|
|
|
|
|
// Informational
|
2017-03-28 09:32:03 +02:00
|
|
|
"modes": {
|
2018-01-23 12:17:14 +01:00
|
|
|
textGenerator: modesTextGenerator,
|
|
|
|
helpType: InformationHelpEntry,
|
2017-03-28 09:32:03 +02:00
|
|
|
},
|
2016-10-14 12:56:44 +02:00
|
|
|
"cmode": {
|
2017-04-30 05:53:49 +02:00
|
|
|
text: cmodeHelpText,
|
|
|
|
helpType: InformationHelpEntry,
|
2016-10-14 12:56:44 +02:00
|
|
|
},
|
|
|
|
"cmodes": {
|
2017-04-30 05:53:49 +02:00
|
|
|
text: cmodeHelpText,
|
|
|
|
helpType: InformationHelpEntry,
|
|
|
|
duplicate: true,
|
2016-10-14 12:56:44 +02:00
|
|
|
},
|
|
|
|
"umode": {
|
2017-04-30 05:53:49 +02:00
|
|
|
text: umodeHelpText,
|
|
|
|
helpType: InformationHelpEntry,
|
2016-10-14 12:56:44 +02:00
|
|
|
},
|
|
|
|
"umodes": {
|
2017-04-30 05:53:49 +02:00
|
|
|
text: umodeHelpText,
|
|
|
|
helpType: InformationHelpEntry,
|
|
|
|
duplicate: true,
|
2016-10-14 12:56:44 +02:00
|
|
|
},
|
2017-05-09 13:33:03 +02:00
|
|
|
"snomask": {
|
|
|
|
text: snomaskHelpText,
|
|
|
|
helpType: InformationHelpEntry,
|
|
|
|
oper: true,
|
|
|
|
duplicate: true,
|
|
|
|
},
|
|
|
|
"snomasks": {
|
|
|
|
text: snomaskHelpText,
|
|
|
|
helpType: InformationHelpEntry,
|
|
|
|
oper: true,
|
|
|
|
},
|
2016-10-14 12:56:44 +02:00
|
|
|
|
|
|
|
// RPL_ISUPPORT
|
|
|
|
"casemapping": {
|
|
|
|
text: `RPL_ISUPPORT CASEMAPPING
|
2016-10-23 10:59:13 +02:00
|
|
|
|
2021-05-25 06:34:38 +02:00
|
|
|
Ergo supports an experimental unicode casemapping designed for extended
|
2017-01-13 23:02:24 +01:00
|
|
|
Unicode support. This casemapping is based off RFC 7613 and the draft rfc7613
|
2021-05-25 06:34:38 +02:00
|
|
|
casemapping spec here: https://ergo.chat/specs.html`,
|
2017-04-30 05:53:49 +02:00
|
|
|
helpType: ISupportHelpEntry,
|
2016-10-14 12:56:44 +02:00
|
|
|
},
|
|
|
|
"prefix": {
|
|
|
|
text: `RPL_ISUPPORT PREFIX
|
|
|
|
|
2021-05-25 06:34:38 +02:00
|
|
|
Ergo supports the following channel membership prefixes:
|
2016-10-14 12:56:44 +02:00
|
|
|
|
|
|
|
+q (~) | Founder channel mode.
|
|
|
|
+a (&) | Admin channel mode.
|
|
|
|
+o (@) | Operator channel mode.
|
|
|
|
+h (%) | Halfop channel mode.
|
|
|
|
+v (+) | Voice channel mode.`,
|
2017-04-30 05:53:49 +02:00
|
|
|
helpType: ISupportHelpEntry,
|
2016-10-14 12:56:44 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2018-01-23 12:17:14 +01:00
|
|
|
// modesTextGenerator generates the text for the 'modes' help entry.
|
|
|
|
// it exists only so we can translate this entry appropriately.
|
|
|
|
func modesTextGenerator(client *Client) string {
|
|
|
|
return client.t(cmodeHelpText) + "\n\n" + client.t(umodeHelpText)
|
|
|
|
}
|
|
|
|
|
2019-02-19 08:54:57 +01:00
|
|
|
type HelpIndexManager struct {
|
|
|
|
sync.RWMutex // tier 1
|
2017-04-30 05:53:49 +02:00
|
|
|
|
2019-02-19 08:54:57 +01:00
|
|
|
langToIndex map[string]string
|
|
|
|
langToOperIndex map[string]string
|
|
|
|
}
|
2017-04-30 05:53:49 +02:00
|
|
|
|
|
|
|
// GenerateHelpIndex is used to generate HelpIndex.
|
2019-02-19 08:54:57 +01:00
|
|
|
// Returns: a map from language code to the help index in that language.
|
2018-02-03 10:46:14 +01:00
|
|
|
func GenerateHelpIndex(lm *languages.Manager, forOpers bool) map[string]string {
|
2018-01-23 12:17:14 +01:00
|
|
|
// generate the help entry lists
|
2017-04-30 05:53:49 +02:00
|
|
|
var commands, isupport, information []string
|
|
|
|
|
|
|
|
var line string
|
|
|
|
for name, info := range Help {
|
|
|
|
if info.duplicate {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if info.oper && !forOpers {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
line = fmt.Sprintf(" %s", name)
|
|
|
|
|
|
|
|
if info.helpType == CommandHelpEntry {
|
|
|
|
commands = append(commands, line)
|
|
|
|
} else if info.helpType == ISupportHelpEntry {
|
|
|
|
isupport = append(isupport, line)
|
|
|
|
} else if info.helpType == InformationHelpEntry {
|
|
|
|
information = append(information, line)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-23 12:17:14 +01:00
|
|
|
// create the strings
|
2017-04-30 05:53:49 +02:00
|
|
|
sort.Strings(commands)
|
2018-01-23 12:17:14 +01:00
|
|
|
commandsString := strings.Join(commands, "\n")
|
2017-04-30 05:53:49 +02:00
|
|
|
sort.Strings(isupport)
|
2018-01-23 12:17:14 +01:00
|
|
|
isupportString := strings.Join(isupport, "\n")
|
2017-04-30 05:53:49 +02:00
|
|
|
sort.Strings(information)
|
2018-01-23 12:17:14 +01:00
|
|
|
informationString := strings.Join(information, "\n")
|
2017-04-30 05:53:49 +02:00
|
|
|
|
|
|
|
// sub them in
|
2018-01-23 12:17:14 +01:00
|
|
|
defaultHelpIndex := `= Help Topics =
|
|
|
|
|
|
|
|
Commands:
|
2019-02-22 03:37:11 +01:00
|
|
|
%[1]s
|
2018-01-23 12:17:14 +01:00
|
|
|
|
|
|
|
RPL_ISUPPORT Tokens:
|
2019-02-22 03:37:11 +01:00
|
|
|
%[2]s
|
2018-01-23 12:17:14 +01:00
|
|
|
|
|
|
|
Information:
|
2019-02-22 03:37:11 +01:00
|
|
|
%[3]s`
|
2018-01-23 12:17:14 +01:00
|
|
|
|
|
|
|
newHelpIndex := make(map[string]string)
|
|
|
|
|
|
|
|
newHelpIndex["en"] = fmt.Sprintf(defaultHelpIndex, commandsString, isupportString, informationString)
|
|
|
|
|
2019-02-19 08:54:57 +01:00
|
|
|
for langCode := range lm.Languages {
|
2018-01-23 12:17:14 +01:00
|
|
|
translatedHelpIndex := lm.Translate([]string{langCode}, defaultHelpIndex)
|
|
|
|
if translatedHelpIndex != defaultHelpIndex {
|
|
|
|
newHelpIndex[langCode] = fmt.Sprintf(translatedHelpIndex, commandsString, isupportString, informationString)
|
|
|
|
}
|
|
|
|
}
|
2017-04-30 05:53:49 +02:00
|
|
|
|
|
|
|
return newHelpIndex
|
|
|
|
}
|
|
|
|
|
2019-02-19 08:54:57 +01:00
|
|
|
// GenerateIndices regenerates our help indexes for each currently enabled language.
|
|
|
|
func (hm *HelpIndexManager) GenerateIndices(lm *languages.Manager) {
|
2017-09-28 07:30:53 +02:00
|
|
|
// generate help indexes
|
2019-02-19 08:54:57 +01:00
|
|
|
langToIndex := GenerateHelpIndex(lm, false)
|
|
|
|
langToOperIndex := GenerateHelpIndex(lm, true)
|
|
|
|
|
|
|
|
hm.Lock()
|
|
|
|
defer hm.Unlock()
|
|
|
|
hm.langToIndex = langToIndex
|
|
|
|
hm.langToOperIndex = langToOperIndex
|
2017-09-28 07:30:53 +02:00
|
|
|
}
|
|
|
|
|
2016-10-14 12:56:44 +02:00
|
|
|
// sendHelp sends the client help of the given string.
|
2020-12-29 11:20:18 +01:00
|
|
|
func (client *Client) sendHelp(helpEntry string, text string, rb *ResponseBuffer) {
|
|
|
|
helpEntry = strings.ToUpper(helpEntry)
|
|
|
|
nick := client.Nick()
|
2016-10-14 12:56:44 +02:00
|
|
|
textLines := strings.Split(text, "\n")
|
|
|
|
|
|
|
|
for i, line := range textLines {
|
|
|
|
if i == 0 {
|
2020-12-29 11:20:18 +01:00
|
|
|
rb.Add(nil, client.server.name, RPL_HELPSTART, nick, helpEntry, line)
|
2016-10-14 12:56:44 +02:00
|
|
|
} else {
|
2020-12-29 11:20:18 +01:00
|
|
|
rb.Add(nil, client.server.name, RPL_HELPTXT, nick, helpEntry, line)
|
2016-10-14 12:56:44 +02:00
|
|
|
}
|
|
|
|
}
|
2020-12-29 11:20:18 +01:00
|
|
|
rb.Add(nil, client.server.name, RPL_ENDOFHELP, nick, helpEntry, client.t("End of /HELPOP"))
|
2016-10-14 12:56:44 +02:00
|
|
|
}
|
|
|
|
|
2018-01-23 12:17:14 +01:00
|
|
|
// GetHelpIndex returns the help index for the given language.
|
2019-02-19 08:54:57 +01:00
|
|
|
func (hm *HelpIndexManager) GetIndex(languages []string, oper bool) string {
|
|
|
|
hm.RLock()
|
|
|
|
langToIndex := hm.langToIndex
|
|
|
|
if oper {
|
|
|
|
langToIndex = hm.langToOperIndex
|
|
|
|
}
|
|
|
|
hm.RUnlock()
|
|
|
|
|
2018-01-23 12:17:14 +01:00
|
|
|
for _, lang := range languages {
|
2019-02-19 08:54:57 +01:00
|
|
|
index, exists := langToIndex[lang]
|
2018-01-23 12:17:14 +01:00
|
|
|
if exists {
|
|
|
|
return index
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 'en' always exists
|
2019-02-19 08:54:57 +01:00
|
|
|
return langToIndex["en"]
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
// startup check that we have HELP entries for every command
|
|
|
|
for name := range Commands {
|
|
|
|
_, exists := Help[strings.ToLower(name)]
|
|
|
|
if !exists {
|
|
|
|
panic(fmt.Sprintf("Help entry does not exist for command %s", name))
|
|
|
|
}
|
|
|
|
}
|
2018-01-23 12:17:14 +01:00
|
|
|
}
|