-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
53 lines (42 loc) · 1.07 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/**
* Simple test file for unibot-github plugin.
*
* Purpose of this is just to "mimic" actual IRC messages on channel where plugin is enabled.
*
* Usage:
* node test.js [message]
*
* @todo make real help for this.
*/
/**
* Runner dependencies.
*
* @type {exports}
*/
var _ = require('lodash');
var plugin = require('./index');
/**
* Nick who is making query
*
* @type {string}
*/
var from = 'tarlepp';
var message = process.argv.slice(2).join(' ');
if (_.isEmpty(message)) {
console.log('Please give some command to process...');
return;
}
message = '!' + message;
var match = false;
_.each(plugin({})({say: function(message, from) { from ? console.log(from + ': ' + message) : console.log(message); } }), function iterator(callback, pattern) {
var expression = new RegExp(pattern, 'i');
var matches = expression.exec(message);
if (matches) {
console.log('Plugin matches with: ' + message);
match = true;
callback(from, matches);
}
});
if (!match) {
console.log('Plugin does not match with: ' + message);
}