You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

help.go 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  1. // Copyright (c) 2016-2017 Daniel Oaks <daniel@danieloaks.net>
  2. // released under the MIT license
  3. package irc
  4. import (
  5. "fmt"
  6. "sort"
  7. "strings"
  8. "sync"
  9. "github.com/oragono/oragono/irc/languages"
  10. )
  11. // HelpEntryType represents the different sorts of help entries that can exist.
  12. type HelpEntryType int
  13. const (
  14. // CommandHelpEntry is a help entry explaining a client command.
  15. CommandHelpEntry HelpEntryType = iota
  16. // InformationHelpEntry is a help entry explaining general server info.
  17. InformationHelpEntry
  18. // ISupportHelpEntry is a help entry explaining a specific RPL_ISUPPORT token.
  19. ISupportHelpEntry
  20. )
  21. // HelpEntry represents an entry in the Help map.
  22. type HelpEntry struct {
  23. oper bool
  24. text string
  25. textGenerator func(*Client) string
  26. helpType HelpEntryType
  27. duplicate bool
  28. }
  29. // used for duplicates
  30. var (
  31. cmodeHelpText = `== Channel Modes ==
  32. Oragono supports the following channel modes:
  33. +b | Client masks that are banned from the channel (e.g. *!*@127.0.0.1)
  34. +e | Client masks that are exempted from bans.
  35. +I | Client masks that are exempted from the invite-only flag.
  36. +i | Invite-only mode, only invited clients can join the channel.
  37. +k | Key required when joining the channel.
  38. +l | Client join limit for the channel.
  39. +m | Moderated mode, only privileged clients can talk on the channel.
  40. +n | No-outside-messages mode, only users that are on the channel can send
  41. | messages to it.
  42. +R | Only registered users can join the channel.
  43. +s | Secret mode, channel won't show up in /LIST or whois replies.
  44. +t | Only channel opers can modify the topic.
  45. = Prefixes =
  46. +q (~) | Founder channel mode.
  47. +a (&) | Admin channel mode.
  48. +o (@) | Operator channel mode.
  49. +h (%) | Halfop channel mode.
  50. +v (+) | Voice channel mode.`
  51. umodeHelpText = `== User Modes ==
  52. Oragono supports the following user modes:
  53. +a | User is marked as being away. This mode is set with the /AWAY command.
  54. +i | User is marked as invisible (their channels are hidden from whois replies).
  55. +o | User is an IRC operator.
  56. +R | User only accepts messages from other registered users.
  57. +s | Server Notice Masks (see help with /HELPOP snomasks).
  58. +Z | User is connected via TLS.`
  59. snomaskHelpText = `== Server Notice Masks ==
  60. Oragono supports the following server notice masks for operators:
  61. a | Local announcements.
  62. c | Local client connections.
  63. j | Local channel actions.
  64. k | Local kills.
  65. n | Local nick changes.
  66. o | Local oper actions.
  67. q | Local quits.
  68. t | Local /STATS usage.
  69. u | Local client account actions.
  70. x | Local X-lines (DLINE/KLINE/etc).
  71. v | Local vhost changes.
  72. To set a snomask, do this with your nickname:
  73. /MODE <nick> +s <chars>
  74. For instance, this would set the kill, oper, account and xline snomasks on dan:
  75. /MODE dan +s koux`
  76. )
  77. // Help contains the help strings distributed with the IRCd.
  78. var Help = map[string]HelpEntry{
  79. // Commands
  80. "acc": {
  81. text: `ACC LS
  82. ACC REGISTER <accountname> [callback_namespace:]<callback> [cred_type] :<credential>
  83. ACC VERIFY <accountname> <auth_code>
  84. Used in account registration. See the relevant specs for more info:
  85. https://oragono.io/specs.html`,
  86. },
  87. "ambiance": {
  88. text: `AMBIANCE <target> <text to be sent>
  89. The AMBIANCE command is used to send a scene notification to the given target.`,
  90. },
  91. "authenticate": {
  92. text: `AUTHENTICATE
  93. Used during SASL authentication. See the IRCv3 specs for more info:
  94. http://ircv3.net/specs/extensions/sasl-3.1.html`,
  95. },
  96. "away": {
  97. text: `AWAY [message]
  98. If [message] is sent, marks you away. If [message] is not sent, marks you no
  99. longer away.`,
  100. },
  101. "batch": {
  102. text: `BATCH {+,-}reference-tag type [params...]
  103. BATCH initiates an IRCv3 client-to-server batch. You should never need to
  104. issue this command manually.`,
  105. },
  106. "brb": {
  107. text: `BRB [message]
  108. Disconnects you from the server, while instructing the server to keep you
  109. present for a short time window. During this window, you can either resume
  110. or reattach to your nickname. If [message] is sent, it is used as your away
  111. message (and as your quit message if you don't return in time).`,
  112. },
  113. "cap": {
  114. text: `CAP <subcommand> [:<capabilities>]
  115. Used in capability negotiation. See the IRCv3 specs for more info:
  116. http://ircv3.net/specs/core/capability-negotiation-3.1.html
  117. http://ircv3.net/specs/core/capability-negotiation-3.2.html`,
  118. },
  119. "chathistory": {
  120. text: `CHATHISTORY [params]
  121. CHATHISTORY is a history replay command associated with the IRCv3
  122. specification draft/chathistory. See this document:
  123. https://github.com/ircv3/ircv3-specifications/pull/393`,
  124. },
  125. "debug": {
  126. oper: true,
  127. text: `DEBUG <option>
  128. Provides various debugging commands for the IRCd. <option> can be one of:
  129. * GCSTATS: Garbage control statistics.
  130. * NUMGOROUTINE: Number of goroutines in use.
  131. * STARTCPUPROFILE: Starts the CPU profiler.
  132. * STOPCPUPROFILE: Stops the CPU profiler.
  133. * PROFILEHEAP: Writes a memory profile.
  134. * CRASHSERVER: Crashes the server (for use in failover testing)`,
  135. },
  136. "deoper": {
  137. oper: true,
  138. text: `DEOPER
  139. DEOPER removes the IRCop privileges granted to you by a successful /OPER.`,
  140. },
  141. "dline": {
  142. oper: true,
  143. text: `DLINE [ANDKILL] [MYSELF] [duration] <ip>/<net> [ON <server>] [reason [| oper reason]]
  144. DLINE LIST
  145. Bans an IP address or network from connecting to the server. If the duration is
  146. given then only for that long. The reason is shown to the user themselves, but
  147. everyone else will see a standard message. The oper reason is shown to
  148. operators getting info about the DLINEs that exist.
  149. Bans are saved across subsequent launches of the server.
  150. "ANDKILL" means that all matching clients are also removed from the server.
  151. "MYSELF" is required when the DLINE matches the address the person applying it is connected
  152. from. If "MYSELF" is not given, trying to DLINE yourself will result in an error.
  153. [duration] can be of the following forms:
  154. 1y 12mo 31d 10h 8m 13s
  155. <net> is specified in typical CIDR notation. For example:
  156. 127.0.0.1/8
  157. 8.8.8.8/24
  158. ON <server> specifies that the ban is to be set on that specific server.
  159. [reason] and [oper reason], if they exist, are separated by a vertical bar (|).
  160. If "DLINE LIST" is sent, the server sends back a list of our current DLINEs.`,
  161. },
  162. "help": {
  163. text: `HELP <argument>
  164. Get an explanation of <argument>, or "index" for a list of help topics.`,
  165. },
  166. "helpop": {
  167. text: `HELPOP <argument>
  168. Get an explanation of <argument>, or "index" for a list of help topics.`,
  169. },
  170. "history": {
  171. text: `HISTORY <target> [limit]
  172. Replay message history. <target> can be a channel name, "me" to replay direct
  173. message history, or a nickname to replay another client's direct message
  174. history (they must be logged into the same account as you). [limit] can be
  175. either an integer (the maximum number of messages to replay), or a time
  176. duration like 10m or 1h (the time window within which to replay messages).`,
  177. },
  178. "info": {
  179. text: `INFO
  180. Sends information about the server, developers, etc.`,
  181. },
  182. "invite": {
  183. text: `INVITE <nickname> <channel>
  184. Invites the given user to the given channel, so long as you have the
  185. appropriate channel privs.`,
  186. },
  187. "ison": {
  188. text: `ISON <nickname>{ <nickname>}
  189. Returns whether the given nicks exist on the network.`,
  190. },
  191. "join": {
  192. text: `JOIN <channel>{,<channel>} [<key>{,<key>}]
  193. Joins the given channels with the matching keys.`,
  194. },
  195. "kick": {
  196. text: `KICK <channel> <user> [reason]
  197. Removes the user from the given channel, so long as you have the appropriate
  198. channel privs.`,
  199. },
  200. "kill": {
  201. oper: true,
  202. text: `KILL <nickname> [reason]
  203. Removes the given user from the network, showing them the reason if it is
  204. supplied.`,
  205. },
  206. "kline": {
  207. oper: true,
  208. text: `KLINE [ANDKILL] [MYSELF] [duration] <mask> [ON <server>] [reason [| oper reason]]
  209. KLINE LIST
  210. Bans a mask from connecting to the server. If the duration is given then only for that
  211. long. The reason is shown to the user themselves, but everyone else will see a standard
  212. message. The oper reason is shown to operators getting info about the KLINEs that exist.
  213. Bans are saved across subsequent launches of the server.
  214. "ANDKILL" means that all matching clients are also removed from the server.
  215. "MYSELF" is required when the KLINE matches the address the person applying it is connected
  216. from. If "MYSELF" is not given, trying to KLINE yourself will result in an error.
  217. [duration] can be of the following forms:
  218. 1y 12mo 31d 10h 8m 13s
  219. <mask> is specified in typical IRC format. For example:
  220. dan
  221. dan!5*@127.*
  222. ON <server> specifies that the ban is to be set on that specific server.
  223. [reason] and [oper reason], if they exist, are separated by a vertical bar (|).
  224. If "KLINE LIST" is sent, the server sends back a list of our current KLINEs.`,
  225. },
  226. "language": {
  227. text: `LANGUAGE <code>{ <code>}
  228. Sets your preferred languages to the given ones.`,
  229. },
  230. "list": {
  231. text: `LIST [<channel>{,<channel>}] [<elistcond>{,<elistcond>}]
  232. Shows information on the given channels (or if none are given, then on all
  233. channels). <elistcond>s modify how the channels are selected.`,
  234. //TODO(dan): Explain <elistcond>s in more specific detail
  235. },
  236. "lusers": {
  237. text: `LUSERS [<mask> [<server>]]
  238. Shows statistics about the size of the network. If <mask> is given, only
  239. returns stats for servers matching the given mask. If <server> is given, the
  240. command is processed by that server.`,
  241. },
  242. "mode": {
  243. text: `MODE <target> [<modestring> [<mode arguments>...]]
  244. Sets and removes modes from the given target. For more specific information on
  245. mode characters, see the help for "modes".`,
  246. },
  247. "monitor": {
  248. text: `MONITOR <subcmd>
  249. Allows the monitoring of nicknames, for alerts when they are online and
  250. offline. The subcommands are:
  251. MONITOR + target{,target}
  252. Adds the given names to your list of monitored nicknames.
  253. MONITOR - target{,target}
  254. Removes the given names from your list of monitored nicknames.
  255. MONITOR C
  256. Clears your list of monitored nicknames.
  257. MONITOR L
  258. Lists all the nicknames you are currently monitoring.
  259. MONITOR S
  260. Lists whether each nick in your MONITOR list is online or offline.`,
  261. },
  262. "motd": {
  263. text: `MOTD [server]
  264. Returns the message of the day for this, or the given, server.`,
  265. },
  266. "names": {
  267. text: `NAMES [<channel>{,<channel>}]
  268. Views the clients joined to a channel and their channel membership prefixes. To
  269. view the channel membership prefixes supported by this server, see the help for
  270. "PREFIX".`,
  271. },
  272. "nick": {
  273. text: `NICK <newnick>
  274. Sets your nickname to the new given one.`,
  275. },
  276. "notice": {
  277. text: `NOTICE <target>{,<target>} <text to be sent>
  278. Sends the text to the given targets as a NOTICE.`,
  279. },
  280. "npc": {
  281. text: `NPC <target> <sourcenick> <text to be sent>
  282. The NPC command is used to send a message to the target as the source.
  283. Requires the roleplay mode (+E) to be set on the target.`,
  284. },
  285. "npca": {
  286. text: `NPCA <target> <sourcenick> <text to be sent>
  287. The NPC command is used to send an action to the target as the source.
  288. Requires the roleplay mode (+E) to be set on the target.`,
  289. },
  290. "oper": {
  291. text: `OPER <name> [password]
  292. If the correct details are given, gives you IRCop privs.`,
  293. },
  294. "part": {
  295. text: `PART <channel>{,<channel>} [reason]
  296. Leaves the given channels and shows people the given reason.`,
  297. },
  298. "pass": {
  299. text: `PASS <password>
  300. When the server requires a connection password to join, used to send us the
  301. password.`,
  302. },
  303. "ping": {
  304. text: `PING <args>...
  305. Requests a PONG. Used to check link connectivity.`,
  306. },
  307. "pong": {
  308. text: `PONG <args>...
  309. Replies to a PING. Used to check link connectivity.`,
  310. },
  311. "privmsg": {
  312. text: `PRIVMSG <target>{,<target>} <text to be sent>
  313. Sends the text to the given targets as a PRIVMSG.`,
  314. },
  315. "rename": {
  316. text: `RENAME <channel> <newname> [<reason>]
  317. Renames the given channel with the given reason, if possible.
  318. For example:
  319. RENAME #ircv2 #ircv3 :Protocol upgrades!`,
  320. },
  321. "sajoin": {
  322. oper: true,
  323. text: `SAJOIN [nick] #channel{,#channel}
  324. Forcibly joins a user to a channel, ignoring restrictions like bans, user limits
  325. and channel keys. If [nick] is omitted, it defaults to the operator.`,
  326. },
  327. "sanick": {
  328. oper: true,
  329. text: `SANICK <currentnick> <newnick>
  330. Gives the given user a new nickname.`,
  331. },
  332. "samode": {
  333. oper: true,
  334. text: `SAMODE <target> [<modestring> [<mode arguments>...]]
  335. Forcibly sets and removes modes from the given target -- only available to
  336. opers. For more specific information on mode characters, see the help for
  337. "cmode" and "umode".`,
  338. },
  339. "scene": {
  340. text: `SCENE <target> <text to be sent>
  341. The SCENE command is used to send a scene notification to the given target.`,
  342. },
  343. "setname": {
  344. text: `SETNAME <realname>
  345. The SETNAME command updates the realname to be the newly-given one.`,
  346. },
  347. "summon": {
  348. text: `SUMMON [parameters]
  349. The SUMMON command is not implemented.`,
  350. },
  351. "tagmsg": {
  352. text: `@+client-only-tags TAGMSG <target>{,<target>}
  353. Sends the given client-only tags to the given targets as a TAGMSG. See the IRCv3
  354. specs for more info: http://ircv3.net/specs/core/message-tags-3.3.html`,
  355. },
  356. "quit": {
  357. text: `QUIT [reason]
  358. Indicates that you're leaving the server, and shows everyone the given reason.`,
  359. },
  360. "rehash": {
  361. oper: true,
  362. text: `REHASH
  363. Reloads the config file and updates TLS certificates on listeners`,
  364. },
  365. "resume": {
  366. text: `RESUME <oldnick> [timestamp]
  367. Sent before registration has completed, this indicates that the client wants to
  368. resume their old connection <oldnick>.`,
  369. },
  370. "time": {
  371. text: `TIME [server]
  372. Shows the time of the current, or the given, server.`,
  373. },
  374. "topic": {
  375. text: `TOPIC <channel> [topic]
  376. If [topic] is given, sets the topic in the channel to that. If [topic] is not
  377. given, views the current topic on the channel.`,
  378. },
  379. "undline": {
  380. oper: true,
  381. text: `UNDLINE <ip>/<net>
  382. Removes an existing ban on an IP address or a network.
  383. <net> is specified in typical CIDR notation. For example:
  384. 127.0.0.1/8
  385. 8.8.8.8/24`,
  386. },
  387. "unkline": {
  388. oper: true,
  389. text: `UNKLINE <mask>
  390. Removes an existing ban on a mask.
  391. For example:
  392. dan
  393. dan!5*@127.*`,
  394. },
  395. "user": {
  396. text: `USER <username> 0 * <realname>
  397. Used in connection registration, sets your username and realname to the given
  398. values (though your username may also be looked up with Ident).`,
  399. },
  400. "users": {
  401. text: `USERS [parameters]
  402. The USERS command is not implemented.`,
  403. },
  404. "userhost": {
  405. text: `USERHOST <nickname>{ <nickname>}
  406. Shows information about the given users. Takes up to 10 nicknames.`,
  407. },
  408. "version": {
  409. text: `VERSION [server]
  410. Views the version of software and the RPL_ISUPPORT tokens for the given server.`,
  411. },
  412. "webirc": {
  413. oper: true, // not really, but it's restricted anyways
  414. text: `WEBIRC <password> <gateway> <hostname> <ip> [:<flags>]
  415. Used by web<->IRC gateways and bouncers, the WEBIRC command allows gateways to
  416. pass-through the real IP addresses of clients:
  417. ircv3.net/specs/extensions/webirc.html
  418. <flags> is a list of space-separated strings indicating various details about
  419. the connection from the client to the gateway, such as:
  420. - tls: this flag indicates that the client->gateway connection is secure`,
  421. },
  422. "who": {
  423. text: `WHO <name> [o]
  424. Returns information for the given user.`,
  425. },
  426. "whois": {
  427. text: `WHOIS <client>{,<client>}
  428. Returns information for the given user(s).`,
  429. },
  430. "whowas": {
  431. text: `WHOWAS <nickname>
  432. Returns historical information on the last user with the given nickname.`,
  433. },
  434. "znc": {
  435. text: `ZNC <module> [params]
  436. Used to emulate features of the ZNC bouncer. This command is not intended
  437. for direct use by end users.`,
  438. duplicate: true,
  439. },
  440. // Informational
  441. "modes": {
  442. textGenerator: modesTextGenerator,
  443. helpType: InformationHelpEntry,
  444. },
  445. "cmode": {
  446. text: cmodeHelpText,
  447. helpType: InformationHelpEntry,
  448. },
  449. "cmodes": {
  450. text: cmodeHelpText,
  451. helpType: InformationHelpEntry,
  452. duplicate: true,
  453. },
  454. "umode": {
  455. text: umodeHelpText,
  456. helpType: InformationHelpEntry,
  457. },
  458. "umodes": {
  459. text: umodeHelpText,
  460. helpType: InformationHelpEntry,
  461. duplicate: true,
  462. },
  463. "snomask": {
  464. text: snomaskHelpText,
  465. helpType: InformationHelpEntry,
  466. oper: true,
  467. duplicate: true,
  468. },
  469. "snomasks": {
  470. text: snomaskHelpText,
  471. helpType: InformationHelpEntry,
  472. oper: true,
  473. },
  474. // RPL_ISUPPORT
  475. "casemapping": {
  476. text: `RPL_ISUPPORT CASEMAPPING
  477. Oragono supports an experimental unicode casemapping designed for extended
  478. Unicode support. This casemapping is based off RFC 7613 and the draft rfc7613
  479. casemapping spec here: https://oragono.io/specs.html`,
  480. helpType: ISupportHelpEntry,
  481. },
  482. "prefix": {
  483. text: `RPL_ISUPPORT PREFIX
  484. Oragono supports the following channel membership prefixes:
  485. +q (~) | Founder channel mode.
  486. +a (&) | Admin channel mode.
  487. +o (@) | Operator channel mode.
  488. +h (%) | Halfop channel mode.
  489. +v (+) | Voice channel mode.`,
  490. helpType: ISupportHelpEntry,
  491. },
  492. }
  493. // modesTextGenerator generates the text for the 'modes' help entry.
  494. // it exists only so we can translate this entry appropriately.
  495. func modesTextGenerator(client *Client) string {
  496. return client.t(cmodeHelpText) + "\n\n" + client.t(umodeHelpText)
  497. }
  498. type HelpIndexManager struct {
  499. sync.RWMutex // tier 1
  500. langToIndex map[string]string
  501. langToOperIndex map[string]string
  502. }
  503. // GenerateHelpIndex is used to generate HelpIndex.
  504. // Returns: a map from language code to the help index in that language.
  505. func GenerateHelpIndex(lm *languages.Manager, forOpers bool) map[string]string {
  506. // generate the help entry lists
  507. var commands, isupport, information []string
  508. var line string
  509. for name, info := range Help {
  510. if info.duplicate {
  511. continue
  512. }
  513. if info.oper && !forOpers {
  514. continue
  515. }
  516. line = fmt.Sprintf(" %s", name)
  517. if info.helpType == CommandHelpEntry {
  518. commands = append(commands, line)
  519. } else if info.helpType == ISupportHelpEntry {
  520. isupport = append(isupport, line)
  521. } else if info.helpType == InformationHelpEntry {
  522. information = append(information, line)
  523. }
  524. }
  525. // create the strings
  526. sort.Strings(commands)
  527. commandsString := strings.Join(commands, "\n")
  528. sort.Strings(isupport)
  529. isupportString := strings.Join(isupport, "\n")
  530. sort.Strings(information)
  531. informationString := strings.Join(information, "\n")
  532. // sub them in
  533. defaultHelpIndex := `= Help Topics =
  534. Commands:
  535. %[1]s
  536. RPL_ISUPPORT Tokens:
  537. %[2]s
  538. Information:
  539. %[3]s`
  540. newHelpIndex := make(map[string]string)
  541. newHelpIndex["en"] = fmt.Sprintf(defaultHelpIndex, commandsString, isupportString, informationString)
  542. for langCode := range lm.Languages {
  543. translatedHelpIndex := lm.Translate([]string{langCode}, defaultHelpIndex)
  544. if translatedHelpIndex != defaultHelpIndex {
  545. newHelpIndex[langCode] = fmt.Sprintf(translatedHelpIndex, commandsString, isupportString, informationString)
  546. }
  547. }
  548. return newHelpIndex
  549. }
  550. // GenerateIndices regenerates our help indexes for each currently enabled language.
  551. func (hm *HelpIndexManager) GenerateIndices(lm *languages.Manager) {
  552. // generate help indexes
  553. langToIndex := GenerateHelpIndex(lm, false)
  554. langToOperIndex := GenerateHelpIndex(lm, true)
  555. hm.Lock()
  556. defer hm.Unlock()
  557. hm.langToIndex = langToIndex
  558. hm.langToOperIndex = langToOperIndex
  559. }
  560. // sendHelp sends the client help of the given string.
  561. func (client *Client) sendHelp(name string, text string, rb *ResponseBuffer) {
  562. splitName := strings.Split(name, " ")
  563. textLines := strings.Split(text, "\n")
  564. for i, line := range textLines {
  565. args := splitName
  566. args = append(args, line)
  567. if i == 0 {
  568. rb.Add(nil, client.server.name, RPL_HELPSTART, args...)
  569. } else {
  570. rb.Add(nil, client.server.name, RPL_HELPTXT, args...)
  571. }
  572. }
  573. args := splitName
  574. args = append(args, client.t("End of /HELPOP"))
  575. rb.Add(nil, client.server.name, RPL_ENDOFHELP, args...)
  576. }
  577. // GetHelpIndex returns the help index for the given language.
  578. func (hm *HelpIndexManager) GetIndex(languages []string, oper bool) string {
  579. hm.RLock()
  580. langToIndex := hm.langToIndex
  581. if oper {
  582. langToIndex = hm.langToOperIndex
  583. }
  584. hm.RUnlock()
  585. for _, lang := range languages {
  586. index, exists := langToIndex[lang]
  587. if exists {
  588. return index
  589. }
  590. }
  591. // 'en' always exists
  592. return langToIndex["en"]
  593. }
  594. func init() {
  595. // startup check that we have HELP entries for every command
  596. for name := range Commands {
  597. _, exists := Help[strings.ToLower(name)]
  598. if !exists {
  599. panic(fmt.Sprintf("Help entry does not exist for command %s", name))
  600. }
  601. }
  602. }