Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746
  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. "extjwt": {
  163. text: `EXTJWT <target> [service_name]
  164. Get a JSON Web Token for target (either * or a channel name).`,
  165. },
  166. "help": {
  167. text: `HELP <argument>
  168. Get an explanation of <argument>, or "index" for a list of help topics.`,
  169. },
  170. "helpop": {
  171. text: `HELPOP <argument>
  172. Get an explanation of <argument>, or "index" for a list of help topics.`,
  173. },
  174. "history": {
  175. text: `HISTORY <target> [limit]
  176. Replay message history. <target> can be a channel name, "me" to replay direct
  177. message history, or a nickname to replay another client's direct message
  178. history (they must be logged into the same account as you). [limit] can be
  179. either an integer (the maximum number of messages to replay), or a time
  180. duration like 10m or 1h (the time window within which to replay messages).`,
  181. },
  182. "info": {
  183. text: `INFO
  184. Sends information about the server, developers, etc.`,
  185. },
  186. "invite": {
  187. text: `INVITE <nickname> <channel>
  188. Invites the given user to the given channel, so long as you have the
  189. appropriate channel privs.`,
  190. },
  191. "ison": {
  192. text: `ISON <nickname>{ <nickname>}
  193. Returns whether the given nicks exist on the network.`,
  194. },
  195. "join": {
  196. text: `JOIN <channel>{,<channel>} [<key>{,<key>}]
  197. Joins the given channels with the matching keys.`,
  198. },
  199. "kick": {
  200. text: `KICK <channel> <user> [reason]
  201. Removes the user from the given channel, so long as you have the appropriate
  202. channel privs.`,
  203. },
  204. "kill": {
  205. oper: true,
  206. text: `KILL <nickname> [reason]
  207. Removes the given user from the network, showing them the reason if it is
  208. supplied.`,
  209. },
  210. "kline": {
  211. oper: true,
  212. text: `KLINE [ANDKILL] [MYSELF] [duration] <mask> [ON <server>] [reason [| oper reason]]
  213. KLINE LIST
  214. Bans a mask from connecting to the server. If the duration is given then only for that
  215. long. The reason is shown to the user themselves, but everyone else will see a standard
  216. message. The oper reason is shown to operators getting info about the KLINEs that exist.
  217. Bans are saved across subsequent launches of the server.
  218. "ANDKILL" means that all matching clients are also removed from the server.
  219. "MYSELF" is required when the KLINE matches the address the person applying it is connected
  220. from. If "MYSELF" is not given, trying to KLINE yourself will result in an error.
  221. [duration] can be of the following forms:
  222. 1y 12mo 31d 10h 8m 13s
  223. <mask> is specified in typical IRC format. For example:
  224. dan
  225. dan!5*@127.*
  226. ON <server> specifies that the ban is to be set on that specific server.
  227. [reason] and [oper reason], if they exist, are separated by a vertical bar (|).
  228. If "KLINE LIST" is sent, the server sends back a list of our current KLINEs.`,
  229. },
  230. "language": {
  231. text: `LANGUAGE <code>{ <code>}
  232. Sets your preferred languages to the given ones.`,
  233. },
  234. "list": {
  235. text: `LIST [<channel>{,<channel>}] [<elistcond>{,<elistcond>}]
  236. Shows information on the given channels (or if none are given, then on all
  237. channels). <elistcond>s modify how the channels are selected.`,
  238. //TODO(dan): Explain <elistcond>s in more specific detail
  239. },
  240. "lusers": {
  241. text: `LUSERS [<mask> [<server>]]
  242. Shows statistics about the size of the network. If <mask> is given, only
  243. returns stats for servers matching the given mask. If <server> is given, the
  244. command is processed by that server.`,
  245. },
  246. "mode": {
  247. text: `MODE <target> [<modestring> [<mode arguments>...]]
  248. Sets and removes modes from the given target. For more specific information on
  249. mode characters, see the help for "modes".`,
  250. },
  251. "monitor": {
  252. text: `MONITOR <subcmd>
  253. Allows the monitoring of nicknames, for alerts when they are online and
  254. offline. The subcommands are:
  255. MONITOR + target{,target}
  256. Adds the given names to your list of monitored nicknames.
  257. MONITOR - target{,target}
  258. Removes the given names from your list of monitored nicknames.
  259. MONITOR C
  260. Clears your list of monitored nicknames.
  261. MONITOR L
  262. Lists all the nicknames you are currently monitoring.
  263. MONITOR S
  264. Lists whether each nick in your MONITOR list is online or offline.`,
  265. },
  266. "motd": {
  267. text: `MOTD [server]
  268. Returns the message of the day for this, or the given, server.`,
  269. },
  270. "names": {
  271. text: `NAMES [<channel>{,<channel>}]
  272. Views the clients joined to a channel and their channel membership prefixes. To
  273. view the channel membership prefixes supported by this server, see the help for
  274. "PREFIX".`,
  275. },
  276. "nick": {
  277. text: `NICK <newnick>
  278. Sets your nickname to the new given one.`,
  279. },
  280. "notice": {
  281. text: `NOTICE <target>{,<target>} <text to be sent>
  282. Sends the text to the given targets as a NOTICE.`,
  283. },
  284. "npc": {
  285. text: `NPC <target> <sourcenick> <text to be sent>
  286. The NPC command is used to send a message to the target as the source.
  287. Requires the roleplay mode (+E) to be set on the target.`,
  288. },
  289. "npca": {
  290. text: `NPCA <target> <sourcenick> <text to be sent>
  291. The NPC command is used to send an action to the target as the source.
  292. Requires the roleplay mode (+E) to be set on the target.`,
  293. },
  294. "oper": {
  295. text: `OPER <name> [password]
  296. If the correct details are given, gives you IRCop privs.`,
  297. },
  298. "part": {
  299. text: `PART <channel>{,<channel>} [reason]
  300. Leaves the given channels and shows people the given reason.`,
  301. },
  302. "pass": {
  303. text: `PASS <password>
  304. When the server requires a connection password to join, used to send us the
  305. password.`,
  306. },
  307. "ping": {
  308. text: `PING <args>...
  309. Requests a PONG. Used to check link connectivity.`,
  310. },
  311. "pong": {
  312. text: `PONG <args>...
  313. Replies to a PING. Used to check link connectivity.`,
  314. },
  315. "privmsg": {
  316. text: `PRIVMSG <target>{,<target>} <text to be sent>
  317. Sends the text to the given targets as a PRIVMSG.`,
  318. },
  319. "rename": {
  320. text: `RENAME <channel> <newname> [<reason>]
  321. Renames the given channel with the given reason, if possible.
  322. For example:
  323. RENAME #ircv2 #ircv3 :Protocol upgrades!`,
  324. },
  325. "sajoin": {
  326. oper: true,
  327. text: `SAJOIN [nick] #channel{,#channel}
  328. Forcibly joins a user to a channel, ignoring restrictions like bans, user limits
  329. and channel keys. If [nick] is omitted, it defaults to the operator.`,
  330. },
  331. "sanick": {
  332. oper: true,
  333. text: `SANICK <currentnick> <newnick>
  334. Gives the given user a new nickname.`,
  335. },
  336. "samode": {
  337. oper: true,
  338. text: `SAMODE <target> [<modestring> [<mode arguments>...]]
  339. Forcibly sets and removes modes from the given target -- only available to
  340. opers. For more specific information on mode characters, see the help for
  341. "cmode" and "umode".`,
  342. },
  343. "scene": {
  344. text: `SCENE <target> <text to be sent>
  345. The SCENE command is used to send a scene notification to the given target.`,
  346. },
  347. "setname": {
  348. text: `SETNAME <realname>
  349. The SETNAME command updates the realname to be the newly-given one.`,
  350. },
  351. "summon": {
  352. text: `SUMMON [parameters]
  353. The SUMMON command is not implemented.`,
  354. },
  355. "tagmsg": {
  356. text: `@+client-only-tags TAGMSG <target>{,<target>}
  357. Sends the given client-only tags to the given targets as a TAGMSG. See the IRCv3
  358. specs for more info: http://ircv3.net/specs/core/message-tags-3.3.html`,
  359. },
  360. "quit": {
  361. text: `QUIT [reason]
  362. Indicates that you're leaving the server, and shows everyone the given reason.`,
  363. },
  364. "rehash": {
  365. oper: true,
  366. text: `REHASH
  367. Reloads the config file and updates TLS certificates on listeners`,
  368. },
  369. "resume": {
  370. text: `RESUME <oldnick> [timestamp]
  371. Sent before registration has completed, this indicates that the client wants to
  372. resume their old connection <oldnick>.`,
  373. },
  374. "time": {
  375. text: `TIME [server]
  376. Shows the time of the current, or the given, server.`,
  377. },
  378. "topic": {
  379. text: `TOPIC <channel> [topic]
  380. If [topic] is given, sets the topic in the channel to that. If [topic] is not
  381. given, views the current topic on the channel.`,
  382. },
  383. "undline": {
  384. oper: true,
  385. text: `UNDLINE <ip>/<net>
  386. Removes an existing ban on an IP address or a network.
  387. <net> is specified in typical CIDR notation. For example:
  388. 127.0.0.1/8
  389. 8.8.8.8/24`,
  390. },
  391. "unkline": {
  392. oper: true,
  393. text: `UNKLINE <mask>
  394. Removes an existing ban on a mask.
  395. For example:
  396. dan
  397. dan!5*@127.*`,
  398. },
  399. "user": {
  400. text: `USER <username> 0 * <realname>
  401. Used in connection registration, sets your username and realname to the given
  402. values (though your username may also be looked up with Ident).`,
  403. },
  404. "users": {
  405. text: `USERS [parameters]
  406. The USERS command is not implemented.`,
  407. },
  408. "userhost": {
  409. text: `USERHOST <nickname>{ <nickname>}
  410. Shows information about the given users. Takes up to 10 nicknames.`,
  411. },
  412. "version": {
  413. text: `VERSION [server]
  414. Views the version of software and the RPL_ISUPPORT tokens for the given server.`,
  415. },
  416. "webirc": {
  417. oper: true, // not really, but it's restricted anyways
  418. text: `WEBIRC <password> <gateway> <hostname> <ip> [:<flags>]
  419. Used by web<->IRC gateways and bouncers, the WEBIRC command allows gateways to
  420. pass-through the real IP addresses of clients:
  421. ircv3.net/specs/extensions/webirc.html
  422. <flags> is a list of space-separated strings indicating various details about
  423. the connection from the client to the gateway, such as:
  424. - tls: this flag indicates that the client->gateway connection is secure`,
  425. },
  426. "who": {
  427. text: `WHO <name> [o]
  428. Returns information for the given user.`,
  429. },
  430. "whois": {
  431. text: `WHOIS <client>{,<client>}
  432. Returns information for the given user(s).`,
  433. },
  434. "whowas": {
  435. text: `WHOWAS <nickname>
  436. Returns historical information on the last user with the given nickname.`,
  437. },
  438. "znc": {
  439. text: `ZNC <module> [params]
  440. Used to emulate features of the ZNC bouncer. This command is not intended
  441. for direct use by end users.`,
  442. duplicate: true,
  443. },
  444. // Informational
  445. "modes": {
  446. textGenerator: modesTextGenerator,
  447. helpType: InformationHelpEntry,
  448. },
  449. "cmode": {
  450. text: cmodeHelpText,
  451. helpType: InformationHelpEntry,
  452. },
  453. "cmodes": {
  454. text: cmodeHelpText,
  455. helpType: InformationHelpEntry,
  456. duplicate: true,
  457. },
  458. "umode": {
  459. text: umodeHelpText,
  460. helpType: InformationHelpEntry,
  461. },
  462. "umodes": {
  463. text: umodeHelpText,
  464. helpType: InformationHelpEntry,
  465. duplicate: true,
  466. },
  467. "snomask": {
  468. text: snomaskHelpText,
  469. helpType: InformationHelpEntry,
  470. oper: true,
  471. duplicate: true,
  472. },
  473. "snomasks": {
  474. text: snomaskHelpText,
  475. helpType: InformationHelpEntry,
  476. oper: true,
  477. },
  478. // RPL_ISUPPORT
  479. "casemapping": {
  480. text: `RPL_ISUPPORT CASEMAPPING
  481. Oragono supports an experimental unicode casemapping designed for extended
  482. Unicode support. This casemapping is based off RFC 7613 and the draft rfc7613
  483. casemapping spec here: https://oragono.io/specs.html`,
  484. helpType: ISupportHelpEntry,
  485. },
  486. "prefix": {
  487. text: `RPL_ISUPPORT PREFIX
  488. Oragono supports the following channel membership prefixes:
  489. +q (~) | Founder channel mode.
  490. +a (&) | Admin channel mode.
  491. +o (@) | Operator channel mode.
  492. +h (%) | Halfop channel mode.
  493. +v (+) | Voice channel mode.`,
  494. helpType: ISupportHelpEntry,
  495. },
  496. }
  497. // modesTextGenerator generates the text for the 'modes' help entry.
  498. // it exists only so we can translate this entry appropriately.
  499. func modesTextGenerator(client *Client) string {
  500. return client.t(cmodeHelpText) + "\n\n" + client.t(umodeHelpText)
  501. }
  502. type HelpIndexManager struct {
  503. sync.RWMutex // tier 1
  504. langToIndex map[string]string
  505. langToOperIndex map[string]string
  506. }
  507. // GenerateHelpIndex is used to generate HelpIndex.
  508. // Returns: a map from language code to the help index in that language.
  509. func GenerateHelpIndex(lm *languages.Manager, forOpers bool) map[string]string {
  510. // generate the help entry lists
  511. var commands, isupport, information []string
  512. var line string
  513. for name, info := range Help {
  514. if info.duplicate {
  515. continue
  516. }
  517. if info.oper && !forOpers {
  518. continue
  519. }
  520. line = fmt.Sprintf(" %s", name)
  521. if info.helpType == CommandHelpEntry {
  522. commands = append(commands, line)
  523. } else if info.helpType == ISupportHelpEntry {
  524. isupport = append(isupport, line)
  525. } else if info.helpType == InformationHelpEntry {
  526. information = append(information, line)
  527. }
  528. }
  529. // create the strings
  530. sort.Strings(commands)
  531. commandsString := strings.Join(commands, "\n")
  532. sort.Strings(isupport)
  533. isupportString := strings.Join(isupport, "\n")
  534. sort.Strings(information)
  535. informationString := strings.Join(information, "\n")
  536. // sub them in
  537. defaultHelpIndex := `= Help Topics =
  538. Commands:
  539. %[1]s
  540. RPL_ISUPPORT Tokens:
  541. %[2]s
  542. Information:
  543. %[3]s`
  544. newHelpIndex := make(map[string]string)
  545. newHelpIndex["en"] = fmt.Sprintf(defaultHelpIndex, commandsString, isupportString, informationString)
  546. for langCode := range lm.Languages {
  547. translatedHelpIndex := lm.Translate([]string{langCode}, defaultHelpIndex)
  548. if translatedHelpIndex != defaultHelpIndex {
  549. newHelpIndex[langCode] = fmt.Sprintf(translatedHelpIndex, commandsString, isupportString, informationString)
  550. }
  551. }
  552. return newHelpIndex
  553. }
  554. // GenerateIndices regenerates our help indexes for each currently enabled language.
  555. func (hm *HelpIndexManager) GenerateIndices(lm *languages.Manager) {
  556. // generate help indexes
  557. langToIndex := GenerateHelpIndex(lm, false)
  558. langToOperIndex := GenerateHelpIndex(lm, true)
  559. hm.Lock()
  560. defer hm.Unlock()
  561. hm.langToIndex = langToIndex
  562. hm.langToOperIndex = langToOperIndex
  563. }
  564. // sendHelp sends the client help of the given string.
  565. func (client *Client) sendHelp(name string, text string, rb *ResponseBuffer) {
  566. splitName := strings.Split(name, " ")
  567. textLines := strings.Split(text, "\n")
  568. for i, line := range textLines {
  569. args := splitName
  570. args = append(args, line)
  571. if i == 0 {
  572. rb.Add(nil, client.server.name, RPL_HELPSTART, args...)
  573. } else {
  574. rb.Add(nil, client.server.name, RPL_HELPTXT, args...)
  575. }
  576. }
  577. args := splitName
  578. args = append(args, client.t("End of /HELPOP"))
  579. rb.Add(nil, client.server.name, RPL_ENDOFHELP, args...)
  580. }
  581. // GetHelpIndex returns the help index for the given language.
  582. func (hm *HelpIndexManager) GetIndex(languages []string, oper bool) string {
  583. hm.RLock()
  584. langToIndex := hm.langToIndex
  585. if oper {
  586. langToIndex = hm.langToOperIndex
  587. }
  588. hm.RUnlock()
  589. for _, lang := range languages {
  590. index, exists := langToIndex[lang]
  591. if exists {
  592. return index
  593. }
  594. }
  595. // 'en' always exists
  596. return langToIndex["en"]
  597. }
  598. func init() {
  599. // startup check that we have HELP entries for every command
  600. for name := range Commands {
  601. _, exists := Help[strings.ToLower(name)]
  602. if !exists {
  603. panic(fmt.Sprintf("Help entry does not exist for command %s", name))
  604. }
  605. }
  606. }