Skip to content

Commit ce92598

Browse files
committed
Add handlers for HELP and INFO
1 parent c5e19ce commit ce92598

File tree

3 files changed

+64
-1
lines changed

3 files changed

+64
-1
lines changed

docs/events.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,30 @@ Only on supporting IRC servers with CHGHOST capabilities and 'enable_chghost' se
545545

546546

547547
#### Misc
548+
**motd**
549+
~~~javascript
550+
{
551+
motd: 'combined motd text which will contain newlines',
552+
tags: {},
553+
}
554+
~~~
555+
556+
**info**
557+
~~~javascript
558+
{
559+
info: 'combined info text which will contain newlines (RPL_INFO)',
560+
tags: {},
561+
}
562+
~~~
563+
564+
**help**
565+
~~~javascript
566+
{
567+
help: 'combined help text which will contain newlines (RPL_HELPTXT)',
568+
tags: {},
569+
}
570+
~~~
571+
548572
**batch start**
549573

550574
On capable networks a set of commands may be batched together. The commands will be

src/commands/handlers/misc.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,42 @@ const handlers = {
212212
cache.destroy();
213213
},
214214

215+
RPL_INFO: function(command, handler) {
216+
const cache = handler.cache('info');
217+
if (!cache.info) {
218+
cache.info = '';
219+
}
220+
cache.info += command.params[command.params.length - 1] + '\n';
221+
},
222+
223+
RPL_ENDOFINFO: function(command, handler) {
224+
const cache = handler.cache('info');
225+
handler.emit('info', {
226+
info: cache.info,
227+
tags: command.tags
228+
});
229+
cache.destroy();
230+
},
231+
232+
RPL_HELPSTART: function(command, handler) {
233+
const cache = handler.cache('help');
234+
cache.help = command.params[command.params.length - 1] + '\n';
235+
},
236+
237+
RPL_HELPTXT: function(command, handler) {
238+
const cache = handler.cache('help');
239+
cache.help += command.params[command.params.length - 1] + '\n';
240+
},
241+
242+
RPL_ENDOFHELP: function(command, handler) {
243+
const cache = handler.cache('help');
244+
handler.emit('help', {
245+
help: cache.help,
246+
tags: command.tags
247+
});
248+
cache.destroy();
249+
},
250+
215251
BATCH: function(command, handler) {
216252
const batch_start = command.params[0].substr(0, 1) === '+';
217253
const batch_id = command.params[0].substr(1);

src/commands/numerics.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ module.exports = {
111111
'369': 'RPL_ENDOFWHOWAS',
112112
'371': 'RPL_INFO',
113113
'372': 'RPL_MOTD',
114-
'374': 'RPL_ENDINFO',
114+
'374': 'RPL_ENDOFINFO',
115115
'375': 'RPL_MOTDSTART',
116116
'376': 'RPL_ENDOFMOTD',
117117
'378': 'RPL_WHOISHOST',
@@ -148,6 +148,9 @@ module.exports = {
148148
'491': 'ERR_NOOPERHOST',
149149
'670': 'RPL_STARTTLS',
150150
'671': 'RPL_WHOISSECURE',
151+
'704': 'RPL_HELPSTART',
152+
'705': 'RPL_HELPTXT',
153+
'706': 'RPL_ENDOFHELP',
151154
'900': 'RPL_LOGGEDIN',
152155
'901': 'RPL_LOGGEDOUT',
153156
'903': 'RPL_SASLLOGGEDIN',

0 commit comments

Comments
 (0)