forked from GitHub/dbot
Compare commits
1034 Commits
Author | SHA1 | Date | |
---|---|---|---|
20582defd5 | |||
ac3d2761bc | |||
70a21d2b18 | |||
|
77a9c346d8 | ||
|
97ebd371bf | ||
|
ec3d6ed13b | ||
|
a245d385f7 | ||
|
695398d8fb | ||
|
08922c8e67 | ||
|
dfdb31b31d | ||
|
1b18c9f048 | ||
|
8c97c665a6 | ||
|
1657e7cc02 | ||
|
09f8f525e6 | ||
|
d64375ca50 | ||
|
a4697e8d36 | ||
|
a97bda3c20 | ||
|
ab6cb80ea2 | ||
|
c26be5410f | ||
|
e11abe5af4 | ||
|
6a255244df | ||
|
f3dcc0e693 | ||
|
ed69582c7a | ||
|
814a84ee8e | ||
|
a5f9998872 | ||
|
d544dcf017 | ||
|
bbfc4c18a6 | ||
|
0c8c377b08 | ||
|
c298813b28 | ||
|
0f0877f27a | ||
|
554a9e995b | ||
|
ae989d60ae | ||
|
f7b83e98b7 | ||
|
b415ee086f | ||
|
944827c4d9 | ||
|
97642f35a9 | ||
|
2d20f19572 | ||
|
98c8894f95 | ||
|
11a7f1d20e | ||
|
86d0a6f31b | ||
|
71c2c52d47 | ||
|
fbc4ac5afe | ||
|
a574b7d2ed | ||
|
93ee3cb08b | ||
|
597171c37d | ||
|
8182980420 | ||
|
bb28cebde1 | ||
|
48728c5801 | ||
|
43cfe3b637 | ||
|
19cc4c474d | ||
|
f5c9a275a9 | ||
|
ff7be1f31d | ||
|
0118f962b6 | ||
|
167525b5b9 | ||
|
25d572e8cb | ||
|
72a4552742 | ||
|
bd148915ed | ||
|
354c0935b9 | ||
|
4a4e41b702 | ||
|
b87175e665 | ||
|
9a7e1ab4bf | ||
|
10c642c94f | ||
|
dde0200032 | ||
|
217e65df96 | ||
|
03067f97d6 | ||
|
00215f62f0 | ||
|
9a4a86c6ba | ||
|
7d31560458 | ||
|
f55f645a3b | ||
|
7debad9a1d | ||
|
9faffa0d11 | ||
|
3c22b811ad | ||
|
329836d577 | ||
|
5796308e62 | ||
|
3972b5272b | ||
|
17ecf62da0 | ||
|
9b55509257 | ||
|
69c06537e2 | ||
|
8fe032579d | ||
|
fe8168a237 | ||
|
016c132158 | ||
|
9df86cdd99 | ||
|
00ac08a9da | ||
|
eba4a9a4a1 | ||
|
beaa420015 | ||
|
709cd085a9 | ||
|
56d12bd649 | ||
|
510a02d08a | ||
|
d7f212ea52 | ||
|
3b6dd18611 | ||
|
58256a8f62 | ||
|
0da6af229f | ||
|
8310dc38ff | ||
|
ebb0a023c0 | ||
|
f097685c3d | ||
|
4f269a5c02 | ||
|
777d738394 | ||
|
e62a1c8484 | ||
|
0f1c6c6782 | ||
|
b8bbaab9d9 | ||
|
3204c422bb | ||
|
ec86b6e1a8 | ||
|
07156b2eb3 | ||
|
d37326c88e | ||
|
1f0e13bd2a | ||
|
0d233f69b7 | ||
|
e22133d685 | ||
|
0d2d00635c | ||
|
d41836e937 | ||
|
c1c54bbd59 | ||
|
6a38eb5289 | ||
|
d25ec221c7 | ||
|
54efa27ff2 | ||
|
f02d2b74df | ||
|
330868686d | ||
|
9a44c41fbd | ||
|
92598b13c2 | ||
|
a57b123fed | ||
|
ef86954025 | ||
|
7964bb9e88 | ||
|
238c112986 | ||
|
d4d101bc94 | ||
|
5191eca0a4 | ||
|
3f599ddfc2 | ||
|
0e95f8e42a | ||
|
485e08ff97 | ||
|
ed24043a55 | ||
|
e8f657de94 | ||
|
aeea5a7e18 | ||
|
2b043d018b | ||
|
45a27904bd | ||
|
cfbb71faa6 | ||
|
d9093e6da8 | ||
|
930607b4fe | ||
|
601d10b0de | ||
|
92c045d8c7 | ||
|
face69d31a | ||
|
45153a45d2 | ||
|
e767e43771 | ||
|
2ebeea1ef4 | ||
|
a58e1fcc4b | ||
|
7f2878ce58 | ||
|
a5657a5a36 | ||
|
bab36d5af3 | ||
|
d19fc76088 | ||
|
fc0fe6f5be | ||
|
45e44bc7f8 | ||
|
d442461076 | ||
|
c47677a590 | ||
|
f2c61c95b9 | ||
|
e120869bcd | ||
|
a14d042be2 | ||
|
bc114a10e6 | ||
|
5e8ccb6bcc | ||
|
b61c482a32 | ||
|
ba2ad2649f | ||
|
0473597b0a | ||
|
04fb1cc67b | ||
|
72e6fca9e5 | ||
|
71632f401b | ||
|
d31a95b3a3 | ||
|
fa431ac800 | ||
|
aed72f52dc | ||
|
b9064302ba | ||
|
40e20f06b0 | ||
|
84f8e7a151 | ||
|
86c570a8c8 | ||
|
fd1a76d3bc | ||
|
266f6b58f4 | ||
|
212ae87e8b | ||
|
6038443225 | ||
|
8ce27053ce | ||
|
e2949094a2 | ||
|
8095aea3d0 | ||
|
2f6dc6f25f | ||
|
d1b764d4ec | ||
|
badf17b0ec | ||
|
f4a203e416 | ||
|
d4c3edca0a | ||
|
c26c776b48 | ||
|
c247f48fbe | ||
|
da8c297973 | ||
|
8be0261295 | ||
|
991411f28d | ||
|
c63c17d9d5 | ||
|
4478f4e405 | ||
|
660693281f | ||
|
a4141288e5 | ||
|
a107c81ad3 | ||
|
ad448a51fa | ||
|
affb89662f | ||
|
2d2d00ccbf | ||
|
da2ad191c9 | ||
|
a52fdbcea5 | ||
|
c16f65c5b8 | ||
|
4afeb8ff38 | ||
|
431266136c | ||
|
e52699b211 | ||
|
9ca81e3094 | ||
|
c10b65ef3b | ||
|
ac9488bad9 | ||
|
3af2cbb678 | ||
|
8c06ec9dcf | ||
|
dc00730168 | ||
|
eb35db1074 | ||
|
890103e4ab | ||
|
eebf1d9680 | ||
|
44f46cfc75 | ||
|
5abb1ab166 | ||
|
92e4db287d | ||
|
a378ec7ab4 | ||
|
2ea263f997 | ||
|
d473d95e42 | ||
|
339fb3ddfb | ||
|
ef500e2d96 | ||
|
04c411c6c1 | ||
|
04d797c6d3 | ||
|
b49b9b99c4 | ||
|
e88f2a70b1 | ||
|
2d0fa7fe59 | ||
|
5b7c52a63f | ||
|
74377c1db7 | ||
|
939797f5be | ||
|
3a57f11f69 | ||
|
bece1b245f | ||
|
2e3d4582f1 | ||
|
0069003cc7 | ||
|
c6d352038c | ||
|
25d26b5586 | ||
|
11a0a76a9d | ||
|
1252ef39d1 | ||
|
bf54039724 | ||
|
b82a3e72ff | ||
|
d5b35a7b13 | ||
|
deae0ae352 | ||
|
8cd0b07c76 | ||
|
db25eadedf | ||
|
bfa4de5a1a | ||
|
cf509cb3c5 | ||
|
5f8cbe3fb1 | ||
|
36496b64ac | ||
|
7ce6cb5dc2 | ||
|
5084722e0b | ||
|
a3fd5e71f3 | ||
|
fd0d3829d8 | ||
|
7fcd277815 | ||
|
050fa88e47 | ||
|
24aaf298f7 | ||
|
024ee7913e | ||
|
f7785c95a3 | ||
|
c584e7b8f5 | ||
|
2483ec1ef6 | ||
|
aba5ac4fa5 | ||
|
4895c12b6d | ||
|
b28a5f6655 | ||
|
b440a232fc | ||
|
a9dff5c39e | ||
|
10f853c921 | ||
|
b9786b1d2f | ||
|
5bf1e24d02 | ||
|
25347f9006 | ||
|
a582600f0f | ||
|
ea07d55b9e | ||
|
613b9cd3bd | ||
|
81cfa22dcf | ||
|
2b7077642d | ||
|
9e7153cf42 | ||
|
06f6491d99 | ||
|
ac2a6036eb | ||
|
744e075697 | ||
|
c0e8290bba | ||
|
be71f31c07 | ||
|
f4d25c0bfa | ||
|
849067127f | ||
|
3d92550c76 | ||
|
cb2e4da2ae | ||
|
42952a24e5 | ||
|
9f685779d5 | ||
|
e271ac2885 | ||
|
0108de389b | ||
|
2820dfb0c7 | ||
|
548d4977f2 | ||
|
79dd53e4c4 | ||
|
15de4c4f5d | ||
|
19442bfe8f | ||
|
8e31ac0ed6 | ||
|
6dd233d51f | ||
|
24c792e4cf | ||
|
9d682455f5 | ||
|
e46135d1ec | ||
|
80ebcb76fd | ||
|
fcb32eaac4 | ||
|
ff8dc8ce6d | ||
|
4467e9fd5b | ||
|
0384a45bf7 | ||
|
57a2a12814 | ||
|
f6f6de508b | ||
|
25b026cf26 | ||
|
91e6ef3612 | ||
|
41c56be7da | ||
|
7376c380e7 | ||
|
8da13c35a7 | ||
|
fc06811907 | ||
|
063fb36567 | ||
|
7a138804a8 | ||
|
b54e5aa22d | ||
|
0fdbc5fe68 | ||
|
37d5fca1af | ||
|
7ac7817101 | ||
|
448309dc37 | ||
|
64bffd534e | ||
|
6b7ff075e4 | ||
|
4cc8e26232 | ||
|
baaa444f42 | ||
|
0da96ea9ff | ||
|
db0c61b369 | ||
|
1756ae84ef | ||
|
65d752484f | ||
|
300a6c51a1 | ||
|
58ef784a1e | ||
|
c873d4888d | ||
|
8bdb11e9e1 | ||
|
0536ce1efa | ||
|
6838e269b2 | ||
|
db661c1229 | ||
|
a07daddccc | ||
|
e393fd6fdb | ||
|
3347b67cea | ||
|
999b6f44ad | ||
|
135a4b421e | ||
|
b7b57da78a | ||
|
417cc7b5f8 | ||
|
33923aee8b | ||
|
febddfcac7 | ||
|
a27f789a37 | ||
|
e57b0107f4 | ||
|
dc2b61b21d | ||
|
148a7a6693 | ||
|
0a9a5a95d0 | ||
|
bcdf86d7ff | ||
|
16e9b2d9bd | ||
|
902cbdec3c | ||
|
ac2f7bbccd | ||
|
33c50671e6 | ||
|
4d50f1eff2 | ||
|
e892b0518a | ||
|
04cf918f7a | ||
|
17840f5c9c | ||
|
a2ea8cd260 | ||
|
323be545ab | ||
|
b41d01b4ad | ||
|
22c9a5e011 | ||
|
b54774994b | ||
|
028f56c289 | ||
|
bde2e5f231 | ||
|
0dac6bd576 | ||
|
ce149998d8 | ||
|
8070875937 | ||
|
65d1c24adf | ||
|
148e4a43db | ||
|
46d5df86c2 | ||
|
36372a511c | ||
|
e523e35c73 | ||
|
f3b1d0c4ef | ||
|
b8e3f13816 | ||
|
4aa2c05989 | ||
|
96dc972637 | ||
|
6fc93344a8 | ||
|
89384492d1 | ||
|
ad2448f2a0 | ||
|
fb61ce21a5 | ||
|
c779721d52 | ||
|
840ed71188 | ||
|
d83a2cab74 | ||
|
6c671b1ba7 | ||
|
1d55c1ebce | ||
|
2f874686b6 | ||
|
3d8700a6d2 | ||
|
baeeee64d9 | ||
|
cdc8cb0d74 | ||
|
cafe173911 | ||
|
d84b94f050 | ||
|
dda7beea10 | ||
|
77e67b637b | ||
|
c2573f9043 | ||
|
c7733ee382 | ||
|
5aeeb77065 | ||
|
e5ac647de4 | ||
|
2d1cfdd567 | ||
|
81520a3aab | ||
|
10c300ff2b | ||
|
76a59dee55 | ||
|
6b7b5494f6 | ||
|
2f9133fcee | ||
|
e9e1e61540 | ||
|
fc81fc38a1 | ||
|
7749b2eb65 | ||
|
e8a18fa72f | ||
|
e831a7cfa5 | ||
|
11c303bcaa | ||
|
e426a306ab | ||
|
7ad9a5c6a0 | ||
|
931d2de4f1 | ||
|
4446825458 | ||
|
5cbb0362c0 | ||
|
6adc93f043 | ||
|
4a198e2f64 | ||
|
164ec47337 | ||
|
d97e4969f9 | ||
|
720740de58 | ||
|
b5bb0af0da | ||
|
1cbb57e519 | ||
|
29bdb0e91e | ||
|
bf920874b1 | ||
|
eab1004215 | ||
|
57b6b1b7ee | ||
|
c290b64285 | ||
|
79a607ba1b | ||
|
c87c4312ad | ||
|
f440ffd405 | ||
|
1d10ed86e6 | ||
|
357fe04058 | ||
|
501c8e66d9 | ||
|
ff342bc932 | ||
|
a101cfe437 | ||
|
b3d7abbc3b | ||
|
4e4da78e0b | ||
|
c412ad0b23 | ||
|
52a5023ef7 | ||
|
552b87c29e | ||
|
e5b8034e0f | ||
|
3f6153a7cf | ||
|
14f3a09c2c | ||
|
84e7b5f06e | ||
|
0e47ce22ce | ||
|
4709a11fad | ||
|
5b067094de | ||
|
439fcf567c | ||
|
97f44141b3 | ||
|
333c8de2ad | ||
|
b1697464d9 | ||
|
4ca95aa1aa | ||
|
d3633fc21d | ||
|
5621bad05c | ||
|
d732440e3e | ||
|
b2188ea036 | ||
|
0a6f1bd82a | ||
|
d0db3b6a53 | ||
|
0d86dc4119 | ||
|
7e968d38bb | ||
|
2c4aad8a23 | ||
|
54f4d4979c | ||
|
e2190444a8 | ||
|
2b31ce12d9 | ||
|
36b41156a5 | ||
|
0f73bca593 | ||
|
d647b35405 | ||
|
047ed35f83 | ||
|
72afc1ca0a | ||
|
ba0d99b60d | ||
|
f8cfc04ab2 | ||
|
2d8a1da470 | ||
|
0cf845f099 | ||
|
f0398fe8fc | ||
|
42b8b1f6ba | ||
|
1a144c6459 | ||
|
f7fbbc7bd0 | ||
|
1b2f01af94 | ||
|
27c150f877 | ||
|
bdbd5ee8e4 | ||
|
1b67b04630 | ||
|
0c8d0c8143 | ||
|
a45c578037 | ||
|
d91c014b53 | ||
|
81b352c306 | ||
|
f309348e25 | ||
|
977de65914 | ||
|
d7939a59cc | ||
|
cd92f0c4de | ||
|
c4828f7ef4 | ||
|
9705f308fd | ||
|
a68108df07 | ||
|
8a5089c0f6 | ||
|
881f828f34 | ||
|
5289efc72c | ||
|
9ed4c582e2 | ||
|
a7ccb5ff14 | ||
|
80cd9ab9d6 | ||
|
d0aab89435 | ||
|
6d8224bdf1 | ||
|
fb3ddf2da8 | ||
|
80d9af6279 | ||
|
0a914c820a | ||
|
038af50eaa | ||
|
9733fa6185 | ||
|
6895ad66f6 | ||
|
6b52141245 | ||
|
0eb29caf44 | ||
|
e1732ff26a | ||
|
f8bc0be366 | ||
|
d184a251e4 | ||
|
84ddfb90a6 | ||
|
83e5a35677 | ||
|
5560f96744 | ||
|
2660995aee | ||
|
e3a6f53537 | ||
|
2570eb99a6 | ||
|
0ebdb2dbde | ||
|
b660d9ce21 | ||
|
ac603c3b9c | ||
|
9a7827448d | ||
|
a2a025ad55 | ||
|
77d9997009 | ||
|
402c8e80f4 | ||
|
5551e8545f | ||
|
a496526049 | ||
|
03bab4e7db | ||
|
63ded5b197 | ||
|
57742d13f2 | ||
|
1d9765c95b | ||
|
64e7294233 | ||
|
15e3971f11 | ||
|
64cdd374bc | ||
|
8d9ef6365e | ||
|
bea3283b05 | ||
|
8c5e871640 | ||
|
7cb53a8b5a | ||
|
24d14e7005 | ||
|
e83b4af33f | ||
|
8dfe1a37c4 | ||
|
ef250fbc05 | ||
|
e096daa605 | ||
|
c519727b6c | ||
|
78057dca3c | ||
|
b18a61ebd1 | ||
|
34acae025b | ||
|
1037070bff | ||
|
8ba4db33a7 | ||
|
905ced9485 | ||
|
0a4240f3db | ||
|
be07c36294 | ||
|
b950426d7b | ||
|
1a590bd678 | ||
|
b1a6a85ff7 | ||
|
87bc11061d | ||
|
c691ce38ed | ||
|
ad08b24c3e | ||
|
964467464c | ||
|
311f8034f4 | ||
|
dd8e1fccd7 | ||
|
30ffd22599 | ||
|
48ba900ea1 | ||
|
45f1b3c311 | ||
|
70040a0ed3 | ||
|
7b3489225c | ||
|
ba393020b2 | ||
|
776bd6d7d6 | ||
|
aab0e8b6db | ||
|
80ff91b609 | ||
|
ad35f9cc82 | ||
|
c0e8a588ec | ||
|
60f9c5ef29 | ||
|
18f7f64b47 | ||
|
427bb7c4b8 | ||
|
1aec6dcd34 | ||
|
7ca178fced | ||
|
01b2d22059 | ||
|
f621fbc38e | ||
|
9fe8b3ab43 | ||
|
4aed770b7e | ||
|
9530bead9c | ||
|
5ecd3054b3 | ||
|
1af4788de0 | ||
|
0697f0b5a0 | ||
|
610a8cfabf | ||
|
3250e25aa0 | ||
|
ad0133b948 | ||
|
3a2374ad59 | ||
|
09e91bf817 | ||
|
daa5c9ccc2 | ||
|
abab37b71e | ||
|
71bda91639 | ||
|
c50975672e | ||
|
fbdec17670 | ||
|
ecec80ac58 | ||
|
f1442edf34 | ||
|
51426264d6 | ||
|
58b9e430ad | ||
|
628b7bc378 | ||
|
6990a10d9c | ||
|
131233e7d0 | ||
|
80e9f245ab | ||
|
4f8ce61909 | ||
|
569265f1c7 | ||
|
4acf17f636 | ||
|
2864c0fa7f | ||
|
6218def4df | ||
|
b5a8929931 | ||
|
639467fe27 | ||
|
73ce7c6bfd | ||
|
bc00fabb81 | ||
|
64f5f61a0a | ||
|
61471e80dc | ||
|
fc4ba61e86 | ||
|
358e8b95bb | ||
|
f38af0836c | ||
|
6b2f2f8484 | ||
|
14bb252a73 | ||
|
ef1e514c54 | ||
|
f48e4c3942 | ||
|
5644675b74 | ||
|
c97d947087 | ||
|
0069bdf5a4 | ||
|
f2527a6363 | ||
|
93022fa4f2 | ||
|
8c93a75e04 | ||
|
4f3b648bdd | ||
|
8d407c39b8 | ||
|
eb84abb470 | ||
|
c8d46d73a3 | ||
|
ee58d0fdb3 | ||
|
b9894b5597 | ||
|
b72562b0bf | ||
|
721ed55598 | ||
|
03f2ac16b5 | ||
|
3ea9fb8c68 | ||
|
408707157a | ||
|
9ec94c889a | ||
|
c6fdd3bdbc | ||
|
fb14f24927 | ||
|
7f8209544e | ||
|
f21745305e | ||
|
df87621241 | ||
|
b369ce3a0c | ||
|
d1b72fe443 | ||
|
ade1dcd5e8 | ||
|
ed433977c7 | ||
|
8f8636c509 | ||
|
b43be1f900 | ||
|
3beee89f00 | ||
|
7537d85084 | ||
|
566c91a2b6 | ||
|
2c1acab761 | ||
|
a38f8df657 | ||
|
e4997cd915 | ||
|
0913f382d7 | ||
|
21eab082bf | ||
|
748b42cff0 | ||
|
2bb307a462 | ||
|
33c48f854c | ||
|
1751c197b6 | ||
|
27f26da0e5 | ||
|
39d0bd7058 | ||
|
8302c83001 | ||
|
eaf5e97266 | ||
|
68e13e7bcd | ||
|
faaee59116 | ||
|
349f283af6 | ||
|
4b8363c9d1 | ||
|
8934ebed1d | ||
|
62efc4b2b9 | ||
|
36aab19204 | ||
|
502d9c5ae8 | ||
|
b86efbc3c2 | ||
|
2204c910b9 | ||
|
a4a6689d38 | ||
|
b9926a154c | ||
|
023dafc4cb | ||
|
2fac33c2e7 | ||
|
02d18245c3 | ||
|
130113db50 | ||
|
036cdb0740 | ||
|
5941d3f1bd | ||
|
a4009d7ff3 | ||
|
a554b8d1cf | ||
|
1a5f809bdc | ||
|
2677834aad | ||
|
c73deb5974 | ||
|
6204df19c0 | ||
|
6d28aa272b | ||
|
8e734d895f | ||
|
2ae2b427b0 | ||
|
6817c4568b | ||
|
b74ba66a87 | ||
|
e0c2ec36f8 | ||
|
b008f28406 | ||
|
5c34719ad1 | ||
|
563a9adaf9 | ||
|
18780b59b0 | ||
|
76b6371498 | ||
|
4b4f0a1608 | ||
|
7a51fdf524 | ||
|
75b4b4e2c2 | ||
|
5a676220dc | ||
|
0e46741d9a | ||
|
aaa924d9d8 | ||
|
fe0cbf048b | ||
|
148535e7de | ||
|
72ac41d632 | ||
|
ca5357ea49 | ||
|
4dd774f290 | ||
|
c3ffe8d729 | ||
|
47d1f3ea31 | ||
|
633e233d9d | ||
|
c1f3905672 | ||
|
63e1344851 | ||
|
3cd6c91eda | ||
|
0422c3702d | ||
|
44a3b4e7c6 | ||
|
c48832a2bc | ||
|
4089fee13c | ||
|
b0d41fb490 | ||
|
f04da64b21 | ||
|
9c17803e03 | ||
|
2cb8c4fc10 | ||
|
5e1dcd4d30 | ||
|
eb348848e6 | ||
|
e66df67913 | ||
|
05ebfd1dfd | ||
|
61c4afd8aa | ||
|
1ef1a6cf34 | ||
|
068286744f | ||
|
3d3203b823 | ||
|
696aef6a6f | ||
|
2ce0e67d4b | ||
|
fc415aa6c6 | ||
|
39f36e146e | ||
|
f45084e01a | ||
|
734f53d9fa | ||
|
d093fafbe9 | ||
|
0e72143945 | ||
|
0ebae76732 | ||
|
5541981d4e | ||
|
9d7093e6f2 | ||
|
ea0aab80e2 | ||
|
ba8a603e26 | ||
|
13a2c465ae | ||
|
1920b4fd03 | ||
|
93c53b93e2 | ||
|
41fe000bf4 | ||
|
7c1b1066f9 | ||
|
055e865628 | ||
|
e8c0d54b02 | ||
|
c1ac7f035d | ||
|
1d2a5f891e | ||
|
912df73b56 | ||
|
7a4dc61412 | ||
|
dc0785fe2e | ||
|
70a2a77cc0 | ||
|
0fa228a749 | ||
|
d910b116c6 | ||
|
07206a0ac3 | ||
|
0fac0ac948 | ||
|
956b947a4c | ||
|
a28ec17a6d | ||
|
96926ab5fa | ||
|
6d81b21b43 | ||
|
cf0c6f19c4 | ||
|
a1826e5c95 | ||
|
8e791ed581 | ||
|
614520443f | ||
|
1c1ba2ef02 | ||
|
93b751af29 | ||
|
fbf1bc1ae2 | ||
|
9d48917d09 | ||
|
7f2d813c8c | ||
|
1e995d7bba | ||
|
80b76c9325 | ||
|
b01fce2cc8 | ||
|
4537651367 | ||
|
9369fd8d05 | ||
|
a3f1341daf | ||
|
5c0a9d9300 | ||
|
d044232cd0 | ||
|
fdfb94371e | ||
|
de1d8d67d8 | ||
|
1c0b3d5780 | ||
|
2bd9b081f5 | ||
|
903427e1ef | ||
|
35c59d4c72 | ||
|
0088d88af6 | ||
|
0649a2c0c9 | ||
|
632f6e4218 | ||
|
ead2d21a35 | ||
|
d714b2c0be | ||
|
fd400cf3ea | ||
|
aed155d5a2 | ||
|
b3a558d81c | ||
|
f6b8ff9030 | ||
|
f217289e9d | ||
|
c56c7d2664 | ||
|
c372efc3eb | ||
|
9746641f48 | ||
|
e45aa0bcde | ||
|
a721d82e76 | ||
|
5a3b936aff | ||
|
2f3c6f9206 | ||
|
708e3e0b96 | ||
|
a2cb958b73 | ||
|
e40a10dbdc | ||
|
d568562cad | ||
|
f492ead7d6 | ||
|
c611487f42 | ||
|
d0ac927b92 | ||
|
54a0a96cbc | ||
|
44316a5de1 | ||
|
0db0abeb6a | ||
|
906291234b | ||
|
74af9642e1 | ||
|
a828536e97 | ||
|
10a46a3bde | ||
|
bb37adc63d | ||
|
1f3dd159b3 | ||
|
2cd538e1eb | ||
|
ffd60654b1 | ||
|
fc17201f35 | ||
|
d7d8c34167 | ||
|
96db56a25c | ||
|
785df48d7c | ||
|
05f2fdb8a3 | ||
|
3df467e35e | ||
|
439d25f9b0 | ||
|
3dfa3be2e1 | ||
|
e9605b60d3 | ||
|
9b036039c5 | ||
|
110f23ca2f | ||
|
56616d6bdf | ||
|
7c621aeae2 | ||
|
2f747d618c | ||
|
7046539f29 | ||
|
f87f6a37d4 | ||
|
e43ead6832 | ||
|
bf0c277ad6 | ||
|
b6d7a92b32 | ||
|
f8e4c52616 | ||
|
6e1238206d | ||
|
9e98f2799d | ||
|
93915c7c5f | ||
|
bf996f2fd1 | ||
|
ef4ceac61e | ||
|
3ff165f323 | ||
|
a3f9e238bf | ||
|
fbc0aa59c2 | ||
|
d271b6672f | ||
|
df7d4149c6 | ||
|
46de1a5fac | ||
|
64fdca5097 | ||
|
4f36d2608f | ||
|
6ded78bb5e | ||
|
e4b46452e5 | ||
|
3089d2bd1b | ||
|
c97347a228 | ||
|
1f0c11e8c3 | ||
|
8db41809fd | ||
|
e80b695dfa | ||
|
c46f5c4f9b | ||
|
7ec7537b7d | ||
|
17bd41d3ef | ||
|
6b9c7d6cf0 | ||
|
a238994e0f | ||
|
4940eec5ce | ||
|
b1c41008ce | ||
|
306b28bf93 | ||
|
b4531e2c8f | ||
|
9848785d38 | ||
|
24ccdeac8f | ||
|
f9ca9a76d9 | ||
|
503326be04 | ||
|
0cd9e6e343 | ||
|
3b304bf769 | ||
|
dbccd67b20 | ||
|
d7640f1c20 | ||
|
1675700073 | ||
|
6b128ec798 | ||
|
8e4ac8d503 | ||
|
16b9e0e415 | ||
|
9e67c94074 | ||
|
c09e9de9f9 | ||
|
a90083b287 | ||
|
0ea80369cf | ||
|
26821a3ac5 | ||
|
7bc6fc988f | ||
|
017822d422 | ||
|
de3eb90ab5 | ||
|
3ce44418e7 | ||
|
8b8400f437 | ||
|
20e76c3076 | ||
|
6d1d5d0afe | ||
|
26bce2e8a0 | ||
|
2f2c702c8f | ||
|
c5a3d75d29 | ||
|
4b36fc33b1 | ||
|
8aa9842091 | ||
|
d718b81d79 | ||
|
83a37a88f9 | ||
|
0ced8cf27c | ||
|
e6b764bd25 | ||
|
78860ce01a | ||
|
5cdd2d927c | ||
|
4a3dbd8f3f | ||
|
ee4ee92340 | ||
|
d3d25164c3 | ||
|
5de0e8ad7d | ||
|
397b732341 | ||
|
dd7abf2fff | ||
|
fdd3187c82 | ||
|
884158c27e | ||
|
223a000c91 | ||
|
1c31d46d58 | ||
|
51a7cbaffa | ||
|
459b6917b5 | ||
|
96369ab604 | ||
|
69f061c671 | ||
|
cb38352519 | ||
|
ab9cfb1469 | ||
|
760780537a | ||
|
ec5ef85023 | ||
|
ecd30eb896 | ||
|
5cf79312f4 | ||
|
31f32ca8da | ||
|
36aae7cad1 | ||
|
f664ba5e5f | ||
|
103407634d | ||
|
9a4111c393 | ||
|
dfde53b8ac | ||
|
abee98b68d | ||
|
14b1727122 | ||
|
a6ff79e5cd | ||
|
55ff01a618 | ||
|
a10a6bf9e6 | ||
|
2ab019008f | ||
|
5358d1be96 | ||
|
2263f884f0 | ||
|
e56eaa7a9f | ||
|
08b46b9a8b | ||
|
de54ec5c61 | ||
|
c397ba40f4 | ||
|
83ffee2874 | ||
|
570239cccf | ||
|
3e8ba74459 | ||
|
ec72489300 | ||
|
16607a68d2 | ||
|
5b571a0cb8 | ||
|
51e5f620bf | ||
|
779ace09bf | ||
|
1d73115c33 | ||
|
904b7d22d5 | ||
|
13ff92899c | ||
|
405b3d47e4 | ||
|
a40abd4bbd | ||
|
4f4cdea951 | ||
|
7eec11197a | ||
|
165c9491a9 | ||
|
1ff9718039 | ||
|
91d6f64520 | ||
|
a5eda46339 | ||
|
cc52b81eb2 | ||
|
7bbea38454 | ||
|
f3e18f63bb | ||
|
6d4291c564 | ||
|
66ead26635 | ||
|
18d67e0f26 | ||
|
dee39dd14a | ||
|
fc345f4ebc | ||
|
46231c9e56 | ||
|
73ca19ca73 | ||
|
0bcf220d91 | ||
|
e5818e2f04 | ||
|
ddc4b099ee | ||
|
493f29ff57 | ||
|
15d5c1ce16 | ||
|
e34b46d4e4 | ||
|
509911aae0 | ||
|
a9fdd82911 | ||
|
4d130df390 | ||
|
284a316cd5 | ||
|
fc4537bcea | ||
|
0efa8d0217 | ||
|
2c988b0f77 | ||
|
71b7b3c570 | ||
|
f2755468e0 | ||
|
506ca60682 | ||
|
d71906838d | ||
|
e1c8966d9f | ||
|
1d5f635f24 | ||
|
74ec643208 | ||
|
a7b2ba96e7 | ||
|
0f53693c28 | ||
|
5b82ab8690 | ||
|
68902d74bd | ||
|
c86dc4035b | ||
|
fea9932631 | ||
|
9a5a75c1c2 | ||
|
0739997a59 | ||
|
fe6141ea81 | ||
|
5233481992 | ||
|
239e94fe05 | ||
|
74558aea20 | ||
|
e04ffa5f25 | ||
|
c513e8cd33 | ||
|
e5c51682fb | ||
|
45eb778560 | ||
|
930ca1fbc0 | ||
|
403fd035a7 | ||
|
656861f6df | ||
|
0d927881b4 | ||
|
da025dafbb | ||
|
fa1634d040 | ||
|
de8285e199 | ||
|
152db6995f | ||
|
6fb7c8e91f | ||
|
52d38aa1e7 | ||
|
9d6b2cc3e1 | ||
|
06053b9e17 | ||
|
897b27f31e | ||
|
98782fed57 | ||
|
e086afc4d8 | ||
|
f6c1f22b4f | ||
|
745a763b7f | ||
|
7517540cc5 | ||
|
0a212bab1d | ||
|
2ed6488d77 | ||
|
e757ee34df | ||
|
a3d18884aa | ||
|
154a0b30fe | ||
|
e06c1647c4 | ||
|
3136db5cb4 | ||
|
b7ccc8c0e6 | ||
|
4dd6fab12f | ||
|
bc23d64686 | ||
|
c0865b1bea | ||
|
eb0a61c25b | ||
|
99eb1462ad | ||
|
e9c6729894 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,5 +1,4 @@
|
|||||||
# Ignore the user config files
|
# Ignore the user config files
|
||||||
config.json
|
|
||||||
db.json
|
db.json
|
||||||
|
|
||||||
# ignore npm
|
# ignore npm
|
||||||
|
8
.gitmodules
vendored
8
.gitmodules
vendored
@ -1,6 +1,6 @@
|
|||||||
[submodule "jsbot"]
|
[submodule "jsbot"]
|
||||||
path = jsbot
|
path = jsbot
|
||||||
url = git://github.com/reality/jsbot.git
|
url = git://github.com/reality/jsbot.git
|
||||||
[submodule "modules/github"]
|
[submodule "modules/github"]
|
||||||
path = modules/github
|
path = modules/github
|
||||||
url = git://github.com/zuzak/dbot-github.git
|
url = git://github.com/zuzak/dbot-github.git
|
||||||
|
46
README.md
46
README.md
@ -1,3 +1,47 @@
|
|||||||
|
### dbot - revived
|
||||||
|
|
||||||
|
The motivation for this fork came from trying to make the trusty bot of our IRC network work with new infrastructure, until all features made their way into its successor.
|
||||||
|
|
||||||
|
Note that this project is not production worthy - it contains a lot of hardcoded debug lines and untidy code. Whether it will see prettification anytime soon, I cannot tell.
|
||||||
|
|
||||||
|
So far, the following issues were tackled successfully:
|
||||||
|
|
||||||
|
- NickServ identification
|
||||||
|
- NickServ user retrieval
|
||||||
|
- Quote shortcuts (~foo)
|
||||||
|
- Channel statistics (cstats)
|
||||||
|
|
||||||
|
This makes the bot usable on an IRC network powered by the Ergo IRCd, which is dbot was not happy communicate with at all when I first tried to run it.
|
||||||
|
|
||||||
|
The following issues are known, but are assigned low priority:
|
||||||
|
|
||||||
|
- No PASS/SASL authentication - it is hackable with a PASS line right after the USER command, however that prevents some parts of the bot from initializing. To use NickServ authentication, allowing the bot to start properly, the strict username checking feature in Ergo needs to be disabled
|
||||||
|
- Lots of ENOENT errors on startup
|
||||||
|
- Channel mode detection and assignment
|
||||||
|
- Some sites in the webinterface don't load / show errors
|
||||||
|
|
||||||
|
The following issues are known, and await investigation:
|
||||||
|
|
||||||
|
- Upon issuing some administrative commands, apparently a sort of "queue flush" gets trigered, causing dozens of unban events to make the bot unresponsive for a while
|
||||||
|
|
||||||
|
The following issues are resolved, but are not available in this repository, due to files not being accessible:
|
||||||
|
|
||||||
|
- WHO parsing for user management commands
|
||||||
|
- nban/nunban, with newly added ipban
|
||||||
|
|
||||||
|
The directory modules-stock/ is the stock modules directory, kept for safekeeping.
|
||||||
|
The directory modules/ contains changed modules.
|
||||||
|
|
||||||
|
The jsbot/ directory is not populated in the stock repository, however its contents are included here, as a few essential changes have been implemented there as well.
|
||||||
|
|
||||||
|
Tested with node v10.
|
||||||
|
|
||||||
|
Note: TripSit IRC related modules are to be found in a seperate repository.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Original README.md
|
||||||
|
|
||||||
# DBot IRC Bot
|
# DBot IRC Bot
|
||||||
|
|
||||||
## Introduction
|
## Introduction
|
||||||
@ -26,7 +70,7 @@ Once you have that set up, you can install DBot's dependencies, configure and
|
|||||||
run the bot for the first time with the following command:
|
run the bot for the first time with the following command:
|
||||||
|
|
||||||
```
|
```
|
||||||
sh install.sh
|
./install
|
||||||
```
|
```
|
||||||
|
|
||||||
## Upgrading
|
## Upgrading
|
||||||
|
@ -15,10 +15,13 @@
|
|||||||
"admins": [ "batman" ],
|
"admins": [ "batman" ],
|
||||||
"moderators": [ "whatever" ],
|
"moderators": [ "whatever" ],
|
||||||
"power_users": [],
|
"power_users": [],
|
||||||
"moduleNames": [ "ignore", "admin", "command", "dice", "js", "kick", "quotes", "spelling", "youare", "timers", "stats", "users", "link" ],
|
"moduleNames": [ "ignore", "admin", "command", "dice", "js", "kick", "quotes", "spelling", "users", "youare", "timers", "sstats", "link" ],
|
||||||
"language": "en",
|
"language": "en",
|
||||||
"debugMode": false,
|
"debugMode": false,
|
||||||
"debugLevel": 1,
|
"debugLevel": 1,
|
||||||
|
"dbType": "redis",
|
||||||
|
"redisPort": 6379,
|
||||||
|
"timezone": "Europe/London",
|
||||||
"repoRoot": "https://github.com/reality/depressionbot/",
|
"repoRoot": "https://github.com/reality/depressionbot/",
|
||||||
"version": "Depressionbot IRC bot 0.5-dev - Lovingly crafted by The DepressionBot Foundation (a charity arm of the Official Aberystwyth Open Source International Development League)."
|
"version": "Depressionbot IRC bot 0.5-dev - Lovingly crafted by The DepressionBot Foundation (a charity arm of the Official Aberystwyth Open Source International Development League)."
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ var databank = require('databank'),
|
|||||||
*/
|
*/
|
||||||
var DatabaseDriver = function(config) {
|
var DatabaseDriver = function(config) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.databanks = {};
|
this.databank = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -20,12 +20,12 @@ DatabaseDriver.prototype.createDB = function(name, driver, schema, callback) {
|
|||||||
if(driver == 'redis' && _.has(this.config, 'redisPort')) params.port = this.config.redisPort;
|
if(driver == 'redis' && _.has(this.config, 'redisPort')) params.port = this.config.redisPort;
|
||||||
if(driver == 'disk') params.dir = 'db';
|
if(driver == 'disk') params.dir = 'db';
|
||||||
|
|
||||||
this.databanks[name] = Databank.get(driver, params);
|
this.databank = Databank.get(driver, params);
|
||||||
this.databanks[name].connect({}, function(err) {
|
this.databank.connect({}, function(err) {
|
||||||
if(err) {
|
if(err) {
|
||||||
console.log('Didn\'t manage to connect to the data source - ' + err);
|
console.log('Didn\'t manage to connect to the data source - ' + err);
|
||||||
} else {
|
} else {
|
||||||
callback(this.databanks[name]);
|
callback(this.databank);
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
};
|
};
|
||||||
|
48
install
Executable file
48
install
Executable file
@ -0,0 +1,48 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
cat LICENCE
|
||||||
|
git submodule init
|
||||||
|
git submodule update
|
||||||
|
|
||||||
|
command -v node > /dev/null
|
||||||
|
if [[ $? -gt 0 ]]; then
|
||||||
|
echo 'node.js is not installed. Please install it before running install.sh.'
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
command -v npm > /dev/null
|
||||||
|
if [[ $? -gt 0 ]]; then
|
||||||
|
echo 'npm is not installed. Please install it before running install.sh'
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
npm install googlemaps humanize feedparser node-units tvdb method-override 500px process async wordnik node-uuid underscore request request-promise-native sandbox express moment-timezone moment jade databank databank-redis ent passport passport-local password-hash connect-flash
|
||||||
|
|
||||||
|
cd public/
|
||||||
|
wget https://github.com/twbs/bootstrap/releases/download/v3.3.2/bootstrap-3.3.2-dist.zip
|
||||||
|
unzip bootstrap-3.3.2-dist.zip
|
||||||
|
mv bootstrap-3.3.2-dist bootstrap
|
||||||
|
rm bootstrap-3.3.2-dist.zip
|
||||||
|
|
||||||
|
mkdir d3
|
||||||
|
cd d3
|
||||||
|
wget https://github.com/mbostock/d3/releases/download/v3.5.5/d3.zip
|
||||||
|
unzip d3.zip
|
||||||
|
rm d3.zip
|
||||||
|
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
if [ ! -f config.json ];
|
||||||
|
then
|
||||||
|
echo 'Creating configuration file...'
|
||||||
|
cp config.json.sample config.json
|
||||||
|
$EDITOR config.json # Open config file with EDITOR variable, but if not available:
|
||||||
|
if [[ $? != 0 ]]; then vim config.json; fi # Find the return code from previous command, if failed then use vim to edit.
|
||||||
|
fi
|
||||||
|
|
||||||
|
read -p "Setup complete. Run dbot now? [y/N]"
|
||||||
|
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
||||||
|
then
|
||||||
|
echo 'Okay. To run the bot, use "node run.js"'
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
node run.js
|
||||||
|
|
46
install.sh
46
install.sh
@ -1,46 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
cat LICENCE
|
|
||||||
git submodule init
|
|
||||||
git submodule update
|
|
||||||
|
|
||||||
if [ ! -e /usr/bin/node ] && [ ! -e /usr/local/bin/node ];
|
|
||||||
then
|
|
||||||
echo 'node.js is not installed. Please install it before running install.sh.'
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ ! -e /usr/bin/npm ] && [ ! -e /usr/local/bin/npm ];
|
|
||||||
then
|
|
||||||
echo 'npm is not installed. Please install it before running install.sh'
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
npm install async wordnik node-uuid underscore request sandbox express moment jade databank databank-redis ent
|
|
||||||
|
|
||||||
cd public/
|
|
||||||
wget http://twitter.github.com/bootstrap/assets/bootstrap.zip
|
|
||||||
unzip bootstrap.zip
|
|
||||||
rm bootstrap.zip
|
|
||||||
|
|
||||||
mkdir d3
|
|
||||||
cd d3
|
|
||||||
wget http://d3js.org/d3.v3.zip
|
|
||||||
unzip d3.v3.zip
|
|
||||||
rm d3.v3.zip
|
|
||||||
|
|
||||||
cd ../..
|
|
||||||
|
|
||||||
if [ ! -f config.json ];
|
|
||||||
then
|
|
||||||
echo 'Creating configuration file...'
|
|
||||||
cp config.json.sample config.json
|
|
||||||
vim config.json
|
|
||||||
fi
|
|
||||||
|
|
||||||
read -p "Setup complete. Run depressionbot now? [y/N]"
|
|
||||||
if [[ ! $REPLY =~ ^[Yy]$ ]]
|
|
||||||
then
|
|
||||||
echo 'Okay. To run the bot, use "node run.js"'
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
node run.js
|
|
||||||
|
|
1
jsbot
1
jsbot
@ -1 +0,0 @@
|
|||||||
Subproject commit 87b8dbbb9083d2ded4b2214a450a58ef09d4e4f9
|
|
40
jsbot/README.md
Normal file
40
jsbot/README.md
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
## JSBot
|
||||||
|
|
||||||
|
JSBot is an IRC bot library written in Node JS.
|
||||||
|
|
||||||
|
With features like multiple server support and being 'pretty good, I guess,'
|
||||||
|
JSBot is designed to be the IRC bot library of the future! For an example of a
|
||||||
|
large project which uses JSBot, take a look at
|
||||||
|
[DepressionBot](http://github.com/reality/depressionbot/ "DepressionBot").
|
||||||
|
|
||||||
|
To get started with JSBot, take a look at the 'run.js' example provided with the
|
||||||
|
code, then head on over to the
|
||||||
|
[online documentation](https://github.com/reality/jsbot/wiki/Documentation "JSBot Docs").
|
||||||
|
|
||||||
|
## ChangeLog
|
||||||
|
|
||||||
|
### 0.3 I guess
|
||||||
|
|
||||||
|
* Fixed an edge case with the IRC line tokenisation /potentially/ causing events to be parsed twice
|
||||||
|
* Isolated all core channel/nick list logic in JOIN/PART/KICK/QUIT/NICK handlers
|
||||||
|
* Removed useless timeout in 004 handler, switched it to handle 001 instead
|
||||||
|
* Removed a duplicate send() call for IDENTIFY
|
||||||
|
* Semantically reorganised source code
|
||||||
|
* Various other improvements
|
||||||
|
|
||||||
|
speeddefrost <3
|
||||||
|
|
||||||
|
### 0.2
|
||||||
|
|
||||||
|
* Multiple server support.
|
||||||
|
* Functionality for certain users to ignore listeners with certain tags.
|
||||||
|
* Better 'event' object passed to listeners.
|
||||||
|
* Ability to 'reply' to events.
|
||||||
|
|
||||||
|
### 0.1
|
||||||
|
|
||||||
|
* It connects to a server
|
||||||
|
* Listeners
|
||||||
|
* Ping/Pong
|
||||||
|
* Some of the other functionality you'd expect, like, what do you want from me?
|
||||||
|
|
572
jsbot/jsbot.js
Normal file
572
jsbot/jsbot.js
Normal file
@ -0,0 +1,572 @@
|
|||||||
|
var _ = require('underscore')._,
|
||||||
|
net = require('net'),
|
||||||
|
async = require('async'),
|
||||||
|
tls = require('tls'),
|
||||||
|
Tokenizer = require('./tokenizer');
|
||||||
|
|
||||||
|
var JSBot = function(nick) {
|
||||||
|
this.nick = nick;
|
||||||
|
this.connections = {};
|
||||||
|
this.ignores = {};
|
||||||
|
this.preEmitHooks = [];
|
||||||
|
this.events = {
|
||||||
|
'JOIN': [],
|
||||||
|
'PART': [],
|
||||||
|
'QUIT': [],
|
||||||
|
'NICK': [],
|
||||||
|
'PRIVMSG': [],
|
||||||
|
'MODE': [],
|
||||||
|
'KICK': []
|
||||||
|
};
|
||||||
|
this.addDefaultListeners();
|
||||||
|
};
|
||||||
|
|
||||||
|
// connections
|
||||||
|
|
||||||
|
var Connection = function(name, instance, host, port, owner, onReady, nickserv, password, tlsOptions) {
|
||||||
|
this.name = name;
|
||||||
|
this.instance = instance;
|
||||||
|
this.host = host;
|
||||||
|
this.port = port;
|
||||||
|
this.owner = owner;
|
||||||
|
this.onReady = onReady;
|
||||||
|
this.nickserv = nickserv;
|
||||||
|
this.password = password;
|
||||||
|
this.tlsOptions = tlsOptions;
|
||||||
|
|
||||||
|
this.channels = {};
|
||||||
|
this.commands = {};
|
||||||
|
this.encoding = 'utf8';
|
||||||
|
this.netBuffer = '';
|
||||||
|
this.conn = null;
|
||||||
|
this.lastSent = Date.now();
|
||||||
|
};
|
||||||
|
|
||||||
|
Connection.prototype.connect = function() {
|
||||||
|
|
||||||
|
if((typeof this.port == 'string' || this.port instanceof String) && this.port.substring(0, 1) == '+') {
|
||||||
|
this.conn = tls.connect(parseInt(this.port.substring(1)), this.host, this.tlsOptions);
|
||||||
|
} else {
|
||||||
|
this.conn = net.createConnection(this.port, this.host);
|
||||||
|
}
|
||||||
|
console.log('trying to connect' + this.port + ' ' + this.host);
|
||||||
|
|
||||||
|
this.conn.setTimeout(60 * 60 * 1000);
|
||||||
|
this.conn.setEncoding(this.encoding);
|
||||||
|
this.conn.setKeepAlive(enable=true, 10000);
|
||||||
|
|
||||||
|
connectListener = function() {
|
||||||
|
this.send('NICK', this.instance.nick);
|
||||||
|
//this.send('USER', this.instance.nick, '0', '*', this.instance.nick);
|
||||||
|
this.send('PASS ' + this.instance.nick + ':' + this.password);
|
||||||
|
this.send('USER', this.instance.nick + ' ' + this.instance.nick + ' ' + this.instance.nick, ' ', this.instance.nick);
|
||||||
|
}.bind(this);
|
||||||
|
|
||||||
|
this.conn.addListener('connect', connectListener.bind(this));
|
||||||
|
this.conn.addListener('secureConnect', connectListener.bind(this));
|
||||||
|
this.conn.addListener('error', function(err) {
|
||||||
|
console.log('hi')
|
||||||
|
console.log(err);
|
||||||
|
console.error(err);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.conn.addListener('data', function(chunk) {
|
||||||
|
this.netBuffer += chunk;
|
||||||
|
console.log(chunk)
|
||||||
|
|
||||||
|
var t = new Tokenizer(this.netBuffer);
|
||||||
|
while(true) {
|
||||||
|
var line = t.tokenize('\r\n');
|
||||||
|
if(line == null) {
|
||||||
|
this.netBuffer = t.tokenize(null);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.instance.parse(this, line);
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
};
|
||||||
|
|
||||||
|
Connection.prototype.send = function() {
|
||||||
|
var message = [].splice.call(arguments, 0).join(' ');
|
||||||
|
//if(Date.now() > this.lastSent + 500) {
|
||||||
|
message += '\r\n';
|
||||||
|
this.conn.write(message, this.encoding);
|
||||||
|
this.lastSent = Date.now();
|
||||||
|
//} else {
|
||||||
|
/* setImmediate(function() {
|
||||||
|
this.send(message);
|
||||||
|
}.bind(this));
|
||||||
|
}*/
|
||||||
|
};
|
||||||
|
|
||||||
|
Connection.prototype.pong = function(message) {
|
||||||
|
this.send('PONG', ':' ); //+ message.split(':')[1]);
|
||||||
|
};
|
||||||
|
|
||||||
|
Connection.prototype.join = function(channel) {
|
||||||
|
this.send('JOIN', channel);
|
||||||
|
};
|
||||||
|
|
||||||
|
Connection.prototype.part = function(channel) {
|
||||||
|
this.send('PART', channel);
|
||||||
|
};
|
||||||
|
|
||||||
|
JSBot.prototype.addConnection = function(name, host, port, owner, onReady, nickserv, password, tlsOptions) {
|
||||||
|
tlsOptions = tlsOptions || {};
|
||||||
|
tlsOptions = _.defaults(tlsOptions, {rejectUnauthorized: false});
|
||||||
|
this.connections[name] = new Connection(name, this, host, port, owner, onReady,
|
||||||
|
nickserv, password, tlsOptions);
|
||||||
|
};
|
||||||
|
|
||||||
|
JSBot.prototype.connect = function(name) {
|
||||||
|
var conn = this.connections[name];
|
||||||
|
this.addListener('001', 'onReady', function(event) {
|
||||||
|
conn.instance.say(conn.name, conn.nickserv, 'IDENTIFY ' + this.nick + " " + conn.password);
|
||||||
|
setTimeout(function() {
|
||||||
|
if(conn.onReady != null)
|
||||||
|
conn.onReady(event);
|
||||||
|
}, 5000);
|
||||||
|
});
|
||||||
|
|
||||||
|
conn.connect();
|
||||||
|
};
|
||||||
|
|
||||||
|
JSBot.prototype.connectAll = function() {
|
||||||
|
_.each(this.connections, function(connection, name) {
|
||||||
|
this.connect(name);
|
||||||
|
}, this);
|
||||||
|
};
|
||||||
|
|
||||||
|
// event parsing and processing
|
||||||
|
|
||||||
|
JSBot.prototype.parse = function(connection, input) {
|
||||||
|
var event = new Event(this),
|
||||||
|
t = new Tokenizer(input);
|
||||||
|
|
||||||
|
event.server = connection.name;
|
||||||
|
event.allChannels = this.connections[event.server].channels;
|
||||||
|
|
||||||
|
if(input[0] == ':') {
|
||||||
|
// consume to next whitespace, strip leading ':'
|
||||||
|
var prefix = t.tokenize(' '),
|
||||||
|
maskMatch = prefix.match(/:(.+)!(.+)@(.+)/);
|
||||||
|
|
||||||
|
if(maskMatch && maskMatch.length == 4) {
|
||||||
|
event.user = maskMatch[1];
|
||||||
|
event.ident = maskMatch[2];
|
||||||
|
event.host = maskMatch[3];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
event.host = prefix.substring(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* parameter string extraction */
|
||||||
|
|
||||||
|
// try consuming to beginning of a message
|
||||||
|
var paramsStr = t.tokenize(' :');
|
||||||
|
if(!paramsStr) {
|
||||||
|
// if that fails (no message), fall back to line ending
|
||||||
|
paramsStr = t.tokenize(null);
|
||||||
|
} else {
|
||||||
|
// first attempt succeeded, extract message
|
||||||
|
event.message = t.tokenize(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
// split the parameter string
|
||||||
|
event.args = paramsStr.split(' ');
|
||||||
|
// use first item as action, remove from list
|
||||||
|
event.action = event.args.shift();
|
||||||
|
|
||||||
|
// -- Common Event Variables --
|
||||||
|
// All channel/nick/target parameters in server-to-client events are accounted for here.
|
||||||
|
// Others need to be handled manually via event.params.
|
||||||
|
|
||||||
|
if (/^\d+$/.test(event.action)) {
|
||||||
|
var rsp = parseInt(event.action),
|
||||||
|
nickRsps = [ 301, 311, 312, 313, 317, 318, 319, 314,
|
||||||
|
369, 322, 324, 338, 401, 406, 432, 433, 436 ],
|
||||||
|
channelRsps = [ 322, 324, 331, 332, 346, 347, 348, 349,
|
||||||
|
366, 367, 368, 403, 404, 405, 467, 471,
|
||||||
|
473, 474, 475, 476, 477, 478, 482 ],
|
||||||
|
channelNickRsps = [ 325, 341 ],
|
||||||
|
targetRsps = [ 407, 437 ];
|
||||||
|
|
||||||
|
if(nickRsps.indexOf(rsp) != -1) {
|
||||||
|
event.user = event.args[0];
|
||||||
|
}
|
||||||
|
else if(channelRsps.indexOf(rsp) != -1) {
|
||||||
|
event.channel = event.args[0];
|
||||||
|
}
|
||||||
|
else if(channelNickRsps.indexOf(rsp) != -1) {
|
||||||
|
event.channel = event.args[0];
|
||||||
|
event.user = event.args[1];
|
||||||
|
}
|
||||||
|
else if(targetRsps.indexOf(rsp) != -1) {
|
||||||
|
if ('&#!+.~'.indexOf(event.args[0][0]) != -1) {
|
||||||
|
event.channel = event.args[0];
|
||||||
|
} else {
|
||||||
|
event.user = event.args[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(rsp == 352) {
|
||||||
|
event.channel = event.args[0];
|
||||||
|
event.user = event.args[4];
|
||||||
|
}
|
||||||
|
else if(rsp == 353) {
|
||||||
|
event.channel = event.args[2];
|
||||||
|
}
|
||||||
|
else if(rsp == 441) {
|
||||||
|
event.user = event.args[0];
|
||||||
|
event.channel = event.args[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(event.action == 'PRIVMSG') {
|
||||||
|
if('&#!+.~'.indexOf(event.args[0][0]) != -1) {
|
||||||
|
event.channel = event.args[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(event.action == 'JOIN' ||
|
||||||
|
event.action == 'PART' ||
|
||||||
|
event.action == 'TOPIC')
|
||||||
|
{
|
||||||
|
event.channel = event.args[0];
|
||||||
|
}
|
||||||
|
else if(event.action == 'KICK') {
|
||||||
|
event.channel = event.args[0];
|
||||||
|
event.targetUser = event.args[1];
|
||||||
|
}
|
||||||
|
else if(event.action == 'NICK') {
|
||||||
|
event.newNick = event.args[1];
|
||||||
|
event.multiChannel = true;
|
||||||
|
}
|
||||||
|
else if(event.action == 'MODE') {
|
||||||
|
event.channel = event.args[0];
|
||||||
|
event.modeChanges = event.args[1];
|
||||||
|
if(event.args.length > 2) {
|
||||||
|
event.targetUsers = event.args.slice(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(event.action == 'QUIT') {
|
||||||
|
event.multiChannel = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(event.multiChannel) {
|
||||||
|
// populate a list of channels this event applies to
|
||||||
|
event.channels = [];
|
||||||
|
for(var ch in event.allChannels) {
|
||||||
|
for(var nick in event.allChannels[ch].nicks) {
|
||||||
|
if(nick == event.user) {
|
||||||
|
event.channels.push(event.allChannels[ch]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(event.channel && event.channel in event.allChannels) {
|
||||||
|
// replace the channel name with it's coresponding object
|
||||||
|
event.channel = event.allChannels[event.channel];
|
||||||
|
} else {
|
||||||
|
event.channel = {
|
||||||
|
'name': event.user,
|
||||||
|
'nicks': {},
|
||||||
|
'toString': function() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run any pre-emit hooks
|
||||||
|
async.eachSeries(this.preEmitHooks, function(hook, callback) {
|
||||||
|
hook(event, callback);
|
||||||
|
}, function(err) {
|
||||||
|
this.emit(event);
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
|
// for handlers
|
||||||
|
if(event.message) {
|
||||||
|
event.params = event.message.split(' ');
|
||||||
|
} else {
|
||||||
|
event.params = [];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
JSBot.prototype.addPreEmitHook = function(func) {
|
||||||
|
this.preEmitHooks.push(func);
|
||||||
|
};
|
||||||
|
|
||||||
|
JSBot.prototype.clearHooks = function() {
|
||||||
|
this.preEmitHooks = [];
|
||||||
|
};
|
||||||
|
|
||||||
|
JSBot.prototype.emit = function(event) {
|
||||||
|
if(event.action in this.events) {
|
||||||
|
_.each(this.events[event.action], function(listener) {
|
||||||
|
var eventFunc = listener.listener;
|
||||||
|
|
||||||
|
var channel = false;
|
||||||
|
if(event.channel) {
|
||||||
|
channel = event.channel.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_.isFunction(eventFunc) && this.ignores &&
|
||||||
|
(_.has(this.ignores, event.user) && _.include(this.ignores[event.user], listener.tag)) == false &&
|
||||||
|
(_.has(this.ignores, channel) && _.include(this.ignores[channel], listener.tag)) == false) {
|
||||||
|
try {
|
||||||
|
eventFunc.call(this, event);
|
||||||
|
} catch(err) {
|
||||||
|
console.log('ERROR: ' + eventFunc + '\n' + err);
|
||||||
|
console.log(err.stack.split('\n')[1].trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// client functionality
|
||||||
|
|
||||||
|
JSBot.prototype.say = function(server, channel, msg) {
|
||||||
|
var event = new Event(this);
|
||||||
|
event.server = server;
|
||||||
|
event.channel = channel;
|
||||||
|
event.msg = msg;
|
||||||
|
event.reply(msg);
|
||||||
|
};
|
||||||
|
|
||||||
|
JSBot.prototype.reply = function(event, msg) {
|
||||||
|
this.connections[event.server].send('PRIVMSG ' + event.channel + ' ' + ':' + msg);
|
||||||
|
};
|
||||||
|
|
||||||
|
JSBot.prototype.act = function(event, msg) {
|
||||||
|
this.connections[event.server].send('PRIVMSG', event.channel, '\001ACTION ' + msg + '\001');
|
||||||
|
}
|
||||||
|
|
||||||
|
JSBot.prototype.replyNotice = function(event, msg) {
|
||||||
|
this.connections[event.server].send('NOTICE', event.user , ':' + msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
JSBot.prototype.join = function(event, channel) {
|
||||||
|
this.connections[event.server].join(channel);
|
||||||
|
};
|
||||||
|
|
||||||
|
JSBot.prototype.part = function(event, channel) {
|
||||||
|
this.connections[event.server].part(channel);
|
||||||
|
};
|
||||||
|
|
||||||
|
JSBot.prototype.mode = function(event, channel, msg) {
|
||||||
|
this.connections[event.server].send('MODE', channel, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
JSBot.prototype.nick = function(event, nick) {
|
||||||
|
this.connections[event.server].send('NICK', nick);
|
||||||
|
}
|
||||||
|
|
||||||
|
// listeners
|
||||||
|
|
||||||
|
JSBot.prototype.addListener = function(index, tag, func) {
|
||||||
|
if(!(index instanceof Array)) {
|
||||||
|
index = [index];
|
||||||
|
}
|
||||||
|
|
||||||
|
var listener = {
|
||||||
|
'listener': func,
|
||||||
|
'tag': tag
|
||||||
|
};
|
||||||
|
|
||||||
|
_.each(index, function(type) {
|
||||||
|
if(!_.has(this.events, type)) {
|
||||||
|
this.events[type] = [];
|
||||||
|
}
|
||||||
|
this.events[type].push(listener);
|
||||||
|
}, this);
|
||||||
|
};
|
||||||
|
|
||||||
|
JSBot.prototype.removeListeners = function() {
|
||||||
|
this.events = {
|
||||||
|
'JOIN': [],
|
||||||
|
'PART': [],
|
||||||
|
'QUIT': [],
|
||||||
|
'NICK': [],
|
||||||
|
'PRIVMSG': [],
|
||||||
|
'MODE': [],
|
||||||
|
'KICK': []
|
||||||
|
};
|
||||||
|
this.addDefaultListeners();
|
||||||
|
};
|
||||||
|
|
||||||
|
JSBot.prototype.addDefaultListeners = function() {
|
||||||
|
// PING
|
||||||
|
this.addListener('PING', 'pong', function(event) {
|
||||||
|
this.connections[event.server].pong(event.message);
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
|
// JOIN
|
||||||
|
this.addListener('JOIN', 'joinname', function(event) {
|
||||||
|
if(event.user != this.nick) {
|
||||||
|
if(!_.has(this.connections[event.server].channels[event.channel].nicks, event.user)) {
|
||||||
|
this.connections[event.server].channels[event.channel].nicks[event.user] = {
|
||||||
|
'name': event.user,
|
||||||
|
'op': false,
|
||||||
|
'voice': false,
|
||||||
|
'toString': function() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
event.user = this.connections[event.server].channels[event.channel].nicks[event.user];
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
|
// PART
|
||||||
|
this.addListener('PART', 'partname', function(event) {
|
||||||
|
if(event.user == this.nick)
|
||||||
|
delete this.connections[event.server].channels[event.channel];
|
||||||
|
else
|
||||||
|
delete event.channel.nicks[event.user];
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
|
// KICK
|
||||||
|
this.addListener('KICK', 'kickname', function(event) {
|
||||||
|
if(event.targetUser == this.nick)
|
||||||
|
delete this.connections[event.server].channels[event.channel];
|
||||||
|
else
|
||||||
|
delete event.channel.nicks[event.user];
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
|
// QUIT
|
||||||
|
this.addListener('QUIT', 'quitname', function(event) {
|
||||||
|
_.each(event.allChannels, function(channel) {
|
||||||
|
delete event.allChannels[channel].nicks[event.user];
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// NICK
|
||||||
|
this.addListener('NICK', 'nickchan', function(event) {
|
||||||
|
if(event.user == this.nick) {
|
||||||
|
this.nick = event.message;
|
||||||
|
} else {
|
||||||
|
_.each(event.allChannels, function(channel) {
|
||||||
|
if(_.has(channel, 'nicks')) {
|
||||||
|
if(event.user in channel.nicks) {
|
||||||
|
channel.nicks[event.message] = channel.nicks[event.user];
|
||||||
|
channel.nicks[event.message].name = event.message;
|
||||||
|
delete channel.nicks[event.user];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
|
// MODE
|
||||||
|
this.addListener('MODE', 'modop', function(event) {
|
||||||
|
if(!event.modeChanges || !event.targetUsers)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var changeSets = event.modeChanges.match(/[+-][ov]+/);
|
||||||
|
if(!changeSets)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for(var i=0; i < changeSets.length && i < event.targetUsers.length; ++i) {
|
||||||
|
var chanUser = event.channel.nicks[event.targetUsers[i]],
|
||||||
|
prefix = changeSets[i].match(/[+-]/)[0],
|
||||||
|
flags = changeSets[i].match(/[ov]+/)[0],
|
||||||
|
value = prefix == '+';
|
||||||
|
if(!chanUser) {
|
||||||
|
event.channel.nicks[event.targetUsers[i]] = {
|
||||||
|
'name': event.targetUsers[i],
|
||||||
|
'op': false,
|
||||||
|
'voice': false,
|
||||||
|
'toString': function() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
chanUser = event.channel.nicks[event.targetUsers[i]];
|
||||||
|
}
|
||||||
|
|
||||||
|
for(var f=0; f < flags.length; ++f) {
|
||||||
|
if(flags[f] == 'o') {
|
||||||
|
chanUser.op = value;
|
||||||
|
}
|
||||||
|
else if(flags[f] == 'v')
|
||||||
|
chanUser.voice = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 353 replies
|
||||||
|
this.addListener('353', 'names', function(event) {
|
||||||
|
|
||||||
|
if(!_.has(this.connections[event.server].channels, event.channel)) {
|
||||||
|
this.connections[event.server].channels[event.channel] = {
|
||||||
|
'name': event.channel,
|
||||||
|
'nicks': {},
|
||||||
|
'toString': function() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
event.channel = this.connections[event.server].channels[event.channel];
|
||||||
|
|
||||||
|
for(var i=0; i < event.params.length; ++i) {
|
||||||
|
var hasFlag = '~&@%+'.indexOf(event.params[i][0]) != -1,
|
||||||
|
name = hasFlag ? event.params[i].slice(1) : event.params[i];
|
||||||
|
|
||||||
|
event.channel.nicks[name] = {
|
||||||
|
'name': name,
|
||||||
|
'op': hasFlag && event.params[i][0] == '@',
|
||||||
|
'voice': hasFlag && event.params[i][0] == '+',
|
||||||
|
'toString': function() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.addListener('PRIVMSG', 'ping', function(event) {
|
||||||
|
//if(event.message.match(/\x01PING .+\x01/) != null)
|
||||||
|
event.replyNotice(event.message);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// ignore functionality
|
||||||
|
|
||||||
|
JSBot.prototype.ignoreTag = function(item, tag) {
|
||||||
|
if(_.has(this.ignores, item) == false)
|
||||||
|
this.ignores[item] = [];
|
||||||
|
|
||||||
|
this.ignores[item].push(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
JSBot.prototype.clearIgnores = function() {
|
||||||
|
this.ignores = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
JSBot.prototype.removeIgnore = function(item, tag) {
|
||||||
|
if(_.has(this.ignores, item) && _.include(this.ignores[item], tag))
|
||||||
|
this.ignores[item].slice(this.ignores[item].indexOf(tag), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// events
|
||||||
|
|
||||||
|
var Event = function(instance) {
|
||||||
|
this.instance = instance;
|
||||||
|
};
|
||||||
|
|
||||||
|
Event.prototype.reply = function(msg) {
|
||||||
|
this.instance.reply(this, msg);
|
||||||
|
};
|
||||||
|
|
||||||
|
Event.prototype.replyNotice = function(msg) {
|
||||||
|
this.instance.replyNotice(this, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
// export that shit
|
||||||
|
|
||||||
|
exports.createJSBot = function(name) {
|
||||||
|
return new JSBot(name);
|
||||||
|
};
|
29
jsbot/package.json
Normal file
29
jsbot/package.json
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"name": "jsbot",
|
||||||
|
"version": "0.3.0",
|
||||||
|
"description": "It's a JS IRC library.",
|
||||||
|
"main": "jsbot.js",
|
||||||
|
"dependencies": {
|
||||||
|
"async": "~0.2.9",
|
||||||
|
"underscore": "~1.4.4"
|
||||||
|
},
|
||||||
|
"devDependencies": {},
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git://github.com/reality/jsbot.git"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"irc",
|
||||||
|
"ssl",
|
||||||
|
"reality",
|
||||||
|
"dbot"
|
||||||
|
],
|
||||||
|
"author": "Luke Slater (reality) <tinmachin3@gmail.com>",
|
||||||
|
"license": "GPL",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/reality/jsbot/issues"
|
||||||
|
}
|
||||||
|
}
|
28
jsbot/run.js
Normal file
28
jsbot/run.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
jsbot = require('./jsbot');
|
||||||
|
|
||||||
|
var instance = jsbot.createJSBot('jsbottest');
|
||||||
|
|
||||||
|
instance.addConnection('aberwiki', 'irc.aberwiki.org', 6667, 'reality', function(event) {
|
||||||
|
instance.join(event, '#realitest');
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
|
instance.addConnection('freenode', 'irc.freenode.net', 6667, 'reality', function(event) {
|
||||||
|
instance.join(event, '#realitest');
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
|
instance.addConnection('darchoods', 'irc.darchoods.net', '+6697', 'reality', function(event) {
|
||||||
|
instance.join(event, '#realitest');
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
|
instance.addPreEmitHook(function(event, callback) {
|
||||||
|
if(event.user) event.user = event.user.toLowerCase();
|
||||||
|
callback(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
instance.addListener('JOIN', 'join', function(event) {
|
||||||
|
event.reply('I love ' + event.user);
|
||||||
|
});
|
||||||
|
|
||||||
|
instance.ignoreTag('jsbottest', 'join');
|
||||||
|
|
||||||
|
instance.connectAll();
|
38
jsbot/tokenizer.js
Normal file
38
jsbot/tokenizer.js
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* String tokenizer thing.
|
||||||
|
* by speeddefrost <origin206@protonmail.ch>
|
||||||
|
*/
|
||||||
|
|
||||||
|
function Tokenizer(str) {
|
||||||
|
this.str = str;
|
||||||
|
this.pos = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Tokenizer.prototype.tokenize = function(delim) {
|
||||||
|
if(this.pos == -1)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if(!delim) {
|
||||||
|
var leftover = this.str.slice(this.pos);
|
||||||
|
this.pos = -1;
|
||||||
|
return leftover;
|
||||||
|
}
|
||||||
|
|
||||||
|
var i = this.pos,
|
||||||
|
j = this.pos + delim.length
|
||||||
|
z = this.str.length - delim.length;
|
||||||
|
|
||||||
|
while(i <= z) {
|
||||||
|
if(this.str.substring(i,j) == delim) {
|
||||||
|
var token = this.str.substring(this.pos, i);
|
||||||
|
this.pos = j;
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
++i; ++j;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = Tokenizer;
|
28
modules-stock/SAMPLE/README.md
Normal file
28
modules-stock/SAMPLE/README.md
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
## FOO
|
||||||
|
|
||||||
|
bar.
|
||||||
|
|
||||||
|
### Description
|
||||||
|
|
||||||
|
This module provides a command which allows users to foobar.
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
|
It has following dependencies:
|
||||||
|
+ [foo](link)
|
||||||
|
|
||||||
|
### config.json
|
||||||
|
|
||||||
|
foo
|
||||||
|
```
|
||||||
|
```
|
||||||
|
|
||||||
|
### Commands
|
||||||
|
|
||||||
|
|
||||||
|
#### ~foo [(bar]
|
||||||
|
|
||||||
|
Example:
|
||||||
|
+ ~foo bar
|
||||||
|
|
||||||
|
### TODO
|
4
modules-stock/SAMPLE/config
Normal file
4
modules-stock/SAMPLE/config
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"foo": true,
|
||||||
|
"foo": "bar"
|
||||||
|
}
|
39
modules-stock/SAMPLE/foo
Normal file
39
modules-stock/SAMPLE/foo
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/**
|
||||||
|
* Module Name: foo
|
||||||
|
* Description: bar.
|
||||||
|
* Requires: foo [bar]
|
||||||
|
*/
|
||||||
|
|
||||||
|
var _ = require('underscore')._,
|
||||||
|
bar = require('foo');//dependencies
|
||||||
|
|
||||||
|
var foo = function(dbot) { //name of module
|
||||||
|
|
||||||
|
this.ApiRoot = 'API_ROOT_HERE';
|
||||||
|
|
||||||
|
this.internalAPI = {
|
||||||
|
//code for internal api here
|
||||||
|
};
|
||||||
|
|
||||||
|
this.api = {
|
||||||
|
//code for api here
|
||||||
|
};
|
||||||
|
|
||||||
|
this.commands = {
|
||||||
|
//code for commands here
|
||||||
|
};
|
||||||
|
|
||||||
|
this.onLoad = function() {
|
||||||
|
//code for stuff to be done on load here
|
||||||
|
};
|
||||||
|
|
||||||
|
this.onDestroy = function() {
|
||||||
|
//stuff to be done on destroy here
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.fetch = function(dbot) {
|
||||||
|
return new foo(dbot); //name of module
|
||||||
|
};
|
8
modules-stock/SAMPLE/strings
Normal file
8
modules-stock/SAMPLE/strings
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"foo": {
|
||||||
|
"en": "{output} bar"
|
||||||
|
},
|
||||||
|
"foo2": {
|
||||||
|
"en": "Something went wrong :( Example:'~foo bar'"
|
||||||
|
}
|
||||||
|
}
|
3
modules-stock/SAMPLE/usage
Normal file
3
modules-stock/SAMPLE/usage
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"~foo": "~foo [bar]"
|
||||||
|
}
|
72
modules-stock/admin/README.md
Normal file
72
modules-stock/admin/README.md
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
## Admin
|
||||||
|
|
||||||
|
Administrator functionality.
|
||||||
|
|
||||||
|
### Description
|
||||||
|
|
||||||
|
Various administration functionality such as banning users, hot-reloading the
|
||||||
|
code and ordering him to talk. Note that commands added here are handled with
|
||||||
|
their own listener, rather than being part of the command logic which is handled
|
||||||
|
by the Command module. Functionality in this module can be slightly unsafe as
|
||||||
|
not everything is thoroughly sanity checked.
|
||||||
|
|
||||||
|
### Commands
|
||||||
|
|
||||||
|
#### join [#channel]
|
||||||
|
Join the given channel.
|
||||||
|
|
||||||
|
#### part [#channel]
|
||||||
|
Leave the given channel.
|
||||||
|
|
||||||
|
#### opme [#channel]
|
||||||
|
Gives the caller ops in a given channel if possible. If called without a
|
||||||
|
channel, it will attempt to give the caller ops in the current channel.
|
||||||
|
|
||||||
|
#### greload
|
||||||
|
Perform a git pull, and then execute the 'reload' command. Saves a lot of time
|
||||||
|
updating!
|
||||||
|
|
||||||
|
#### version [module]
|
||||||
|
Shows the git version of the currently loaded revision of DBot. If module is
|
||||||
|
provided, it will attempt to get the revision of the module (this is only useful
|
||||||
|
for submodules).
|
||||||
|
|
||||||
|
#### status [module]
|
||||||
|
Show the recorded status for a given module, this is helpful for debugging
|
||||||
|
issues when loading or for checking if a module is loaded.
|
||||||
|
|
||||||
|
#### reload
|
||||||
|
Reload all of the modules currently in use by DBot. By using this, all module
|
||||||
|
functionality should be reloadable and replaceable without having to restart the
|
||||||
|
bot or interrupt the connection to the server.
|
||||||
|
|
||||||
|
#### say [#channel] [message]
|
||||||
|
Have DBot post the given message in the given channel (uses the server from
|
||||||
|
which you are sending the message). You may replace channel with '@' to have him
|
||||||
|
post the message in the current channel. Channel may also be replaced with a
|
||||||
|
nick on the server.
|
||||||
|
|
||||||
|
#### load [module]
|
||||||
|
Load a new module. This works by adding a module name to the roster and then
|
||||||
|
triggering a reload of all modules, at which point the new module is actually
|
||||||
|
loaded by the standard DBot process.
|
||||||
|
|
||||||
|
#### unload [module]
|
||||||
|
Unload a currently loaded module. This removes the module, and then triggers a
|
||||||
|
reload of all modules.
|
||||||
|
|
||||||
|
#### setconfig [path] [value]
|
||||||
|
Set a config value at path to be a certain value persistently. For example, if
|
||||||
|
you want to change the web module to listen on port 9001, you can run _setconfig
|
||||||
|
web.webPort 9001_.
|
||||||
|
|
||||||
|
#### pushconfig [path] [value]
|
||||||
|
Push a new value to an existing config array. For example, if you want to add
|
||||||
|
the user 'batman62' to the DBot moderators, you can run _pushconfig moderators
|
||||||
|
batman62_.
|
||||||
|
|
||||||
|
#### showconfig [path]
|
||||||
|
Use this to explore and view the DBot configuration. If called without a path,
|
||||||
|
it will display the config keys in the root; if the path is a subkey, it will
|
||||||
|
show all config keys under that key. If you give it an actual key, it'll show you
|
||||||
|
the currently effective config value.
|
64
modules-stock/admin/admin.js
Normal file
64
modules-stock/admin/admin.js
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
/**
|
||||||
|
* Module Name: Admin
|
||||||
|
* Description: Set of commands which only one who is a DepressionBot
|
||||||
|
* administrator can run.
|
||||||
|
*/
|
||||||
|
var fs = require('fs'),
|
||||||
|
_ = require('underscore')._;
|
||||||
|
|
||||||
|
var admin = function(dbot) {
|
||||||
|
this.internalAPI = {
|
||||||
|
'getCurrentConfig': function(configKey, callback) {
|
||||||
|
var configPath = dbot.config;
|
||||||
|
configKey = configKey.split('.');
|
||||||
|
|
||||||
|
for(var i=0;i<configKey.length;i++) {
|
||||||
|
if(_.has(configPath, configKey[i])) {
|
||||||
|
configPath = configPath[configKey[i]];
|
||||||
|
} else {
|
||||||
|
configPath = null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(configPath);
|
||||||
|
},
|
||||||
|
|
||||||
|
'setConfig': function(configKey, newOption, callback) {
|
||||||
|
var configPath = dbot.customConfig,
|
||||||
|
oldOption = null;
|
||||||
|
configKey = configKey.split('.');
|
||||||
|
|
||||||
|
for(var i=0;i<configKey.length-1;i++) {
|
||||||
|
if(!_.has(configPath, configKey[i])) {
|
||||||
|
configPath[configKey[i]] = {};
|
||||||
|
}
|
||||||
|
configPath = configPath[configKey[i]];
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_.has(configPath, configKey[i])) {
|
||||||
|
oldOption = configPath[configKey[i]];
|
||||||
|
}
|
||||||
|
configPath[configKey[i]] = newOption;
|
||||||
|
|
||||||
|
this.internalAPI.saveConfig();
|
||||||
|
dbot.reloadModules();
|
||||||
|
callback(null, oldOption);
|
||||||
|
}.bind(this),
|
||||||
|
|
||||||
|
'saveConfig': function() {
|
||||||
|
var config = dbot.customConfig;
|
||||||
|
fs.writeFileSync('config.json', JSON.stringify(config, null, ' '));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.onLoad = function() {
|
||||||
|
dbot.api.timers.addTimer(60000, function() {
|
||||||
|
dbot.save(function() {});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.fetch = function(dbot) {
|
||||||
|
return new admin(dbot);
|
||||||
|
};
|
311
modules-stock/admin/commands.js
Normal file
311
modules-stock/admin/commands.js
Normal file
@ -0,0 +1,311 @@
|
|||||||
|
var fs = require('fs'),
|
||||||
|
_ = require('underscore')._,
|
||||||
|
sys = require('sys'),
|
||||||
|
process = require('process'),
|
||||||
|
exec = require('child_process').exec;
|
||||||
|
|
||||||
|
var commands = function(dbot) {
|
||||||
|
var noChangeConfig = [ 'servers', 'name', 'moduleNames' ];
|
||||||
|
|
||||||
|
var commands = {
|
||||||
|
// Join a channel
|
||||||
|
'~join': function(event) {
|
||||||
|
var channel = event.params[1];
|
||||||
|
if(_.has(event.allChannels, channel)) {
|
||||||
|
event.reply(dbot.t('already_in_channel', {'channel': channel}));
|
||||||
|
} else {
|
||||||
|
dbot.instance.join(event, channel);
|
||||||
|
event.reply(dbot.t('join', {'channel': channel}));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// Leave a channel
|
||||||
|
'~part': function(event) {
|
||||||
|
var channel = event.params[1];
|
||||||
|
if(!_.has(event.allChannels, channel)) {
|
||||||
|
event.reply(dbot.t('not_in_channel', {'channel': channel}));
|
||||||
|
} else {
|
||||||
|
event.instance.part(event, channel);
|
||||||
|
event.reply(dbot.t('part', {'channel': channel}));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// Op admin caller in given channel
|
||||||
|
'~opme': function(event) {
|
||||||
|
var channel = event.params[1];
|
||||||
|
|
||||||
|
// If given channel isn't valid just op in current one.
|
||||||
|
if(!_.has(event.allChannels, channel)) {
|
||||||
|
channel = event.channel.name;
|
||||||
|
}
|
||||||
|
dbot.instance.mode(event, channel, ' +o ' + event.user);
|
||||||
|
},
|
||||||
|
|
||||||
|
// Do a git pull and reload
|
||||||
|
'~greload': function(event) {
|
||||||
|
exec("git pull", function (error, stdout, stderr) {
|
||||||
|
exec("git submodule update", function (error, stdout, stderr) {
|
||||||
|
event.reply(dbot.t('gpull'));
|
||||||
|
commands['~reload'](event);
|
||||||
|
commands['~version'](event);
|
||||||
|
}.bind(this));
|
||||||
|
}.bind(this));
|
||||||
|
},
|
||||||
|
|
||||||
|
// Display commit information for part of dbot
|
||||||
|
'~version': function(event){
|
||||||
|
var cmd = "git log --pretty=format:'%h (%s): %ar' -n 1 -- ";
|
||||||
|
if(event.params[1]){
|
||||||
|
var input = event.params[1].trim();
|
||||||
|
if(_.has(dbot.modules, input.split("/")[0])){
|
||||||
|
cmd += "modules/"+input;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
cmd += input;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exec(cmd, function(error, stdout, stderr){
|
||||||
|
if(stdout.length > 0){
|
||||||
|
event.reply(stdout);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
event.reply(dbot.t("no_version"));
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
},
|
||||||
|
|
||||||
|
'~status': function(event) {
|
||||||
|
var moduleName = event.params[1];
|
||||||
|
if(_.has(dbot.status, moduleName)) {
|
||||||
|
var status = dbot.status[moduleName];
|
||||||
|
if(status === true) {
|
||||||
|
event.reply(dbot.t('status_good', {
|
||||||
|
'module': moduleName,
|
||||||
|
'reason': status
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t('status_bad', {
|
||||||
|
'module': moduleName,
|
||||||
|
'reason': status
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t("status_unloaded"));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// Reload DB, translations and modules.
|
||||||
|
'~reload': function(event) {
|
||||||
|
dbot.db = JSON.parse(fs.readFileSync('db.json', 'utf-8'));
|
||||||
|
dbot.reloadModules();
|
||||||
|
process.nextTick(function() {
|
||||||
|
event.reply(dbot.t('reload'));
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
// Say something in a channel
|
||||||
|
'~say': function(event) {
|
||||||
|
var channel = event.params[1];
|
||||||
|
if(event.params[1] === "@") {
|
||||||
|
channel = event.channel.name;
|
||||||
|
}
|
||||||
|
var message = event.params.slice(2).join(' ');
|
||||||
|
dbot.say(event.server, channel, message);
|
||||||
|
},
|
||||||
|
|
||||||
|
// Load new module
|
||||||
|
'~load': function(event) {
|
||||||
|
var moduleName = event.params[1];
|
||||||
|
if(!_.include(dbot.config.moduleNames, moduleName)) {
|
||||||
|
dbot.customConfig.moduleNames.push(moduleName);
|
||||||
|
this.internalAPI.saveConfig();
|
||||||
|
dbot.reloadModules();
|
||||||
|
process.nextTick(function() {
|
||||||
|
if(dbot.status[moduleName] === true) {
|
||||||
|
event.reply(dbot.t('load_module', { 'moduleName': moduleName }));
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t('load_failed', { 'module': moduleName }));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
if(moduleName == 'web') {
|
||||||
|
event.reply(dbot.t('already_loaded_web'));
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t('already_loaded', { 'moduleName': moduleName }));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// Unload a loaded module
|
||||||
|
'~unload': function(event) {
|
||||||
|
var moduleNames = dbot.config.moduleNames;
|
||||||
|
var moduleName = event.params[1];
|
||||||
|
if(_.include(moduleNames, moduleName)) {
|
||||||
|
var moduleDir = '../' + moduleName + '/';
|
||||||
|
try {
|
||||||
|
var cacheKey = require.resolve(moduleDir + moduleName);
|
||||||
|
delete require.cache[cacheKey];
|
||||||
|
} catch(err) { }
|
||||||
|
|
||||||
|
dbot.customConfig.moduleNames = _.without(dbot.config.moduleNames, moduleName);
|
||||||
|
this.internalAPI.saveConfig();
|
||||||
|
dbot.reloadModules();
|
||||||
|
|
||||||
|
process.nextTick(function() {
|
||||||
|
event.reply(dbot.t('unload_module', { 'moduleName': moduleName }));
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t('unload_error', { 'moduleName': moduleName }));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/*** Config options ***/
|
||||||
|
|
||||||
|
'~setconfig': function(event) {
|
||||||
|
var configPath = event.input[1],
|
||||||
|
newOption = event.input[2];
|
||||||
|
|
||||||
|
event.reply(event.input[1]);
|
||||||
|
|
||||||
|
if(!_.include(noChangeConfig, configPath)) {
|
||||||
|
this.internalAPI.getCurrentConfig(configPath, function(config) {
|
||||||
|
if(config !== null) {
|
||||||
|
// Convert to boolean type if config item boolean
|
||||||
|
if(_.isBoolean(config)) {
|
||||||
|
newOption = (newOption == "true");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert to integer type is config item integer
|
||||||
|
if(_.isNumber(config)) {
|
||||||
|
newOption = parseInt(newOption);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(_.isArray(config)) {
|
||||||
|
event.reply(dbot.t("config_array", { "alternate": "pushconfig" }));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t("no_config_key", {'path': configPath}));
|
||||||
|
configPath = configPath.split('.');
|
||||||
|
if(_.has(dbot.config.modules, configPath[0])) {
|
||||||
|
configPath.splice(0, 0, 'modules');
|
||||||
|
event.input[1] = configPath.join('.');
|
||||||
|
commands['~setconfig'](event);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t('new_config_key', { 'key': configPath }));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.internalAPI.setConfig(configPath, newOption, function(err) {
|
||||||
|
event.reply(configPath + ": " + config + " -> " + newOption);
|
||||||
|
});
|
||||||
|
}.bind(this));
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t("config_lock"));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
'~pushconfig': function(event) {
|
||||||
|
var configPath = event.input[1],
|
||||||
|
newOption = event.input[2];
|
||||||
|
|
||||||
|
if(!_.include(noChangeConfig, configPath)) {
|
||||||
|
this.internalAPI.getCurrentConfig(configPath, function(config) {
|
||||||
|
if(config !== null) {
|
||||||
|
if(_.isArray(config)) {
|
||||||
|
event.reply(configPath + ": " + config + " << " + newOption);
|
||||||
|
config.push(newOption);
|
||||||
|
this.internalAPI.setConfig(configPath, config, function(err) {});
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t("config_array", { "alternate": "setconfig" }));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t("no_config_key", { 'path': configPath }));
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t("config_lock"));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
'~showconfig': function(event) {
|
||||||
|
var configPath = event.params[1];
|
||||||
|
if(configPath) {
|
||||||
|
this.internalAPI.getCurrentConfig(configPath, function(config) {
|
||||||
|
if(config !== null) {
|
||||||
|
if(_.isArray(config)) {
|
||||||
|
event.reply(dbot.t("config_keys_location", {
|
||||||
|
"path": configPath,
|
||||||
|
"value": config
|
||||||
|
}));
|
||||||
|
} else if(_.isObject(config)) {
|
||||||
|
event.reply(dbot.t("config_keys_location", {
|
||||||
|
"path": configPath,
|
||||||
|
"value": _.keys(config)
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t("config_keys_location", {
|
||||||
|
"path": configPath,
|
||||||
|
"value": config
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t("no_config_key", {'path': configPath}));
|
||||||
|
|
||||||
|
configPath = configPath.split('.');
|
||||||
|
if(_.has(dbot.config.modules, configPath[0])) {
|
||||||
|
configPath.splice(0, 0, 'modules');
|
||||||
|
} else {
|
||||||
|
configPath.pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
event.params[1] = configPath.join('.');
|
||||||
|
commands['~showconfig'](event);
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t("config_keys_location", {
|
||||||
|
"path": "root",
|
||||||
|
"value": _.keys(dbot.config)
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
'~savemodules': function(event) {
|
||||||
|
fs.readFile('config.json', 'utf-8', function(err, config) {
|
||||||
|
config = JSON.parse(config);
|
||||||
|
config.moduleNames = _.keys(dbot.modules);
|
||||||
|
fs.writeFile('config.json', JSON.stringify(config, null, ' '), function() {
|
||||||
|
event.reply(dbot.t('modules_saved', { 'modules': _.keys(dbot.modules) }));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
'~die': function(event) {
|
||||||
|
event.reply('BRB coconut hunting...');
|
||||||
|
setTimeout(3000, function() {
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
_.each(commands, function(command) {
|
||||||
|
command.access = 'admin';
|
||||||
|
});
|
||||||
|
|
||||||
|
commands['~showconfig'].access = 'moderator';
|
||||||
|
commands['~join'].access = 'moderator';
|
||||||
|
commands['~part'].access = 'moderator';
|
||||||
|
commands['~opme'].access = 'moderator';
|
||||||
|
commands['~say'].access = 'moderator';
|
||||||
|
|
||||||
|
commands['~pushconfig'].regex = [/pushconfig ([^ ]+) ([^ ]+)/, 3];
|
||||||
|
commands['~setconfig'].regex = [/setconfig ([^ ]+) ([^ ]+)/, 3];
|
||||||
|
|
||||||
|
return commands;
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.fetch = function(dbot) {
|
||||||
|
return commands(dbot);
|
||||||
|
}
|
5
modules-stock/admin/config.json
Normal file
5
modules-stock/admin/config.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"ignorable": false,
|
||||||
|
"dbType": "redis",
|
||||||
|
"dependencies": [ "command" ]
|
||||||
|
}
|
230
modules-stock/admin/strings.json
Normal file
230
modules-stock/admin/strings.json
Normal file
@ -0,0 +1,230 @@
|
|||||||
|
{
|
||||||
|
"join": {
|
||||||
|
"en": "Joined {channel}",
|
||||||
|
"es" : "Entrado en {channel}",
|
||||||
|
"na'vi": "fpxäkìm {channel}(nemfa)",
|
||||||
|
"cy": "Wedi ymuno {channel}",
|
||||||
|
"nl": "{channel} binnengekomen",
|
||||||
|
"de": "{channel} beigetreten",
|
||||||
|
"fr": "{channel} rejoint",
|
||||||
|
"it": "Aderito a {channel}"
|
||||||
|
},
|
||||||
|
"part": {
|
||||||
|
"en": "Left {channel}",
|
||||||
|
"es" : "Abandonada {channel}",
|
||||||
|
"na'vi": "Hum {channel}",
|
||||||
|
"cy": "Wedi gadael {channel}",
|
||||||
|
"nl": "{channel} verlaten",
|
||||||
|
"de": "{channel} verlassen",
|
||||||
|
"fr": "{channel} quitté",
|
||||||
|
"it": "uscito da {channel}"
|
||||||
|
},
|
||||||
|
"gpull": {
|
||||||
|
"en": "Git pulled that shit.",
|
||||||
|
"es": "Hecho git pull en esta mierda.",
|
||||||
|
"na'vi": "Gìtìl fì'uti stamarsìm.",
|
||||||
|
"cy": "Wedi tynnu git yr cach na i gyd",
|
||||||
|
"nl": "Git heeft die zooi binnengehaald.",
|
||||||
|
"de": "Git hat es gezogen",
|
||||||
|
"fr": "Git a pullé cette merde",
|
||||||
|
"it": "Git ha pullato questa coglionata"
|
||||||
|
},
|
||||||
|
"reload": {
|
||||||
|
"en": "Reloaded that shit.",
|
||||||
|
"es": "Recargado esta mierda.",
|
||||||
|
"na'vi": "Oel fìuti stìyeftxaw.",
|
||||||
|
"cy": "Ail-lwytho'r cach na",
|
||||||
|
"nl": "Die zooi opnieuw geladen.",
|
||||||
|
"de": "Neu geladen",
|
||||||
|
"fr": "Bordel rechargé",
|
||||||
|
"it": "Ricaricato questa puttanata"
|
||||||
|
},
|
||||||
|
"load_module": {
|
||||||
|
"en": "Loaded new module: {moduleName}",
|
||||||
|
"es": "Cargado módulo nuevo: {moduleName}",
|
||||||
|
"na'vi": "Oel {moduleName}it amip stìyeftxaw.",
|
||||||
|
"cy": "Wedi llwytho modiwl newydd: {moduleName}",
|
||||||
|
"nl": "Nieuwe module geladen: {moduleName}",
|
||||||
|
"de": "Neues Modul geladen: {moduleName}",
|
||||||
|
"fr": "Nouveau module chargé : {moduleName}",
|
||||||
|
"it": "Caricato nuovo modulo: {moduleName}"
|
||||||
|
},
|
||||||
|
"unload_module": {
|
||||||
|
"en": "Turned off module: {moduleName}",
|
||||||
|
"es": "Descargado módulo: {moduleName}",
|
||||||
|
"na'vi": "Oel {moduleName} tswìya'.",
|
||||||
|
"cy": "Wedi troi ffwrdd y modiwl: {moduleName}",
|
||||||
|
"nl": "Module uitgeschakeld: {moduleName}",
|
||||||
|
"de": "Modul ausgeschaltet: {moduleName}",
|
||||||
|
"fr": "Module déchargé : {moduleName}",
|
||||||
|
"it": "Inabilitato modulo: {moduleName}"
|
||||||
|
},
|
||||||
|
"unload_error": {
|
||||||
|
"en": "{moduleName} isn't loaded. Idiot.",
|
||||||
|
"es": "{moduleName} no está cargado. Idiota.",
|
||||||
|
"na'vi": "Oel {moduleName}it omum. Nga skxawng lu.",
|
||||||
|
"cy": "Di {moduleName} ddim wedi llwytho. Twpsyn",
|
||||||
|
"nl": "{moduleName} is niet geladen. Idioot.",
|
||||||
|
"de": "{moduleName} ist nicht geladen, du Idiot.",
|
||||||
|
"fr": "{moduleName} n'est pas chargé. Idiot.",
|
||||||
|
"it": "{moduleName} non è caricato. Idiota"
|
||||||
|
},
|
||||||
|
"banned": {
|
||||||
|
"en": "{user} banned from {command}",
|
||||||
|
"es": "{user} está prohibido de usar {command}",
|
||||||
|
"na'vi": "{command}ìri {user} ke tung.",
|
||||||
|
"cy": "{user} wedi ei gohurio o {command}",
|
||||||
|
"nl": "{user} mag {command} niet meer gebruiken",
|
||||||
|
"de": "{user} wurde von {command} gebannt",
|
||||||
|
"fr": "{user} a été interdit d'utiliser {command}",
|
||||||
|
"it": "{user} bandito da {command}"
|
||||||
|
},
|
||||||
|
"unbanned": {
|
||||||
|
"en": "{user} unbanned from {command}",
|
||||||
|
"es": "{user} no está prohibido de user {command}",
|
||||||
|
"na'vi": "{command}ìri {user} tung set.",
|
||||||
|
"cy": "{user} wedi ei dad-wahardd o {command}",
|
||||||
|
"nl": "{user} mag {command} weer gebruiken",
|
||||||
|
"de": "{user} wurde von {command} entbannt",
|
||||||
|
"fr": "{user} peut de nouveau utiliser {command}",
|
||||||
|
"it": "{user} riammesso da {command}"
|
||||||
|
},
|
||||||
|
"unban_error": {
|
||||||
|
"en": "{user} wasn't banned from that command, fool.",
|
||||||
|
"es": "{user} no fue prohibido de esta instrucción, tont@.",
|
||||||
|
"na'vi": "{user} fìtsu'oti tamung srekrr, nga skxawng lu.",
|
||||||
|
"cy": "Nid oedd {user} wedi ei wahardd o'r gorchymyn yna, twpsyn",
|
||||||
|
"nl": "{user} mag dat commando sowieso al gebruiken, mafketel.",
|
||||||
|
"de": "{user} wurde nicht von {command} gebannt, du Trottel",
|
||||||
|
"fr": "{user} n'a pas été interdit d'utiliser cette commande, imbécile.",
|
||||||
|
"it": "{user} non è stato bandito da utilizzare questo commando, imbecille."
|
||||||
|
},
|
||||||
|
"qlock": {
|
||||||
|
"en": "Locked quote category: {category}",
|
||||||
|
"es": "Cerrado la categoría: {category}",
|
||||||
|
"na'vi": "{category}ìri oel 'upxareti fmoli",
|
||||||
|
"cy": "Categori wedi cloi: {category}",
|
||||||
|
"nl": "Quote categorie vergrendeld: {category}",
|
||||||
|
"de": "Zitat-Kategorie geschlossen: {category}",
|
||||||
|
"fr": "Catégorie de citations verrouillée : {category}",
|
||||||
|
"it": "Categoria di citazione bloccata : {category}"
|
||||||
|
},
|
||||||
|
"already_in_channel": {
|
||||||
|
"en": "I'm already in {channel}",
|
||||||
|
"na'vi": "Oel {channel}it tok li",
|
||||||
|
"cy": "Rydw i eisoes yn {channel}",
|
||||||
|
"nl": "Ik ben al in {channel}",
|
||||||
|
"de": "Ich bin schon in {channel}",
|
||||||
|
"fr": "Je suis déjà dans {channel}",
|
||||||
|
"it": "Sono già in {channel}"
|
||||||
|
},
|
||||||
|
"not_in_channel": {
|
||||||
|
"en": "I'm not in {channel}",
|
||||||
|
"na'vi": "Oel {channel}it ke tok",
|
||||||
|
"cy": "Rydw i ddim yn {channel}",
|
||||||
|
"nl": "Ik ben niet aanwezig in {channel}",
|
||||||
|
"de": "Ich bin noch nicht in {channel}",
|
||||||
|
"fr": "Je ne suis pas dans {channel}",
|
||||||
|
"it": "Non sono in {channel}"
|
||||||
|
},
|
||||||
|
"already_loaded_web": {
|
||||||
|
"en": "WHY CAN'T I LOAD ALL THIS WEB? (web already loaded)",
|
||||||
|
"na'vi": "PELUN OEL KE TSUN OMUM FÌWETIT NÌWOTX (wetìri oe omum li)",
|
||||||
|
"cy": "PAM ALLA I DDIM YN LWYTHO POB Y WE? (We eisoes yn lwytho)",
|
||||||
|
"nl": "AL DIT WEB WORDT ME TOCH EEN BEETJE TE VEEL! (web is al geladen)",
|
||||||
|
"de": "WARUM KANN DAS NICHT GELADEN WERDEN? (bereits geladen)",
|
||||||
|
"fr": "POURQUOI EST-CE QUE JE PEUX PAS CHARGER TOUT CE WEB? (web déjà chargé)",
|
||||||
|
"it": "PERCHÉ NON POSSO CARICARE TUTTE QUESTO WEB? (web già caricato)"
|
||||||
|
},
|
||||||
|
"already_loaded": {
|
||||||
|
"en": "{moduleName} is already loaded.",
|
||||||
|
"na'vi": "Oel omum teri {moduleName}it li.",
|
||||||
|
"cy": "{moduleName} eisoes yn lwytho",
|
||||||
|
"nl": "{moduleName} is al geladen.",
|
||||||
|
"de": "{moduleName} ist bereits geladen.",
|
||||||
|
"fr": "{moduleName} est déjà chargé.",
|
||||||
|
"it": "{moduleName} già caricato."
|
||||||
|
},
|
||||||
|
"no_version": {
|
||||||
|
"en": "No version information or queried module not loaded.",
|
||||||
|
"cy": "Dim gwybodaeth fersiwn neu modiwl holodd dim yn lwytho",
|
||||||
|
"de": "Keine Informationen verfügbar oder gewünschtes Modul wurde noch nicht geladen.",
|
||||||
|
"fr": "Aucune information de version ou module demandé non chargé.",
|
||||||
|
"it": "Informazione sulla versione non è disponibile o modulo richiesto non ancora caricato"
|
||||||
|
},
|
||||||
|
"status_good": {
|
||||||
|
"en": "{module} status: Shit looks good",
|
||||||
|
"cy": "{module} statws: Cachu yn edrych yn dda",
|
||||||
|
"de": "Sieht gut aus",
|
||||||
|
"fr": "Statut de {module}: Cette merde tourne bien",
|
||||||
|
"it": "Stato di {modulo}: Funky gallo come sono bello stamattina"
|
||||||
|
},
|
||||||
|
"status_bad": {
|
||||||
|
"en": "{module} status: Failed to load: {reason}",
|
||||||
|
"cy": "{module} statws: Methu i lwytho: {reason}",
|
||||||
|
"de": "{module} Status: Konnte nicht geladen werden: {reason}",
|
||||||
|
"fr": "Statut de {module}: échec de chargement : {reason}",
|
||||||
|
"it": "Stato di {module}: Caricamento fallito: {reason}"
|
||||||
|
},
|
||||||
|
"status_unloaded": {
|
||||||
|
"en": "Either that module wasn't on the roster or shit is totally fucked.",
|
||||||
|
"cy": "Naill ai heb fod modiwl oedd ar y rhestr, neu cachu yn gwbl torrodd",
|
||||||
|
"de": "Entweder ist das Modul nicht auf der Liste oder die Kacke ist am dampfen",
|
||||||
|
"fr": "Soit ce module n'est pas sur la liste, soit tout est complètement niqué",
|
||||||
|
"it": "O questo modulo non è sulla lista, o sono cazzi amari"
|
||||||
|
},
|
||||||
|
"load_failed": {
|
||||||
|
"en": "Failed to load {module}. See 'status {module}'.",
|
||||||
|
"cy": "Methu i lwytho {module}. Gwelwch 'status {module}'.",
|
||||||
|
"de": "Konnte {module} nicht laden. Siehe 'status {module}'.",
|
||||||
|
"fr": "Echec du chargement de {module}. Voir 'status {module}'.",
|
||||||
|
"it": "Caricamento di {module} non riuscito. Vedi 'stato {module}'."
|
||||||
|
},
|
||||||
|
"no_config_key": {
|
||||||
|
"en": "{path} doesn't exist bro",
|
||||||
|
"cy": "{path} cyfluniad yn bodoli, fy mrawd",
|
||||||
|
"de": "{path} existiert nicht, Bruder",
|
||||||
|
"fr": "{path} n'existe pas, fréro",
|
||||||
|
"it": "{path} non esiste, fratello"
|
||||||
|
},
|
||||||
|
"config_array": {
|
||||||
|
"en": "Config option is an array. Try '{alternate}'.",
|
||||||
|
"cy": "Opsiwn cyfluniad ydy'r amrywiaeth. Rhowch gynnig ar '{alternate}'.",
|
||||||
|
"de": "Einstellung ist ein Array, probiere '{alternate}' aus.",
|
||||||
|
"fr": "L'option de configuration est un array. Essaye '{alternate}'.",
|
||||||
|
"it": "L'opzione di configurazione è un array. Prova '{alternate}'."
|
||||||
|
},
|
||||||
|
"config_lock": {
|
||||||
|
"en": "This config option cannot be altered while the bot is running.",
|
||||||
|
"cy": "Ni all yr opsiwn cyfluniad yn cael ei newid tra bod y bot yn rhedeg.",
|
||||||
|
"de": "Diese Option kann während der Benutzung des Bots nicht verändert werden",
|
||||||
|
"fr": "Cette option de configuration ne peut pas être changée pendant que le bot est activé.",
|
||||||
|
"it": "Questa opzione di configurazione non può essere alterata mentre il bot è attivo."
|
||||||
|
},
|
||||||
|
"no_config_path": {
|
||||||
|
"en": "Config path doesn't exist bro",
|
||||||
|
"cy": "Nid yw llwybr cyfluniad yn bodoli, fy mrawd",
|
||||||
|
"de": "Konfigurationspfad nicht vorhanden, Bruder",
|
||||||
|
"fr": "Le chemin de configuration n'existe pas, fréro",
|
||||||
|
"it": "Percorso di configurazione non esiste, fratello"
|
||||||
|
},
|
||||||
|
"new_config_key": {
|
||||||
|
"en": "Warning: Creating new config key: {key}.",
|
||||||
|
"fr": "Attention : création d'une nouvelle clé de configuration : {key}.",
|
||||||
|
"it": "Attenzione : Creazione di una nuova chiave di configurazione: {key}.",
|
||||||
|
"de": "Achtung: Neuer Konfigurationsschlüssel erstellt: {key}."
|
||||||
|
},
|
||||||
|
"config_keys_location": {
|
||||||
|
"en": "Config keys in {path}: {value}",
|
||||||
|
"cy": "Allweddi cyfluniad yn {path}: {value}",
|
||||||
|
"de": "Die Konfiguration in {path}: {value}",
|
||||||
|
"fr": "Clés de configuration dans {path}: {value}",
|
||||||
|
"it": "Chiave di configurazione in {path}: {value}"
|
||||||
|
},
|
||||||
|
"modules_saved": {
|
||||||
|
"en": "Currently loaded modules now default: {modules}",
|
||||||
|
"fr": "Les modules actuellement chargés sont maintenant chargés par défaut : {modules}",
|
||||||
|
"it": "I moduli attualmente caricati sono adesso predefiniti: {modules}",
|
||||||
|
"de": "Die derzeit geladenen Module sind nun der Standart: {modules}"
|
||||||
|
}
|
||||||
|
}
|
38
modules-stock/announce/announce.js
Normal file
38
modules-stock/announce/announce.js
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/**
|
||||||
|
* Name: Announce
|
||||||
|
* Description: Announce things every now and again
|
||||||
|
*/
|
||||||
|
var _ = require('underscore')._;
|
||||||
|
|
||||||
|
var announce = function(dbot) {
|
||||||
|
this.announces = dbot.config.modules.announce.announces;
|
||||||
|
this.lineCount = 0;
|
||||||
|
this.lastAnnounce = {};
|
||||||
|
_.each(dbot.config.servers, function(v, k) {
|
||||||
|
this.lastAnnounce[k] = {};
|
||||||
|
_.each(this.announces[k], function(announce, channel) {
|
||||||
|
this.lastAnnounce[k][channel] = announce.distance;
|
||||||
|
}, this)
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
this.listener = function(event) {
|
||||||
|
if(_.has(this.lastAnnounce[event.server], event.channel)) {
|
||||||
|
this.lastAnnounce[event.server][event.channel]--;
|
||||||
|
if(this.lastAnnounce[event.server][event.channel] == 0) {
|
||||||
|
var announce = this.config.announces[event.server][event.channel];
|
||||||
|
this.lastAnnounce[event.server][event.channel] = announce.distance;
|
||||||
|
|
||||||
|
dbot.api.quotes.getQuote(announce.category, function(quote) {
|
||||||
|
if(quote) {
|
||||||
|
dbot.say(event.server, event.channel, quote);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.bind(this);
|
||||||
|
this.on = 'PRIVMSG';
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.fetch = function(dbot) {
|
||||||
|
return new announce(dbot);
|
||||||
|
};
|
10
modules-stock/announce/config.json
Normal file
10
modules-stock/announce/config.json
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"announces": {
|
||||||
|
"aberwiki": {
|
||||||
|
"#test": {
|
||||||
|
"category": "test",
|
||||||
|
"distance": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
45
modules-stock/api/README.md
Normal file
45
modules-stock/api/README.md
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
## API
|
||||||
|
|
||||||
|
Creates external REST APIs for module API functions.
|
||||||
|
|
||||||
|
### Description
|
||||||
|
|
||||||
|
This module uses the web module to expose module API functionality externally
|
||||||
|
through a REST API. As it stands, it's only really useful for viewing various
|
||||||
|
information returned by API functions, as there is no system for API keys or
|
||||||
|
anything like that to protect against misuse of functionality which modifies
|
||||||
|
data.
|
||||||
|
|
||||||
|
To externalise an API function, two properties must be set on a particular API
|
||||||
|
function, like so:
|
||||||
|
|
||||||
|
api['resolveUser'].external = true;
|
||||||
|
api['resolveUser'].extMap = [ 'server', 'nick', 'callback' ];
|
||||||
|
|
||||||
|
The first, 'external' flag simply lets the API module know that this function is
|
||||||
|
intended to be exposed externally - and functions will always be considered not
|
||||||
|
to be externally available unless this flag is explicitly set.
|
||||||
|
|
||||||
|
The second is a mapping of parameters to the module. This should match the
|
||||||
|
function prototype given when the function is declared (unfortunately these
|
||||||
|
can't be mapped automatically because the closure use means we get 'native code'
|
||||||
|
returned and can't scan the function headers for the parameter names).
|
||||||
|
|
||||||
|
Then, to access this function remotely we can simply make a GET request to the
|
||||||
|
web counterpart to the internal API function path. So, internally you'd access
|
||||||
|
the resolveUser function at _dbot.api.users.resolveUser_, we can get to it
|
||||||
|
externally with _/api/users/resolveUser_ - supplying parameters as they are
|
||||||
|
named in the extMap.
|
||||||
|
|
||||||
|
The response to the API call will be given in the form of JSON:
|
||||||
|
|
||||||
|
{
|
||||||
|
err: Error, such as 'API function not enabled for external access'
|
||||||
|
data: API call response
|
||||||
|
}
|
||||||
|
|
||||||
|
If there is a _callback_ parameter named in the extMap, then the API module
|
||||||
|
automatically hijacks this parameter and uses the data it's called with to
|
||||||
|
supply the response to the API call with data. If there is no callback
|
||||||
|
parameter, then it's a blocking API request and the response will be the return
|
||||||
|
value of the call.
|
73
modules-stock/api/api.js
Normal file
73
modules-stock/api/api.js
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
/**
|
||||||
|
* Name: API
|
||||||
|
* Description: Expose DBot API functionality with a REST API
|
||||||
|
*/
|
||||||
|
var _ = require('underscore')._;
|
||||||
|
|
||||||
|
var api = function(dbot) {
|
||||||
|
this.onLoad = function() {
|
||||||
|
dbot.modules.web.app.get('/api', function(req, res) {
|
||||||
|
var externalApi = {};
|
||||||
|
_.each(dbot.api, function(moduleApi, moduleName) {
|
||||||
|
externalApi[moduleName] = {};
|
||||||
|
_.each(moduleApi, function(method, methodName) {
|
||||||
|
if(method.external == true) {
|
||||||
|
externalApi[moduleName][methodName] = method.extMap;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
res.render('api/api', { 'name': dbot.config.name, 'api': externalApi });
|
||||||
|
});
|
||||||
|
|
||||||
|
dbot.modules.web.app.get('/api/:module/:method', function(req, res) {
|
||||||
|
var module = req.params.module,
|
||||||
|
method = req.params.method,
|
||||||
|
reqArgs = req.query,
|
||||||
|
body = { 'err': null, 'data': null };
|
||||||
|
|
||||||
|
if(!_.has(dbot.api, module)) {
|
||||||
|
body.err = 'No such API module';
|
||||||
|
} else if(!_.has(dbot.api[module], method)) {
|
||||||
|
body.err = 'No such API function in ' + module;
|
||||||
|
} else if(dbot.api[module][method].external !== true) {
|
||||||
|
body.err = 'API function ' + module + '.' + method +
|
||||||
|
' not enabled for external access';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!body.err) {
|
||||||
|
var func = dbot.api[module][method],
|
||||||
|
paramNames = func.extMap,
|
||||||
|
args = [];
|
||||||
|
|
||||||
|
_.each(reqArgs, function(arg, name) {
|
||||||
|
var callbackIndex = paramNames.indexOf(name);
|
||||||
|
if(callbackIndex != -1) {
|
||||||
|
args[callbackIndex] = decodeURIComponent(arg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var callbackIndex = paramNames.indexOf('callback');
|
||||||
|
if(callbackIndex != -1) {
|
||||||
|
args[callbackIndex] = function() {
|
||||||
|
body.data = Array.prototype.slice.call(arguments, 0);
|
||||||
|
if(_.isObject(body.data[0]) && _.has(body.data[0], 'err')) {
|
||||||
|
body.err = body.data[0].err;
|
||||||
|
}
|
||||||
|
res.json(body);
|
||||||
|
};
|
||||||
|
func.apply(null, args);
|
||||||
|
} else {
|
||||||
|
body.data = func.apply(null, args);
|
||||||
|
res.json(body);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
res.json(body);
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
}.bind(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.fetch = function(dbot) {
|
||||||
|
return new api(dbot);
|
||||||
|
};
|
16
modules-stock/april/april.js
Normal file
16
modules-stock/april/april.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
var april = function(dbot) {
|
||||||
|
this.listener = function(event) {
|
||||||
|
var match = event.message.match(/^i'?( a)?m (an? )?([^ ]+)/i);
|
||||||
|
if(match) {
|
||||||
|
dbot.say(event.server, 'operserv', 'svsnick ' + event.user + ' ' + match[3]);
|
||||||
|
setTimeout(function() {
|
||||||
|
event.reply('Hi ' + match[3] + ', I\'m ' + dbot.config.name + '!');
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.on = 'PRIVMSG';
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.fetch = function(dbot) {
|
||||||
|
return new april(dbot);
|
||||||
|
};
|
157
modules-stock/atheme/atheme.js
Normal file
157
modules-stock/atheme/atheme.js
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
/**
|
||||||
|
* Module Name: atheme
|
||||||
|
* Description: atheme mode references & retrieve channel flags
|
||||||
|
*/
|
||||||
|
var _ = require('underscore')._,
|
||||||
|
async = require('async');
|
||||||
|
|
||||||
|
var atheme = function(dbot) {
|
||||||
|
this.flagStack = {};
|
||||||
|
this.hostStack = {};
|
||||||
|
|
||||||
|
this.api = {
|
||||||
|
'getChannelFlags': function(server, channel, callback) {
|
||||||
|
if(!_.has(this.flagStack, server)) this.flagStack[server] = {};
|
||||||
|
if(_.has(this.flagStack[server], channel)) { // Already an active flag call
|
||||||
|
this.flagStack[server][channel].callbacks.push(callback);
|
||||||
|
} else {
|
||||||
|
this.flagStack[server][channel] = {
|
||||||
|
'flags': {},
|
||||||
|
'callbacks': [ callback ],
|
||||||
|
'timeout': null,
|
||||||
|
'working': false
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
dbot.say(server, 'chanserv', 'FLAGS ' + channel);
|
||||||
|
this.flagStack[server][channel].timeout = setTimeout(function() { // Delete callback if no response
|
||||||
|
if(_.has(this.flagStack[server], channel) && this.flagStack[server][channel].working == false) {
|
||||||
|
_.each(this.flagStack[server][channel].callbacks, function(callback) {
|
||||||
|
callback(true, null);
|
||||||
|
});
|
||||||
|
delete this.flagStack[server][channel];
|
||||||
|
}
|
||||||
|
}.bind(this), 20000);
|
||||||
|
},
|
||||||
|
|
||||||
|
'getVHosts': function(server, mask, callback) {
|
||||||
|
if(!_.has(this.hostStack, server)) this.hostStack[server] = {};
|
||||||
|
if(_.has(this.hostStack[server], mask)) { // Already an active host call
|
||||||
|
this.hostStack[server][channel].callbacks.push(callback);
|
||||||
|
} else {
|
||||||
|
this.hostStack[server][mask] = {
|
||||||
|
'users': [],
|
||||||
|
'callbacks': [ callback ],
|
||||||
|
'timeout': null
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
dbot.say(server, 'hostserv', 'LISTVHOST ' + mask);
|
||||||
|
this.hostStack[server][mask].timeout = setTimeout(function() { // Delete callback if no response
|
||||||
|
if(_.has(this.hostStack[server], mask)) {
|
||||||
|
_.each(this.hostStack[server][mask].callbacks, function(callback) {
|
||||||
|
callback(true, null);
|
||||||
|
});
|
||||||
|
delete this.hostStack[server][mask];
|
||||||
|
}
|
||||||
|
}.bind(this), 5000);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.commands = {
|
||||||
|
'~chanserv': function(event) {
|
||||||
|
if(_.has(this.config.chanserv, event.input[1])) {
|
||||||
|
event.reply('ChanServ flag ' + event.input[1] + ': ' + this.config.chanserv[event.input[1]]);
|
||||||
|
} else {
|
||||||
|
event.reply('I don\'t know anything about ' + event.input[1]);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
'~chanmode': function(event) {
|
||||||
|
if(_.has(this.config.chanmodes, event.input[1])) {
|
||||||
|
event.reply('Channel Mode ' + event.input[1] + ': ' + this.config.chanmodes[event.input[1]]);
|
||||||
|
} else {
|
||||||
|
event.reply('I don\'t know anything about ' + event.input[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.commands['~chanserv'].regex = [/^chanserv (\+.)/, 2];
|
||||||
|
this.commands['~chanmode'].regex = [/^chanmode (\+.)/, 2];
|
||||||
|
|
||||||
|
this.listener = function(event) {
|
||||||
|
if(event.action === 'NOTICE') {
|
||||||
|
if(event.user === 'ChanServ') {
|
||||||
|
var flags = event.params.match(/(\d+)\s+([^ ]+)\s+(\+\w+)\s+\((\#[\w\.]+)\)/),
|
||||||
|
end = event.params.match(/end of \u0002(\#[\w\.]+)\u0002 flags listing/i);
|
||||||
|
|
||||||
|
if(flags && _.has(this.flagStack[event.server], flags[4])) {
|
||||||
|
this.flagStack[event.server][flags[4]].flags[flags[2]] = flags[3];
|
||||||
|
} else if(end) {
|
||||||
|
if(_.has(this.flagStack[event.server], end[1])) {
|
||||||
|
this.flagStack[event.server][end[1]].working = true;
|
||||||
|
// Parse wildcard hostmasks to nicks
|
||||||
|
var allFlags = this.flagStack[event.server][end[1]].flags,
|
||||||
|
hostMasks = {};
|
||||||
|
|
||||||
|
_.each(allFlags, function(f, u) { // TODO: combine to one loop
|
||||||
|
if(u.indexOf('*!*@') !== -1) {
|
||||||
|
hostMasks[u] = f;
|
||||||
|
delete allFlags[u];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
async.each(_.keys(hostMasks), function(hostMask, done) {
|
||||||
|
this.api.getVHosts(event.server, hostMask.split('@')[1], function(err, users) {
|
||||||
|
_.each(users, function(user) {
|
||||||
|
allFlags[user] = hostMasks[hostMask];
|
||||||
|
});
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
}.bind(this), function() {
|
||||||
|
_.each(this.flagStack[event.server][end[1]].callbacks, function(callback) {
|
||||||
|
callback(null, this.flagStack[event.server][end[1]].flags);
|
||||||
|
}.bind(this));
|
||||||
|
clearTimeout(this.flagStack[event.server][end[1]].timeout);
|
||||||
|
delete this.flagStack[event.server][end[1]];
|
||||||
|
}.bind(this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if(event.user === 'HostServ') {
|
||||||
|
_.each(this.hostStack[event.server], function(el, mask) {
|
||||||
|
if(event.params.match(mask)) {
|
||||||
|
var user = event.params.match(/- ([^ ]+)/),
|
||||||
|
end = event.params.match(/matches for pattern/);
|
||||||
|
|
||||||
|
if(user) {
|
||||||
|
this.hostStack[event.server][mask].users.push(user[1]);
|
||||||
|
} else if(end) {
|
||||||
|
_.each(this.hostStack[event.server][mask].callbacks, function(callback) {
|
||||||
|
callback(null, this.hostStack[event.server][mask].users);
|
||||||
|
}, this);
|
||||||
|
clearTimeout(this.hostStack[event.server][mask].timeout);
|
||||||
|
delete this.hostStack[event.server][mask];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
|
} else { // PRIVMSG
|
||||||
|
console.log(event.message);
|
||||||
|
var akill = event.message.match(/([^ ]+) AKILL:ADD: ([^ ]+) \(reason: (.+)(\) )\(duration: ([^,)]+)/);
|
||||||
|
if(event.channel == '#services' && akill) {
|
||||||
|
console.log(akill);
|
||||||
|
var channel = dbot.config.servers[event.server].admin_channel;
|
||||||
|
dbot.api.users.getUser(akill[1] + '.' + event.server, function(err, user) {
|
||||||
|
dbot.api.report.notify('ban', 'tripsit', user, channel, dbot.t('akill', {
|
||||||
|
'host': akill[2],
|
||||||
|
'reason': akill[3],
|
||||||
|
'duration': akill[5]
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.bind(this);
|
||||||
|
this.on = ['NOTICE', 'PRIVMSG'];
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.fetch = function(dbot) {
|
||||||
|
return new atheme(dbot);
|
||||||
|
};
|
50
modules-stock/atheme/config.json
Normal file
50
modules-stock/atheme/config.json
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
{
|
||||||
|
"chanserv": {
|
||||||
|
"+v": "Enables use of the voice/devoice commands.",
|
||||||
|
"+V": "Enables automatic voice.",
|
||||||
|
"+h": "Enables use of the halfop/dehalfop commands.",
|
||||||
|
"+H": "Enables automatic halfop.",
|
||||||
|
"+o": "Enables use of the op/deop commands.",
|
||||||
|
"+O": "Enables automatic op.",
|
||||||
|
"+a": "Enables use of the protect/deprotect commands.",
|
||||||
|
"+q": "Enables use of the owner/deowner commands.",
|
||||||
|
"+s": "Enables use of the set command.",
|
||||||
|
"+i": "Enables use of the invite and getkey commands.",
|
||||||
|
"+r": "Enables use of the kick, kickban, ban and unban commands.",
|
||||||
|
"+r": "Enables use of the ban and unban commands.",
|
||||||
|
"+r": "Enables use of the unban command.",
|
||||||
|
"+R": "Enables use of the recover and clear commands.",
|
||||||
|
"+f": "Enables modification of channel access lists.",
|
||||||
|
"+t": "Enables use of the topic and topicappend commands.",
|
||||||
|
"+A": "Enables viewing of channel access lists.",
|
||||||
|
"+S": "Marks the user as a successor.",
|
||||||
|
"+F": "Grants full founder access.",
|
||||||
|
"+b": "Enables automatic kickban."
|
||||||
|
},
|
||||||
|
"chanmodes": {
|
||||||
|
"+b": "channel ban",
|
||||||
|
"+c": "colour filter",
|
||||||
|
"+e": "ban exemption",
|
||||||
|
"+f": "channel forwarding",
|
||||||
|
"+F": "allow anybody to forward to this",
|
||||||
|
"+g": "allow anybody to invite",
|
||||||
|
"+i": "invite only",
|
||||||
|
"+I": "invite exception (invex)",
|
||||||
|
"+j": "join throttling",
|
||||||
|
"+k": "key (channel password)",
|
||||||
|
"+l": "channel member limit",
|
||||||
|
"+L": "large ban list",
|
||||||
|
"+m": "moderated",
|
||||||
|
"+n": "no external messages",
|
||||||
|
"+o": "channel operator",
|
||||||
|
"+p": "paranoid channel",
|
||||||
|
"+P": "permanent channel",
|
||||||
|
"+q": "quiet",
|
||||||
|
"+Q": "block forwarded users",
|
||||||
|
"+r": "block unidentified",
|
||||||
|
"+s": "secret channel",
|
||||||
|
"+t": "topic limit",
|
||||||
|
"+v": "voice",
|
||||||
|
"+z": "reduced moderation"
|
||||||
|
}
|
||||||
|
}
|
5
modules-stock/atheme/strings.json
Normal file
5
modules-stock/atheme/strings.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"akill": {
|
||||||
|
"en": "{host} has been AKilled for {duration} due to \"{reason}\""
|
||||||
|
}
|
||||||
|
}
|
78
modules-stock/command/README.md
Normal file
78
modules-stock/command/README.md
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
## Command
|
||||||
|
|
||||||
|
Handles the command execution logic for DBot.
|
||||||
|
|
||||||
|
### Description
|
||||||
|
|
||||||
|
Command flow:
|
||||||
|
|
||||||
|
1. Does the input match a command key in the loaded commands?
|
||||||
|
* If command not found and quotes is loaded, attempt to print quote of given
|
||||||
|
command name
|
||||||
|
2. Is the user banned from running the given command?
|
||||||
|
3. Is the user ignoring the command?
|
||||||
|
4. Is the channel ignoring the command?
|
||||||
|
5. Does the use have the access level to run the command?
|
||||||
|
6. Is the command set as disabled?
|
||||||
|
7. Apply regex to the command, pass into event object.
|
||||||
|
* If regex does not apply, show usage info.
|
||||||
|
8. Run the command.
|
||||||
|
|
||||||
|
This is the only module which is force loaded, even if it's not specified in
|
||||||
|
the configuration file.
|
||||||
|
|
||||||
|
### Config
|
||||||
|
|
||||||
|
#### useNickserv: false
|
||||||
|
Use the nickserv module to ensure a user is logged into their account before
|
||||||
|
running any elevated commands. Note you will still have to load and configure
|
||||||
|
the nickserv module yourself.
|
||||||
|
|
||||||
|
#### accessOutput: false
|
||||||
|
Show a message to a user if they attempt to run a command they don't have the
|
||||||
|
access level for.
|
||||||
|
|
||||||
|
### Commands
|
||||||
|
|
||||||
|
#### ~usage [command]
|
||||||
|
Show usage information for a given command.
|
||||||
|
|
||||||
|
#### ~help [command|module]
|
||||||
|
Link module help for a module given either the module name or the name of a
|
||||||
|
command belonging to a module.
|
||||||
|
|
||||||
|
### API
|
||||||
|
|
||||||
|
#### isBanned(user, command)
|
||||||
|
Return whether a user is currently banned from a given commands.
|
||||||
|
|
||||||
|
#### hasAccess(user, command)
|
||||||
|
Return whether a user has the access level (moderator, admin) to run a given
|
||||||
|
command.
|
||||||
|
|
||||||
|
#### isIgnoring(user, command)
|
||||||
|
Return whether a user is currently marked as ignoring a given command.
|
||||||
|
|
||||||
|
#### addHook(command, callback)
|
||||||
|
This API function allows you to hook functions into DBot commands. For example,
|
||||||
|
you may add a hook to post on Identica when a new quote is added to the database
|
||||||
|
with the ~qadd command. As a less useful example, here is how you might add a
|
||||||
|
hook to log to the console every time someone uses the reload command:
|
||||||
|
|
||||||
|
dbot.api.command.addHook('reload', function() {
|
||||||
|
console.log('Reload run!');
|
||||||
|
});
|
||||||
|
|
||||||
|
Hook arguments are populated by the return values of the functions they are
|
||||||
|
hooked into, and command hooks are not run if the command explicitly returns
|
||||||
|
'false.' For example, the ~qadd command returns *[ key, quote ]*, and the hook
|
||||||
|
function will be called with these variables given in the order they were
|
||||||
|
returned, so you would retrieve the key and the quote from a hook to ~qadd like
|
||||||
|
this:
|
||||||
|
|
||||||
|
dbot.api.command.addHook('~qadd', function(key, quote) { ...
|
||||||
|
|
||||||
|
The best place to add hooks to commands is in the 'onLoad' function of your
|
||||||
|
module, as this ensures it will be run while all other modules are loaded. If
|
||||||
|
the target command does not exist (for example if its module was not loaded),
|
||||||
|
the hook will not be added and no errors will be thrown.
|
73
modules-stock/command/api.js
Normal file
73
modules-stock/command/api.js
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
var _ = require('underscore')._;
|
||||||
|
|
||||||
|
var api = function(dbot) {
|
||||||
|
return {
|
||||||
|
/**
|
||||||
|
* Does the user have the correct access level to use the command?
|
||||||
|
*/
|
||||||
|
'hasAccess': function(event, command, callback) {
|
||||||
|
var accessNeeded = dbot.commands[command].access,
|
||||||
|
allowedNicks,
|
||||||
|
user = event.rUser;
|
||||||
|
|
||||||
|
if(_.isUndefined(accessNeeded) || accessNeeded == null) {
|
||||||
|
return callback(true);
|
||||||
|
} else if(!_.isFunction(accessNeeded)) {
|
||||||
|
if(_.has(dbot.access, accessNeeded)) {
|
||||||
|
accessNeeded = dbot.access[accessNeeded];
|
||||||
|
} else {
|
||||||
|
return callback(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
allowedNicks = accessNeeded(event);
|
||||||
|
|
||||||
|
if(!_.include(allowedNicks, user.primaryNick) && !_.include(allowedNicks, user.currentNick)) {
|
||||||
|
callback(false);
|
||||||
|
} else {
|
||||||
|
if(_.has(dbot.modules, 'nickserv') && this.config.useNickserv == true) {
|
||||||
|
dbot.api.nickserv.auth(user.server, user.currentNick, function(result, primary) {
|
||||||
|
if(result == true && primary == user.primaryNick) {
|
||||||
|
callback(true);
|
||||||
|
} else {
|
||||||
|
callback(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
callback(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply Regex to event message, store result. Return false if it doesn't
|
||||||
|
* apply.
|
||||||
|
*/
|
||||||
|
'applyRegex': function(commandName, event) {
|
||||||
|
var applies = false;
|
||||||
|
event.message = event.message.substring(1);
|
||||||
|
if(_.has(dbot.commands[commandName], 'regex')) {
|
||||||
|
var cRegex = dbot.commands[commandName].regex;
|
||||||
|
if(_.isArray(cRegex) && cRegex.length === 2) {
|
||||||
|
var q = event.message.valMatch(cRegex[0], cRegex[1]);
|
||||||
|
if(q) {
|
||||||
|
applies = true;
|
||||||
|
event.input = q;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var q = event.message.match(cRegex);
|
||||||
|
if(q) {
|
||||||
|
applies = true;
|
||||||
|
event.input = q;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
applies = true;
|
||||||
|
}
|
||||||
|
return applies;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.fetch = function(dbot) {
|
||||||
|
return api(dbot);
|
||||||
|
};
|
163
modules-stock/command/command.js
Normal file
163
modules-stock/command/command.js
Normal file
@ -0,0 +1,163 @@
|
|||||||
|
/**
|
||||||
|
* Module Name: Command
|
||||||
|
* Description: An essential module which maps PRIVMSG input to an appropriate
|
||||||
|
* command and then runs that command, given the user isn't banned from or
|
||||||
|
* ignoring that command.
|
||||||
|
*/
|
||||||
|
var _ = require('underscore')._,
|
||||||
|
cDomain = require('domain').create();
|
||||||
|
|
||||||
|
var command = function(dbot) {
|
||||||
|
/**
|
||||||
|
* Run the appropriate command given the input.
|
||||||
|
*/
|
||||||
|
this.listener = function(event) {
|
||||||
|
var commandName = event.params[0];
|
||||||
|
if(commandName.charAt(0) != this.config.commandPrefix || this.config.passiveMode == true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
commandName = commandName.substring(1);
|
||||||
|
|
||||||
|
this.api.hasAccess(event, commandName, function(hasAccess) {
|
||||||
|
dbot.api.ignore.isUserIgnoring(event.rUser, commandName, function(isIgnoring) {
|
||||||
|
dbot.api.ignore.isUserBanned(event.rUser, commandName, function(isBanned) {
|
||||||
|
|
||||||
|
if(isBanned) {
|
||||||
|
if(this.config.banOutput && commandName != this.config.commandPrefix) {
|
||||||
|
event.reply(dbot.t('command_ban', {'user': event.user}));
|
||||||
|
}
|
||||||
|
} else if(!hasAccess) {
|
||||||
|
if(this.config.accessOutput) {
|
||||||
|
event.reply(dbot.t('access_denied', { 'user': event.user }));
|
||||||
|
}
|
||||||
|
} else if(!isIgnoring && _.has(dbot.commands, commandName) && !dbot.commands[commandName].disabled) {
|
||||||
|
if(!_.has(dbot.commands, commandName)) {
|
||||||
|
if(_.has(dbot.modules, 'quotes')) {
|
||||||
|
var key = event.message.substring(1);
|
||||||
|
dbot.api.quotes.getInterpolatedQuote(event.server,
|
||||||
|
event.channel.name, event.user, key, function(quote) {
|
||||||
|
if(quote) {
|
||||||
|
event.reply(key + ': ' + quote);
|
||||||
|
} else if(_.has(dbot.modules, 'spelling')) {
|
||||||
|
var commands = _.keys(dbot.commands),
|
||||||
|
winner = false,
|
||||||
|
closestMatch = Infinity;
|
||||||
|
|
||||||
|
_.each(commands, function(command) {
|
||||||
|
var distance = dbot.api.spelling.distance(commandName, command);
|
||||||
|
if(distance < closestMatch) {
|
||||||
|
closestMatch = distance;
|
||||||
|
winner = command;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if(closestMatch < 1) {
|
||||||
|
event.reply(commandName + ' not found. Did you mean ' + winner + '?');
|
||||||
|
return;
|
||||||
|
} else if(_.has(dbot.modules, 'quotes')) {
|
||||||
|
dbot.api.link.udLookup(key, function(word, definition) {
|
||||||
|
if(word) {
|
||||||
|
event.reply(key + '[UD]: ' + definition);
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t('category_not_found', { 'category': key }));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.api.applyRegex(commandName, event)) {
|
||||||
|
try {
|
||||||
|
cDomain.run(function() {
|
||||||
|
var command = dbot.commands[commandName],
|
||||||
|
results;
|
||||||
|
if(_.has(command, 'resolver')) {
|
||||||
|
event.res = [];
|
||||||
|
command.resolver(event, function(err) {
|
||||||
|
if(!err) {
|
||||||
|
results = command.apply(dbot.modules[command.module], [event]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
results = command.apply(dbot.modules[command.module], [event]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch(err) {
|
||||||
|
if(dbot.config.debugMode == true) {
|
||||||
|
var stack = err.stack.split('\n').slice(1, dbot.config.debugLevel + 1);
|
||||||
|
|
||||||
|
event.reply('- Error in ' + commandName + ':');
|
||||||
|
event.reply('- Message: ' + err);
|
||||||
|
|
||||||
|
_.each(stack, function(stackLine, index) {
|
||||||
|
event.reply('- Stack[' + index + ']: ' +
|
||||||
|
stackLine.trim());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!_.include(['reload', 'load', 'unload', 'setconfig'], commandName)) dbot.api.event.emit('command', [ event ]);
|
||||||
|
} else {
|
||||||
|
if(commandName !== this.config.commandPrefix) {
|
||||||
|
if(_.has(dbot.usage, commandName)) {
|
||||||
|
event.reply('Usage: ' + dbot.usage[commandName]);
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t('syntax_error'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
}.bind(this));
|
||||||
|
}.bind(this));
|
||||||
|
}.bind(this);
|
||||||
|
this.on = 'PRIVMSG';
|
||||||
|
|
||||||
|
this.onLoad = function() {
|
||||||
|
// Not sure this is the right place for this. Perhaps they should be in
|
||||||
|
// another file?
|
||||||
|
|
||||||
|
cDomain.on('error', function(err) {
|
||||||
|
console.log(err); // Hmm
|
||||||
|
if(_.has(dbot.modules, 'log')) {
|
||||||
|
// can't really get context
|
||||||
|
var server = _.keys(dbot.config.servers)[0];
|
||||||
|
dbot.api.log.log(server, dbot.config.name, '[\u00034ERR\u000f] ' + err.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
dbot.access = {
|
||||||
|
'admin': function(event) {
|
||||||
|
return dbot.config.admins;
|
||||||
|
},
|
||||||
|
|
||||||
|
'moderator': function(event) {
|
||||||
|
return [].concat(dbot.access.admin(event), dbot.config.moderators);
|
||||||
|
},
|
||||||
|
|
||||||
|
'power_user': function(event) {
|
||||||
|
return [].concat(dbot.access.admin(event), dbot.access.moderator(event), dbot.config.power_users);
|
||||||
|
},
|
||||||
|
|
||||||
|
'voice': function(event) {
|
||||||
|
return [].concat(dbot.access.admin(event), dbot.access.moderator(event), dbot.access.power_user(event),
|
||||||
|
_.chain(event.channel.nicks)
|
||||||
|
.filter(function(nick) {
|
||||||
|
return nick.op == true || nick.voice == true;
|
||||||
|
})
|
||||||
|
.pluck('name')
|
||||||
|
.value());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}.bind(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.fetch = function(dbot) {
|
||||||
|
return new command(dbot);
|
||||||
|
};
|
70
modules-stock/command/commands.js
Normal file
70
modules-stock/command/commands.js
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
var _ = require('underscore')._,
|
||||||
|
request = require('request');
|
||||||
|
|
||||||
|
var commands = function(dbot) {
|
||||||
|
var commands = {
|
||||||
|
'usage': function(event) {
|
||||||
|
var commandName = event.params[1];
|
||||||
|
if(_.has(dbot.usage, commandName)) {
|
||||||
|
event.reply(dbot.t('usage', {
|
||||||
|
'command': commandName,
|
||||||
|
'usage': dbot.usage[commandName]
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t('no_usage_info', {
|
||||||
|
'command': commandName
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
'~commands': function(event) {
|
||||||
|
var name = event.params[1];
|
||||||
|
if(_.has(dbot.modules, name)) {
|
||||||
|
var commands = _.keys(dbot.commands);
|
||||||
|
commands = _.filter(commands, function(cName) {
|
||||||
|
return dbot.commands[cName].module == name;
|
||||||
|
});
|
||||||
|
event.reply(dbot.t('module_commands', {
|
||||||
|
'module': name,
|
||||||
|
'commands': commands.join(', ')
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t('loaded_modules', {
|
||||||
|
'modules': _.keys(dbot.modules).join(', ')
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
'~help': function(event) {
|
||||||
|
var moduleName = event.params[1];
|
||||||
|
if(!moduleName || !_.has(dbot.modules, moduleName)) {
|
||||||
|
event.reply(dbot.t('usage', {
|
||||||
|
'command': this.config.commandPrefix + 'help',
|
||||||
|
'usage': this.config.commandPrefix + 'help [module]'
|
||||||
|
}));
|
||||||
|
event.reply(dbot.t('loaded_modules', {
|
||||||
|
'modules': _.keys(dbot.modules).join(', ')
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
var helpLink = dbot.config.repoRoot +
|
||||||
|
'blob/master/modules/' + moduleName + '/README.md';
|
||||||
|
if(dbot.config.modules[moduleName].help) {
|
||||||
|
helpLink = dbot.config.modules[moduleName].help;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Check it exists
|
||||||
|
event.reply(dbot.t('help_link', {
|
||||||
|
'module': moduleName,
|
||||||
|
'link': helpLink
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
commands['usage'].regex = [/usage ([^ ]+)/, 2];
|
||||||
|
|
||||||
|
return commands;
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.fetch = function(dbot) {
|
||||||
|
return commands(dbot);
|
||||||
|
};
|
9
modules-stock/command/config.json
Normal file
9
modules-stock/command/config.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ignorable": false,
|
||||||
|
"dependencies": [ "event", "ignore", "users" ],
|
||||||
|
"useNickserv": false,
|
||||||
|
"accessOutput": false,
|
||||||
|
"banOutput": false,
|
||||||
|
"passiveMode": false,
|
||||||
|
"commandPrefix": "~"
|
||||||
|
}
|
78
modules-stock/command/strings.json
Normal file
78
modules-stock/command/strings.json
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
{
|
||||||
|
"command_ban": {
|
||||||
|
"en": "{user} is banned from using this command. Commence incineration.",
|
||||||
|
"es": "{user} está prohibido de usar esta instrucción. urrently loaded modules now default: {modules}.",
|
||||||
|
"na'vi": "Tsu'ori {user} ke tung. Nga skxawng lu.",
|
||||||
|
"cy": "Mae {user} wedi ei gohurio gan ddefnyddio'r gorchymun yma. Cychwyn orfflosgiad",
|
||||||
|
"nl": "{user} mag dit commando niet meer gebruiken. Bereid het verbrandingsritueel voor.",
|
||||||
|
"de": "{user} darf diesen Befehl nicht benutzen. Verbrennung einleiten",
|
||||||
|
"fr": "{user} est interdit d'utiliser cette commande. Commencer l'incinération.",
|
||||||
|
"it": "A {user} è stato interdetto di utilizzare questo commando. Iniziare incenerimento."
|
||||||
|
},
|
||||||
|
"syntax_error": {
|
||||||
|
"en": "Invalid syntax. Initiate incineration.",
|
||||||
|
"es": "Sintaxis no válida. Iniciar incineración.",
|
||||||
|
"na'vi": "Ngeyä pamrel keyawr lu. Nga skxawng lu.",
|
||||||
|
"cy": "Cystrawen annilys. Cychwyn orfflosgiad",
|
||||||
|
"nl": "Ongeldige syntax. Bereid het verbrandingsritueel voor.",
|
||||||
|
"de": "Syntax ungültig. Verbrennung einleiten",
|
||||||
|
"fr": "Syntaxe invalide. Initier l'incinération.",
|
||||||
|
"it": "Sintassi non valida. Iniziare incenerimento"
|
||||||
|
},
|
||||||
|
"usage": {
|
||||||
|
"en": "Usage for {command}: {usage}.",
|
||||||
|
"na'vi": "Nga tsun sivar ìlä {command}: {usage}.",
|
||||||
|
"cy": "Defnydd o {command}: {usage}.",
|
||||||
|
"nl": "{command} wordt op de volgende manier gebruikt: {usage}.",
|
||||||
|
"de": "Benutzung von {command}: [usage}.",
|
||||||
|
"fr": "Utilisation de {command}: {usage}.",
|
||||||
|
"it": "Utilizzo di {command}: {usage}."
|
||||||
|
},
|
||||||
|
"no_usage_info": {
|
||||||
|
"en": "No usage information found for {command}.",
|
||||||
|
"na'vi": "Oel ke tsun sivar {comamnd}it",
|
||||||
|
"cy": "Ni chanfuwyd gwybodaeth am ddefnydd o {command}",
|
||||||
|
"nl": "Geen gebruiksinformatie gevonden voor {command}.",
|
||||||
|
"de": "Keine Gebrauchsanweisung gefunden für {command}.",
|
||||||
|
"fr": "Aucune information d'utilisation trouvée pour {command}",
|
||||||
|
"it": "Nessuna informazione d' utilizzo trovata per {command}"
|
||||||
|
},
|
||||||
|
"help_link": {
|
||||||
|
"en": "Help for {module}: {link}",
|
||||||
|
"na'vi": "{module}ä srungìl {link} it tok",
|
||||||
|
"cy": "Cymorth am {module}: {link}",
|
||||||
|
"nl": "Hulp voor {module}: {link}",
|
||||||
|
"de": "Hilfe für {module}: {link}",
|
||||||
|
"fr": "Aide pour {module}: {link}",
|
||||||
|
"it": "Aiuto per {module}: {link}"
|
||||||
|
},
|
||||||
|
"no_help": {
|
||||||
|
"en": "No help found for {module}.",
|
||||||
|
"na'vi": "Fì{module}ìri oel ke tsun run srungit",
|
||||||
|
"cy": "Ni chanfuwyd cymorth am {module}",
|
||||||
|
"nl": "Geen hulp gevonden voor {module}.",
|
||||||
|
"de": "Keine Hilfe gefunden für {module}.",
|
||||||
|
"fr": "Aucune aide trouvée pour {module}.",
|
||||||
|
"it": "Nessun aiuto trovato per {module}."
|
||||||
|
},
|
||||||
|
"loaded_modules": {
|
||||||
|
"en": "Loaded modules: {modules}.",
|
||||||
|
"cy": "Modiwlau sy'n lwythodd: {modules}.",
|
||||||
|
"nl": "Geladen modules: {modules}.",
|
||||||
|
"de": "Module geladen: {modules}.",
|
||||||
|
"fr": "Modules chargés: {modules}.",
|
||||||
|
"it": "Moduli caricati: {modules}."
|
||||||
|
},
|
||||||
|
"access_denied": {
|
||||||
|
"en": "{user}: You don't have the access level to run this command.",
|
||||||
|
"fr": "{user}: Vous n'avez pas le niveau d'accès requis pour utiliser cette commande.",
|
||||||
|
"it": "{user}: Non hai il livello d'accesso neccessario per utilizzare questo commando.",
|
||||||
|
"de": "{user}: Du hast nicht die notwendigen Rechte um diesen Befehl zu benutzen."
|
||||||
|
},
|
||||||
|
"module_commands": {
|
||||||
|
"en": "Commands in {module}: {commands}.",
|
||||||
|
"fr": "Commandes de {module}: {commands}.",
|
||||||
|
"it": "Commandi di {module}: {commands}.",
|
||||||
|
"de": "Befehle in {module}: {commands}."
|
||||||
|
}
|
||||||
|
}
|
4
modules-stock/command/usage.json
Normal file
4
modules-stock/command/usage.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"~usage": "~usage [command]",
|
||||||
|
"~help": "~help [module]"
|
||||||
|
}
|
15
modules-stock/crypto/README.md
Normal file
15
modules-stock/crypto/README.md
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
## Crypto
|
||||||
|
|
||||||
|
Cryptography!
|
||||||
|
|
||||||
|
### Description
|
||||||
|
This module calculates different hashes or ciphertexts for some algorithms.
|
||||||
|
|
||||||
|
### Commands
|
||||||
|
|
||||||
|
#### ~hash [algorithm] [text]
|
||||||
|
Calculate the hash of the given text using [algorithm].
|
||||||
|
|
||||||
|
#### ~random [number]
|
||||||
|
Gives [number] bytes of cryptographically strong pseudo-random data as hex string.
|
||||||
|
|
44
modules-stock/crypto/crypto.js
Normal file
44
modules-stock/crypto/crypto.js
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/**
|
||||||
|
* Module Name: Crypto
|
||||||
|
* Description: Allows the magic of cryptography to take place.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var cr = require('crypto');
|
||||||
|
|
||||||
|
var crypto = function(dbot) {
|
||||||
|
this.commands = {
|
||||||
|
'~hash': function(event) {
|
||||||
|
var hash = event.params[1];
|
||||||
|
try {
|
||||||
|
var h = cr.createHash(hash);
|
||||||
|
var tohash = event.params.splice(2, event.params.length-1).join(' ');
|
||||||
|
h.update(tohash);
|
||||||
|
event.reply(hash+" of \""+tohash+"\" is: "+h.digest('hex'));
|
||||||
|
} catch(err) {
|
||||||
|
event.reply(err);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'~randomdata': function(event) {
|
||||||
|
try {
|
||||||
|
var count = parseInt(event.params[1]);
|
||||||
|
if(count > 222) {
|
||||||
|
event.reply("Sorry man, I can't paste that much random data.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cr.randomBytes(count, function(err,buf) {
|
||||||
|
if(err) {
|
||||||
|
event.reply(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
event.reply(buf.toString('hex'));
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
event.reply(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.fetch = function(dbot) {
|
||||||
|
return new crypto(dbot);
|
||||||
|
};
|
6
modules-stock/crypto/usage.json
Normal file
6
modules-stock/crypto/usage.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"~md5": "~md5 [text]",
|
||||||
|
"~sha1": "~sha1 [text]",
|
||||||
|
"~sha256": "~sha256 [text]",
|
||||||
|
"~aes": "~aes \"[text]\" \"[key]\""
|
||||||
|
}
|
3
modules-stock/cspeed/config.json
Normal file
3
modules-stock/cspeed/config.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"outputChannel": "#realitree"
|
||||||
|
}
|
62
modules-stock/cspeed/cspeed.js
Normal file
62
modules-stock/cspeed/cspeed.js
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
var _ = require('underscore')._;
|
||||||
|
|
||||||
|
var cspeed = function(dbot) {
|
||||||
|
this.watches = dbot.db.cspeed;
|
||||||
|
this.outputChannel = dbot.config.modules.cspeed.outputChannel;
|
||||||
|
this.counts = {};
|
||||||
|
|
||||||
|
this.api = {
|
||||||
|
'getCounts': function(callback) {
|
||||||
|
callback(this.counts);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.api['getCounts'].external = true;
|
||||||
|
this.api['getCounts'].extMap = [ 'callback' ];
|
||||||
|
|
||||||
|
this.commands = {
|
||||||
|
'addlpmwatch': function(event) {
|
||||||
|
var channel = event.params[1];
|
||||||
|
var key = event.server + '.' + channel;
|
||||||
|
|
||||||
|
if(!_.has(this.watches, key)) {
|
||||||
|
this.watches[key] = {
|
||||||
|
'server': event.server,
|
||||||
|
'channel': channel
|
||||||
|
}; // to be extended with warn nums etc
|
||||||
|
|
||||||
|
this.counts[key] = 0;
|
||||||
|
dbot.api.timers.addTimer(60000, function() {
|
||||||
|
dbot.say(event.server, this.outputChannel, channel + ' currently : ' + this.counts[key] + ' LPM');
|
||||||
|
this.counts[key] = 0;
|
||||||
|
}.bind(this));
|
||||||
|
|
||||||
|
event.reply('Added speed watch for ' + channel);
|
||||||
|
} else {
|
||||||
|
event.reply('Already watching that channel');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.listener = function(event) {
|
||||||
|
var key = event.server + '.' + event.channel;
|
||||||
|
if(_.has(this.watches, key)) {
|
||||||
|
this.counts[key]++;
|
||||||
|
}
|
||||||
|
}.bind(this);
|
||||||
|
this.on = 'PRIVMSG';
|
||||||
|
|
||||||
|
this.onLoad = function() {
|
||||||
|
var watches = dbot.db.cspeed;
|
||||||
|
_.each(watches, function(watch) {
|
||||||
|
var key = watch.server + '.' + watch.channel;
|
||||||
|
this.counts[key] = 0;
|
||||||
|
dbot.api.timers.addTimer(60000, function() {
|
||||||
|
dbot.say(watch.server, dbot.db.cspeed.outputChannel, watch.channel + ': ' + this.counts[key] + 'LPM');
|
||||||
|
}.bind(this));
|
||||||
|
}.bind(this));
|
||||||
|
}.bind(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.fetch = function(dbot) {
|
||||||
|
return new cspeed(dbot);
|
||||||
|
};
|
5
modules-stock/ctcp/README.md
Normal file
5
modules-stock/ctcp/README.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
## CTCP
|
||||||
|
Responds to CTCP commands.
|
||||||
|
|
||||||
|
## Description
|
||||||
|
At the moment only CTCP VERSION, CTCP PING is handled in JSBot.
|
3
modules-stock/ctcp/config.json
Normal file
3
modules-stock/ctcp/config.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"ignorable": true
|
||||||
|
}
|
39
modules-stock/ctcp/ctcp.js
Normal file
39
modules-stock/ctcp/ctcp.js
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
var ctcp = function(dbot) {
|
||||||
|
this.listener = function(event) {
|
||||||
|
var matches = event.message.match(/\u0001[\w]+\u0001/);
|
||||||
|
if(matches) {
|
||||||
|
// We need the CTCP command
|
||||||
|
var question = matches[0];
|
||||||
|
// Cut \u0001 characters from command
|
||||||
|
question = question.slice(1,question.length-1);
|
||||||
|
switch(question) {
|
||||||
|
case 'CLIENTINFO':
|
||||||
|
event.replyNotice("\u0001CLIENTINFO SOURCE VERSION USERINFO\u0001");
|
||||||
|
break;
|
||||||
|
case 'FINGER':
|
||||||
|
event.replyNotice("\u0001FINGER STOP FINGERING ME BRO\u0001");
|
||||||
|
break;
|
||||||
|
case 'SOURCE':
|
||||||
|
event.replyNotice("\u0001SOURCE "+dbot.config.repoRoot+"\u0001");
|
||||||
|
break;
|
||||||
|
case 'TIME':
|
||||||
|
var d = new Date();
|
||||||
|
event.replyNotice("\u0001TIME "+d.toISOString()+"\u0001");
|
||||||
|
break;
|
||||||
|
case 'USERINFO':
|
||||||
|
event.replyNotice("\u0001USERINFO "+dbot.config.name+"\u0001");
|
||||||
|
break;
|
||||||
|
case 'VERSION':
|
||||||
|
event.replyNotice("\u0001VERSION "+dbot.config.version+"\u0001");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
event.replyNotice("\u0001"+question+" Idk what you want. Try CLIENTINFO.\u0001");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.on = 'PRIVMSG';
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.fetch = function(dbot) {
|
||||||
|
return new ctcp(dbot);
|
||||||
|
};
|
31
modules-stock/dent/README.md
Normal file
31
modules-stock/dent/README.md
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
## Dent
|
||||||
|
|
||||||
|
Post dents.
|
||||||
|
|
||||||
|
### Description
|
||||||
|
|
||||||
|
Allows the posting of dents to Identica. Easily abused for posting status
|
||||||
|
messages to Twitter by linking the Identica account.
|
||||||
|
|
||||||
|
### Commands
|
||||||
|
|
||||||
|
#### ~dent [text]
|
||||||
|
Post the given text to Identica.
|
||||||
|
|
||||||
|
### Configuration
|
||||||
|
|
||||||
|
#### username
|
||||||
|
Identica username to post with.
|
||||||
|
|
||||||
|
#### password
|
||||||
|
Identica password to post with.
|
||||||
|
|
||||||
|
### API
|
||||||
|
|
||||||
|
#### post(content)
|
||||||
|
Post the given content to Identica.
|
||||||
|
|
||||||
|
### Hooks
|
||||||
|
|
||||||
|
#### ~qadd
|
||||||
|
Posts new quote additions.
|
8
modules-stock/dent/config.json
Normal file
8
modules-stock/dent/config.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"username": "youruserhere",
|
||||||
|
"password": "yourpasswordhere",
|
||||||
|
"dependencies": [ "link" ],
|
||||||
|
"ignorable": true,
|
||||||
|
"dentQuotes": true,
|
||||||
|
"api": "http://quitter.se/"
|
||||||
|
}
|
77
modules-stock/dent/dent.js
Normal file
77
modules-stock/dent/dent.js
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
var request = require('request');
|
||||||
|
_ = require('underscore')._;
|
||||||
|
|
||||||
|
var dent = function(dbot) {
|
||||||
|
this.StatusRegex = {
|
||||||
|
identica: /\bhttps?:\/\/identi\.ca\/notice\/(\d+)\b/ig,
|
||||||
|
twitter: /\bhttps?:\/\/twitter\.com\/\w+\/status\/(\d+)\b/ig
|
||||||
|
};
|
||||||
|
|
||||||
|
this.StatusAPI = {
|
||||||
|
identica: "http://identi.ca/api/statuses/show.json",
|
||||||
|
twitter: "https://api.twitter.com/1/statuses/show.json"
|
||||||
|
};
|
||||||
|
|
||||||
|
this.api = {
|
||||||
|
'post': function(content) {
|
||||||
|
var username = this.config.username,
|
||||||
|
password = this.config.password,
|
||||||
|
info,
|
||||||
|
auth = "Basic " +
|
||||||
|
new Buffer(username + ":" + password).toString("base64");
|
||||||
|
|
||||||
|
request.post({
|
||||||
|
'url': this.config.api + '/statuses/update.json?status=' +
|
||||||
|
escape(content),
|
||||||
|
'headers': {
|
||||||
|
'Authorization': auth
|
||||||
|
}
|
||||||
|
},
|
||||||
|
function(error, response, body) {
|
||||||
|
console.log(body);
|
||||||
|
}.bind(this));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.lookup = function(id, service, callback) {
|
||||||
|
request({
|
||||||
|
url: this.StatusAPI[service],
|
||||||
|
qs: {"id": id},
|
||||||
|
json: true
|
||||||
|
}, function(error, response, body) {
|
||||||
|
if (!error && response.statusCode == 200) {
|
||||||
|
if (_.has(body, 'text')) {
|
||||||
|
callback(service + " [" + body.user.screen_name + '] ' + body.text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
this.commands = {
|
||||||
|
'~dent': function(event) {
|
||||||
|
this.api.post(event.input[1]);
|
||||||
|
event.reply('Dent posted (probably).');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.commands['~dent'].regex = [/^dent (.+)$/, 2];
|
||||||
|
|
||||||
|
this.onLoad = function() {
|
||||||
|
if(this.config.dentQuotes === true && _.has(dbot.modules, 'quotes')) {
|
||||||
|
dbot.api.event.addHook('qadd', function(key, text) {
|
||||||
|
if(text.indexOf('~~') == -1) {
|
||||||
|
this.api.post(key + ': ' + text);
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
for(s in this.StatusRegex) {
|
||||||
|
dbot.api.link.addHandler(s, this.StatusRegex[s], function(matches, name, callback) {
|
||||||
|
this.lookup(matches[1], name, callback);
|
||||||
|
}.bind(this));
|
||||||
|
}
|
||||||
|
}.bind(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.fetch = function(dbot) {
|
||||||
|
return new dent(dbot);
|
||||||
|
};
|
9
modules-stock/dice/README.md
Normal file
9
modules-stock/dice/README.md
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
## Dice
|
||||||
|
Rolls virtual dice.
|
||||||
|
|
||||||
|
### Description
|
||||||
|
Rolls a virtual die and outputs the result to the channel.
|
||||||
|
### Commands
|
||||||
|
|
||||||
|
#### ~roll <die type>
|
||||||
|
Rolls a die. 1d6 will be rolled by default.
|
4
modules-stock/dice/config.json
Normal file
4
modules-stock/dice/config.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"ignorable": true,
|
||||||
|
"dependencies": [ "command" ]
|
||||||
|
}
|
100
modules-stock/dice/dice.js
Normal file
100
modules-stock/dice/dice.js
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
var parseDiceSpec = function (specString) {
|
||||||
|
var rawSpec = specString.valMatch(/^([0-9]*)d(%|[0-9]*)(|[+-][0-9]+)$/i, 4);
|
||||||
|
if (rawSpec !== false) {
|
||||||
|
if (rawSpec[2] === "%") {
|
||||||
|
rawSpec[2] = 100;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
"count": parseInt(rawSpec[1] || 1),
|
||||||
|
"sides": parseInt(rawSpec[2] || 6),
|
||||||
|
"modifier": parseInt(rawSpec[3] || 0)
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var normalizeDiceSpec = function (specString) {
|
||||||
|
var diceSpec = parseDiceSpec(specString);
|
||||||
|
|
||||||
|
if (diceSpec["sides"] > 10000) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (diceSpec["count"] > 1000) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (diceSpec["count"] > 1) {
|
||||||
|
var count = diceSpec["count"];
|
||||||
|
} else {
|
||||||
|
var count = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (diceSpec["sides"] === 100) {
|
||||||
|
var sides = "%";
|
||||||
|
} else {
|
||||||
|
var sides = diceSpec["sides"];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (diceSpec["modifier"] > 0) {
|
||||||
|
var modifier = "+" + diceSpec["modifier"];
|
||||||
|
} else if (diceSpec["modifier"] < 0) {
|
||||||
|
var modifier = diceSpec["modifier"];
|
||||||
|
} else {
|
||||||
|
var modifier = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return (count + "d" + sides + modifier);
|
||||||
|
};
|
||||||
|
|
||||||
|
var dice = function(dbot) {
|
||||||
|
var commands = {
|
||||||
|
'~roll': function (event) {
|
||||||
|
var rolls = [];
|
||||||
|
|
||||||
|
if (event.params.length === 1) {
|
||||||
|
event.params.push("d6");
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 1; i < event.params.length; i++) {
|
||||||
|
var diceSpec = parseDiceSpec(event.params[i]);
|
||||||
|
if (diceSpec === false) {
|
||||||
|
rolls.push([event.params[i], false]);
|
||||||
|
} else {
|
||||||
|
rolls.push([normalizeDiceSpec(event.params[i]), [], diceSpec["modifier"]]);
|
||||||
|
for (var j = 0; j < diceSpec["count"] ; j++) {
|
||||||
|
rolls[rolls.length-1][1].push(Math.ceil(Math.random() * diceSpec["sides"]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < rolls.length; i++) {
|
||||||
|
if (rolls[i][1] === false) {
|
||||||
|
event.reply(rolls[i][0] + ": invalid dice spec");
|
||||||
|
} else {
|
||||||
|
if (rolls[i][1].length > 1) {
|
||||||
|
var total = " (total " + _.reduce(rolls[i][1], function(memo, num){ return memo + num; }, 0);
|
||||||
|
if (rolls[i][2] != 0) {
|
||||||
|
if (rolls[i][2] > 0) {
|
||||||
|
total += " + ";
|
||||||
|
} else {
|
||||||
|
total += " - ";
|
||||||
|
}
|
||||||
|
total += Math.abs(rolls[i][2]) + " -> " + (rolls[i][1].sum() + rolls[i][2]);
|
||||||
|
}
|
||||||
|
total += ")"
|
||||||
|
} else {
|
||||||
|
var total = "";
|
||||||
|
}
|
||||||
|
event.reply(rolls[i][0] + ": " + rolls[i][1].join(" ") + total);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.commands = commands;
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.fetch = function(dbot) {
|
||||||
|
return new dice(dbot);
|
||||||
|
};
|
17
modules-stock/dns/README.md
Normal file
17
modules-stock/dns/README.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
## DNS
|
||||||
|
|
||||||
|
Performs and reports upon basic DNS functions.
|
||||||
|
|
||||||
|
### Description
|
||||||
|
|
||||||
|
This module utilises the domain name system to discover basic information about
|
||||||
|
domain names and IP addresses.
|
||||||
|
|
||||||
|
### Commands
|
||||||
|
|
||||||
|
#### ~lookup [domain name]
|
||||||
|
Looks up the specified domain name in the domain name system. If a match is found,
|
||||||
|
the first corresponding A or AAAA record is displayed.
|
||||||
|
#### ~rdns [IP address]
|
||||||
|
Looks up the specified IP address in the domain name system. If a match is found,
|
||||||
|
the first corresponding rDNS domain name is displayed.
|
96
modules-stock/dns/dns.js
Normal file
96
modules-stock/dns/dns.js
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
/**
|
||||||
|
* Module Name: DNS
|
||||||
|
* Description: Performs and reports on basic DNS functions.
|
||||||
|
*/
|
||||||
|
var dnsm = require('dns'),
|
||||||
|
request = require('request'),
|
||||||
|
http = require('http');
|
||||||
|
|
||||||
|
var dns = function(dbot) {
|
||||||
|
if(!_.has(dbot.db, 'ip')) {
|
||||||
|
dbot.db.ip = {};
|
||||||
|
}
|
||||||
|
var ips = dbot.db.ip;
|
||||||
|
|
||||||
|
this.api = {
|
||||||
|
'getGeoIp': function(ip, callback) {
|
||||||
|
if(_.has(ips, ip)) {
|
||||||
|
body = ips[ip];
|
||||||
|
callback(ip + ' is located in '+ body.city + ', ' + body.country + '. Hostname: ' + body.hostname + '. ISP: ' + body.org);
|
||||||
|
} else {
|
||||||
|
request.get('http://ipinfo.io/'+ip, {
|
||||||
|
'json': true
|
||||||
|
}, function(err, res, body) {
|
||||||
|
if(!err && body) {
|
||||||
|
callback(ip + ' is located in '+ body.city + ', ' + body.country + '. Hostname: ' + body.hostname + '. ISP: ' + body.org);
|
||||||
|
} else {
|
||||||
|
callback('No info about ' + ip);
|
||||||
|
}
|
||||||
|
ips[ip] = body;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}.bind(this)
|
||||||
|
};
|
||||||
|
|
||||||
|
var commands = {
|
||||||
|
'~lookup': function(event) {
|
||||||
|
domain = event.params[1];
|
||||||
|
dnsm.lookup(domain, function (error, addr) {
|
||||||
|
if (error) {
|
||||||
|
event.reply(dbot.t("lookup-error",{"domain": domain, "code": error.code}));
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t("lookup",{"domain": domain, "address": addr}));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
'~rdns': function(event) {
|
||||||
|
ip = event.params[1];
|
||||||
|
dnsm.reverse(ip, function (error, domain) {
|
||||||
|
if (error) {
|
||||||
|
event.reply(dbot.t("rdns-error",{"domain": domain, "ip": ip, "error": error.code}));
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t("rdns",{"domain": domain, "ip": ip}));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
'~geoip': function(event) {
|
||||||
|
var ip = event.params[1];
|
||||||
|
this.api.getGeoIp(ip, function(result) { event.reply(result); });
|
||||||
|
},
|
||||||
|
|
||||||
|
'~dnsbl': function(event) {
|
||||||
|
var revIp = event.input[1].trim().split('.').reverse().join('.');
|
||||||
|
dnsm.lookup(revIp + '.cbl.abuseat.org', function(err, res) {
|
||||||
|
if(!err && res) {
|
||||||
|
event.reply(event.input[1] + ' is listed as an abusive IP.');
|
||||||
|
} else {
|
||||||
|
event.reply(event.input[1] + ' does not seem to be a Naughty Nancy.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
commands['~dnsbl'].regex = [/^dnsbl ([\d\w\s\.-]*)/, 2];
|
||||||
|
this.commands = commands;
|
||||||
|
|
||||||
|
if(dbot.config.modules.dns.dnsblconn == true) {
|
||||||
|
this.listener = function(event) {
|
||||||
|
if(event.message.match('CLICONN')) {
|
||||||
|
var ip = event.message.match('CLICONN ([^ ]+).*?((?:[0-9]{1,3}\.){3}[0-9]{1,3}) users');
|
||||||
|
revIp = ip[2].trim().split('.').reverse().join('.');
|
||||||
|
dbot.say(event.server, '#dnsbl', 'DEBUG: Looking up ' + ip[2] + ' for ' + ip[1] + ' @ ' + revIp);
|
||||||
|
dnsm.lookup(revIp + '.cbl.abuseat.org', function(err, res) {
|
||||||
|
if(!err && res) {
|
||||||
|
dbot.say(event.server, '#dnsbl', 'ALERT: ' + ip[1] + ' connecting from ' + ip[2] + ' may well be NAUGHTY.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.on = 'NOTICE';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.fetch = function(dbot) {
|
||||||
|
return new dns(dbot);
|
||||||
|
};
|
32
modules-stock/dns/strings.json
Normal file
32
modules-stock/dns/strings.json
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
"lookup-error": {
|
||||||
|
"en": "{domain} is \u000303AVAILABLE! \u000314({code})",
|
||||||
|
"cy": "{domain} \u000303AR GAEL! \u000314({code})",
|
||||||
|
"nl": "{domain} is \u000303BESCHIKBAAR! \u000314({code})",
|
||||||
|
"de": "{domain} ist \u000303VERFÜGBAR! \u000314({code})",
|
||||||
|
"fr": "{domain} est \u000303DISPONIBLE! \u000314({code})",
|
||||||
|
"it": "{domain} è \u000303DISPONIBILE! \u000314({code})"
|
||||||
|
},
|
||||||
|
"lookup": {
|
||||||
|
"en": "{domain} is \u000305TAKEN! \u000314({address})",
|
||||||
|
"cy": "Dydy {domain} \u000305DDIM AR GAEL! \u000314({address})",
|
||||||
|
"nl": "{domain} is \u000305BEZET! \u000314({address})",
|
||||||
|
"de": "{domain} ist \u000305BELEGT! \u000314({address})",
|
||||||
|
"fr": "{domain} est \u000305PRIS! \u000314({address})",
|
||||||
|
"it": "{domain} èt \u000305RISERVATO! \u000314({address})"
|
||||||
|
},
|
||||||
|
"rdns": {
|
||||||
|
"en": "{ip} \u2192 {domain}",
|
||||||
|
"fr": "{ip} \u2192 {domain}",
|
||||||
|
"it": "{ip} \u2192 {domain}",
|
||||||
|
"de":"{ip} \u2192 {domain}"
|
||||||
|
},
|
||||||
|
"rdns-error": {
|
||||||
|
"en": "Unable to lookup {ip}. \u000314({error})",
|
||||||
|
"cy": "Methu am-edrych {ip}. \u000314({error})",
|
||||||
|
"nl": "{ip} kan niet worden opgezocht. \u000314({error})",
|
||||||
|
"de": "Kann {ip} nicht auflösen. \u000314({error})",
|
||||||
|
"fr": "Impossible de rechercher {ip}. \u000314({error})",
|
||||||
|
"it": "Non è possibile cercare {ip}. \u000314({error})"
|
||||||
|
}
|
||||||
|
}
|
30
modules-stock/event/README.md
Normal file
30
modules-stock/event/README.md
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
## Event
|
||||||
|
|
||||||
|
Emit events for whatever you want man idk.
|
||||||
|
|
||||||
|
### Description
|
||||||
|
|
||||||
|
This is a library module designed for other modules to use to emit various
|
||||||
|
events at any point, and also to attach functions to said events. These are
|
||||||
|
similar to command hooks, however their advantage is that they may be called
|
||||||
|
anywhere in your code; they are particularly useful when you want to attach a
|
||||||
|
callback to a listener.
|
||||||
|
|
||||||
|
### API
|
||||||
|
|
||||||
|
#### addHook(eventName, callback)
|
||||||
|
This function will set a given callback to be executed every time the
|
||||||
|
emit API function is executed with the given event name. The arguments of your
|
||||||
|
callback are defined as an array in the emit call.
|
||||||
|
|
||||||
|
The best place to add hooks to commands is in the 'onLoad' function of your
|
||||||
|
module, as this ensures it will be run while all other modules are loaded so
|
||||||
|
nothing will be missed.
|
||||||
|
|
||||||
|
#### emit(eventName, [ arguments ])
|
||||||
|
This function executes all of the functions associated with the given eventName,
|
||||||
|
passing your given array of arguments.
|
||||||
|
|
||||||
|
For example, to emit an event when you detect a nick change:
|
||||||
|
|
||||||
|
dbot.api.event.emit('nick_changed', [ event.server, newNick ]);
|
28
modules-stock/event/event.js
Normal file
28
modules-stock/event/event.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/**
|
||||||
|
* Module Name: event
|
||||||
|
* Description: Allow other modules to emit events and that
|
||||||
|
*/
|
||||||
|
var _ = require('underscore')._;
|
||||||
|
|
||||||
|
var event = function(dbot) {
|
||||||
|
this.dbot = dbot;
|
||||||
|
this.hooks = {};
|
||||||
|
this.api = {
|
||||||
|
'addHook': function(eventName, callback) {
|
||||||
|
if(!_.has(this.hooks, eventName)) this.hooks[eventName] = [];
|
||||||
|
this.hooks[eventName].push(callback);
|
||||||
|
},
|
||||||
|
|
||||||
|
'emit': function(eventName, args) {
|
||||||
|
if(_.has(this.hooks, eventName)) {
|
||||||
|
_.each(this.hooks[eventName], function(callback) {
|
||||||
|
callback.apply(callback.module, args);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.fetch = function(dbot) {
|
||||||
|
return new event(dbot);
|
||||||
|
};
|
9
modules-stock/flashy/README.md
Normal file
9
modules-stock/flashy/README.md
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
## Flashy
|
||||||
|
|
||||||
|
Make big flashy text at people.
|
||||||
|
|
||||||
|
### Commands
|
||||||
|
|
||||||
|
#### ~flashy [color] [message]
|
||||||
|
Give a link to a page hosted by the flashy module which produces big flashing
|
||||||
|
text in the given colour.
|
45
modules-stock/flashy/flashy.js
Normal file
45
modules-stock/flashy/flashy.js
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/**
|
||||||
|
* Module Name: Flashy
|
||||||
|
* Description: Makes pages with flashing text and that innit.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var _ = require('underscore')._;
|
||||||
|
|
||||||
|
var flashy = function(dbot) {
|
||||||
|
this.colourMap = {
|
||||||
|
'white': 'FFFFFF',
|
||||||
|
'red': 'FF0000',
|
||||||
|
'green': '00FF00',
|
||||||
|
'blue': '0000FF',
|
||||||
|
'yellow': 'FFFF00',
|
||||||
|
'pink': 'FFC0CB',
|
||||||
|
'magenta': 'FF00FF',
|
||||||
|
'purple': 'AA00FF',
|
||||||
|
'cyan': '00FFFF',
|
||||||
|
'orange': 'FFAA00',
|
||||||
|
'lime': 'AAFF00',
|
||||||
|
'grey': 'AAAAAA',
|
||||||
|
'infrared': '000000'
|
||||||
|
};
|
||||||
|
|
||||||
|
this.commands = {
|
||||||
|
'~flashy': function(event) {
|
||||||
|
var colour = event.input[1];
|
||||||
|
var text = event.input[2].trim().toUpperCase();
|
||||||
|
|
||||||
|
if(_.has(this.colourMap, colour)) {
|
||||||
|
event.reply(dbot.api.web.getUrl('flashy/' + colour + '/' +
|
||||||
|
encodeURIComponent(text)));
|
||||||
|
} else {
|
||||||
|
var possibleColours = _.keys(this.colourMap).join(', ') + '.';
|
||||||
|
event.reply('No such colour, brah. Available colours are: ' + possibleColours);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.commands['~flashy'].regex = [/^flashy ([^ ]+) (.+)$/, 3];
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.fetch = function(dbot) {
|
||||||
|
return new flashy(dbot);
|
||||||
|
};
|
21
modules-stock/flashy/pages.js
Normal file
21
modules-stock/flashy/pages.js
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
var _ = require('underscore')._;
|
||||||
|
|
||||||
|
var pages = function(dbot) {
|
||||||
|
return {
|
||||||
|
'/flashy/:colour/:text': function(req, res) {
|
||||||
|
if(!_.has(this.colourMap, req.params.colour)) {
|
||||||
|
req.params.colour = 'red';
|
||||||
|
}
|
||||||
|
var colour = this.colourMap[req.params.colour];
|
||||||
|
res.render('flashy', {
|
||||||
|
'name': dbot.config.name,
|
||||||
|
'colour': colour,
|
||||||
|
'text': decodeURIComponent(req.params.text)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.fetch = function(dbot) {
|
||||||
|
return pages(dbot);
|
||||||
|
};
|
4
modules-stock/food/config.json
Normal file
4
modules-stock/food/config.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"outputPrefix": "\u000311food\u000f",
|
||||||
|
"api_key": "http://food2fork.com/about/api"
|
||||||
|
}
|
60
modules-stock/food/food.js
Normal file
60
modules-stock/food/food.js
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/**
|
||||||
|
* Module name: Food
|
||||||
|
* Description: recipe search
|
||||||
|
*/
|
||||||
|
|
||||||
|
var _ = require('underscore')._,
|
||||||
|
request = require('request');
|
||||||
|
|
||||||
|
var food = function(dbot) {
|
||||||
|
this.commands = {
|
||||||
|
'~recipe': function(event) {
|
||||||
|
request.get('http://food2fork.com/api/search', {
|
||||||
|
'qs': {
|
||||||
|
'key': this.config.api_key,
|
||||||
|
'q': event.input[1]
|
||||||
|
},
|
||||||
|
'json': true
|
||||||
|
}, function(error, response, body) {
|
||||||
|
if(_.isObject(body) && _.has(body, 'recipes') && body.recipes.length > 0) {
|
||||||
|
var num = _.random(0, body.recipes.length - 1),
|
||||||
|
recipe = body.recipes[num];
|
||||||
|
|
||||||
|
event.reply(dbot.t('recipe', {
|
||||||
|
'title': recipe.title,
|
||||||
|
'link': recipe.source_url
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t('no_recipe'));
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.commands['~recipe'].regex = [/^recipe (.+)$/, 2];
|
||||||
|
|
||||||
|
this.listener = function(event) {
|
||||||
|
var match = event.message.match(new RegExp(dbot.config.name + ': what should i (have|eat|make)\\??( for (dinner|lunch|breakfast))?\\??', 'i'));
|
||||||
|
if(match) {
|
||||||
|
var page = _.random(0, 200);
|
||||||
|
request.get('http://food2fork.com/api/search', {
|
||||||
|
'qs': {
|
||||||
|
'key': this.config.api_key,
|
||||||
|
'page': page
|
||||||
|
},
|
||||||
|
'json': true
|
||||||
|
}, function(error, response, body) {
|
||||||
|
if(_.isObject(body) && _.has(body, 'recipes') && body.recipes.length > 0) {
|
||||||
|
var num = _.random(0, body.recipes.length - 1),
|
||||||
|
recipe = body.recipes[num];
|
||||||
|
|
||||||
|
event.reply(event.user + ': You should make ' + recipe.title + '. See: ' + recipe.source_url);
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
}
|
||||||
|
}.bind(this);
|
||||||
|
this.on = 'PRIVMSG';
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.fetch = function(dbot) {
|
||||||
|
return new food(dbot);
|
||||||
|
};
|
8
modules-stock/food/strings.json
Normal file
8
modules-stock/food/strings.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"recipe": {
|
||||||
|
"en": "{title} - {link}"
|
||||||
|
},
|
||||||
|
"no_recipe": {
|
||||||
|
"en": "No recipes found."
|
||||||
|
}
|
||||||
|
}
|
34
modules-stock/fpx/README.md
Normal file
34
modules-stock/fpx/README.md
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
## 500px
|
||||||
|
|
||||||
|
Adds various 500px functionality.
|
||||||
|
|
||||||
|
### Description
|
||||||
|
|
||||||
|
This module provides a command which allows users to search for a random popular 500px photo.
|
||||||
|
|
||||||
|
### Dependencies
|
||||||
|
|
||||||
|
It has following dependencies:
|
||||||
|
+ [node-500px](https://github.com/ro-ka/node-500px)
|
||||||
|
|
||||||
|
### config.json
|
||||||
|
|
||||||
|
ignorable and consumerKey has to be configurated. It can be obtained at http://developers.500px.com
|
||||||
|
```
|
||||||
|
{
|
||||||
|
"ignorable": true,
|
||||||
|
"api_key": "CONSUMERKEY_HERE"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Commands
|
||||||
|
|
||||||
|
|
||||||
|
~r500px
|
||||||
|
Responds with a random popular 500px photo.
|
||||||
|
Example:
|
||||||
|
+ ~r500px
|
||||||
|
|
||||||
|
### TODO
|
||||||
|
|
||||||
|
Photo by user etc.
|
4
modules-stock/fpx/config.json
Normal file
4
modules-stock/fpx/config.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"ignorable": true,
|
||||||
|
"api_key": "CONSUMERKEY_HERE"
|
||||||
|
}
|
33
modules-stock/fpx/fpx.js
Normal file
33
modules-stock/fpx/fpx.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/**
|
||||||
|
* Module Name: 500px
|
||||||
|
* Description: Adds various 500px functionality.
|
||||||
|
* Requires: node-500px [http://mjgil.github.io/five-px/]
|
||||||
|
*/
|
||||||
|
|
||||||
|
var _ = require('underscore')._,
|
||||||
|
API500px = require('500px').API500px;
|
||||||
|
|
||||||
|
var fpx = function(dbot) {
|
||||||
|
this.commands = {
|
||||||
|
'~r500px': function(event) {
|
||||||
|
var random = Math.floor(Math.random() * 30);
|
||||||
|
this.api500px.photos.getPopular({'sort': 'created_at', 'rpp': '30'}, function(error, results) {
|
||||||
|
if (error) {
|
||||||
|
event.reply(dbot.t('5px_error'));
|
||||||
|
console.log(error);
|
||||||
|
} else {
|
||||||
|
var name = results.photos[random].name,
|
||||||
|
id = results.photos[random].id;
|
||||||
|
event.reply(dbot.t('5px_result',{'name':name,'id':id}));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.onLoad = function() {
|
||||||
|
this.api500px = new API500px(this.config.api_key);
|
||||||
|
}.bind(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.fetch = function(dbot) {
|
||||||
|
return new fpx(dbot);
|
||||||
|
};
|
8
modules-stock/fpx/strings.json
Normal file
8
modules-stock/fpx/strings.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"5px_result":{
|
||||||
|
"en": "{name} - http://500px.com/photo/{id}"
|
||||||
|
},
|
||||||
|
"5px_error": {
|
||||||
|
"en": "Something went wrong :( Example: '~r500px'"
|
||||||
|
}
|
||||||
|
}
|
3
modules-stock/fpx/usage.json
Normal file
3
modules-stock/fpx/usage.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"~r500px": "~r500px"
|
||||||
|
}
|
18
modules-stock/github/LICENSE
Normal file
18
modules-stock/github/LICENSE
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
Copyright (c) 2013 Douglas Gardner <douglas@chippy.ch>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
28
modules-stock/github/README.md
Normal file
28
modules-stock/github/README.md
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
## Github
|
||||||
|
|
||||||
|
Grabs interesting data from the GitHub API.
|
||||||
|
|
||||||
|
### Description
|
||||||
|
|
||||||
|
This module for [depressionbot](https://github.com/reality/depressionbot) takes some interesting information about Github and parses it in a pleasing manner.
|
||||||
|
|
||||||
|
### Configuration
|
||||||
|
#### defaultrepo
|
||||||
|
When repository information is lacking from the command, this repository will be used.
|
||||||
|
#### sortorder
|
||||||
|
Defines the behaviour of ~issue when no arguments are given. Options are ``created``, ``updated``, or ``comments``.
|
||||||
|
### Commands
|
||||||
|
#### ~commits
|
||||||
|
Returns the number of commits in the repository of the current depressionbot instance.
|
||||||
|
#### ~gstatus
|
||||||
|
Returns the [current status of Github](https://status.github.com), and a message explaining the current state of affairs.
|
||||||
|
#### ~issue (user/repo) [id]
|
||||||
|
Gives information about the isse pecified, from the default repository if one is not explicitly stated.
|
||||||
|
#### ~milestone [milestone name]
|
||||||
|
Returns milestone progress for any given milestone, with a link to the milestone in question.
|
||||||
|
#### ~repo (repo name)
|
||||||
|
Returns information about the repo given as a parameter. The repo should be specified as ``user/name``; for example, ``twitter/snowflake``.
|
||||||
|
#### ~repocount [user]
|
||||||
|
Returns the number of public Github repositories for the specified user.
|
||||||
|
### Dependencies
|
||||||
|
* [request](https://github.com/mikeal/request/):``$ npm install request``
|
8
modules-stock/github/config.json
Normal file
8
modules-stock/github/config.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"dependencies": [ "command" ],
|
||||||
|
"ignorable": true,
|
||||||
|
"help": "http://github.com/zuzak/dbot-github/blob/master/README.md",
|
||||||
|
"defaultrepo": "reality/dbot",
|
||||||
|
"sortorder": "updated",
|
||||||
|
"useragent": "reality/depressionbot github module"
|
||||||
|
}
|
192
modules-stock/github/github.js
Normal file
192
modules-stock/github/github.js
Normal file
@ -0,0 +1,192 @@
|
|||||||
|
/**
|
||||||
|
* Module Name: Github
|
||||||
|
* Description: Retrieves interesting Github information
|
||||||
|
*/
|
||||||
|
var request = require('request'),
|
||||||
|
exec = require('child_process').exec;
|
||||||
|
|
||||||
|
var github = function(dbot) {
|
||||||
|
this.api = {
|
||||||
|
"githubStatus": function(callback){
|
||||||
|
var reqUrl = "https://status.github.com/api/last-message.json";
|
||||||
|
request({"url": reqUrl, "headers": {"User-Agent": this.config.useragent}}, function(error, response, body) {
|
||||||
|
callback(JSON.parse(body));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
var commands = {
|
||||||
|
'~repocount': function(event) {
|
||||||
|
var reqUrl = "https://api.github.com/users/" + event.params[1] + "/repos";
|
||||||
|
request({"url": reqUrl, "headers": {"User-Agent": this.config.useragent}}, function(error, response, body) {
|
||||||
|
if(response.statusCode == "200") {
|
||||||
|
var result = JSON.parse(body);
|
||||||
|
event.reply(dbot.t("repocount",{"user": event.params[1], "count": result.length}));
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t("usernotfound"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
'~repo': function(event) {
|
||||||
|
var repo = event.params[1];
|
||||||
|
if (typeof repo == 'undefined') {
|
||||||
|
repo = this.config.defaultrepo;
|
||||||
|
}
|
||||||
|
|
||||||
|
var reqUrl = "https://api.github.com/";
|
||||||
|
reqUrl += "repos/" + repo;
|
||||||
|
request({"url": reqUrl, "headers": {"User-Agent": this.config.useragent}}, function(error, response, body) {
|
||||||
|
|
||||||
|
var data = JSON.parse(body);
|
||||||
|
if (data["fork"]) {
|
||||||
|
event.reply(dbot.t("forkedrepo",data));
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t("unforkedrepo",data));
|
||||||
|
}
|
||||||
|
// TODO: move this shizz into an api call
|
||||||
|
var longurl = "http://github.com/" + repo;
|
||||||
|
event.reply(dbot.t('location')+" "+longurl);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
'~gstatus': function(event) {
|
||||||
|
data = this.api.githubStatus(function(data){
|
||||||
|
event.reply(dbot.t("status"+data["status"]));
|
||||||
|
event.reply(data["body"]);
|
||||||
|
}.bind(this));
|
||||||
|
},
|
||||||
|
'~milestone': function(event) {
|
||||||
|
var repo = this.config.defaultrepo;
|
||||||
|
var name = event.params[1];
|
||||||
|
if (event.params[2]){
|
||||||
|
repo = name;
|
||||||
|
name = event.params[2];
|
||||||
|
}
|
||||||
|
var reqUrl = "https://api.github.com/repos/";
|
||||||
|
reqUrl += repo + "/milestones";
|
||||||
|
|
||||||
|
request({"url": reqUrl, "headers":{"User-Agent": this.config.useragent}}, function(error, response, body) {
|
||||||
|
var data = JSON.parse(body);
|
||||||
|
for (var section in data) {
|
||||||
|
var milestone = data[section];
|
||||||
|
if (milestone["title"] == name){
|
||||||
|
var str = "Milestone " + milestone["title"];
|
||||||
|
var progress = milestone["closed_issues"] / (milestone["open_issues"] + milestone["closed_issues"]);
|
||||||
|
progress = Math.round(progress*100);
|
||||||
|
var bar = "[";
|
||||||
|
for (var i = 10; i < 100; i += 10) {
|
||||||
|
if ((progress/i) > 1) {
|
||||||
|
bar += "█";
|
||||||
|
} else {
|
||||||
|
bar += " ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bar += "]";
|
||||||
|
str += " is " + bar + progress + "% complete";
|
||||||
|
|
||||||
|
event.reply(str);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
'~repocount': function(event) {
|
||||||
|
// TODO: add handling for non existent user
|
||||||
|
var reqUrl = "https://api.github.com/users/" + event.params[1] + "/repos";
|
||||||
|
request({"url": reqUrl,"headers": { "User-Agent": this.config.useragent}}, function(error, response, body) {
|
||||||
|
var result = JSON.parse(body);
|
||||||
|
event.reply(event.params[1] + " has " + result.length + " public repositories.");
|
||||||
|
});
|
||||||
|
},
|
||||||
|
'~grate': function(event) {
|
||||||
|
request.get({"url":"https://api.github.com/rate_limit", "headers":{"User-Agent": this.config.useragent}}, function(error, response, body) {
|
||||||
|
var data = JSON.parse(body);
|
||||||
|
if (data.message){
|
||||||
|
event.reply(data.message);
|
||||||
|
} else {
|
||||||
|
event.reply(data.rate.remaining + " requests of " + data.rate.limit + " remaining.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
'~issue': function(event) {
|
||||||
|
var repo, issue, randflag;
|
||||||
|
if (isNaN(event.params[1]) && event.params[1]){ // if ~issue foo/bar
|
||||||
|
repo = event.params[1];
|
||||||
|
issue = event.params[2];
|
||||||
|
} else {
|
||||||
|
repo = this.config.defaultrepo;
|
||||||
|
issue = event.params[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (issue == "*" || issue == "random" || issue == "0") {
|
||||||
|
issue = "";
|
||||||
|
randflag = true;
|
||||||
|
} else if (!issue) { // issue is undefined
|
||||||
|
issue = "";
|
||||||
|
} else {
|
||||||
|
issue = "/" + issue; // got to be a better way
|
||||||
|
}
|
||||||
|
|
||||||
|
var reqUrl = "https://api.github.com/repos/" + repo + "/issues" +
|
||||||
|
issue + "?sort=" + this.config.sortorder;
|
||||||
|
request.get({"url": reqUrl, headers: { "User-Agent": this.config.useragent}}, function(error,response, body) {
|
||||||
|
if (response.statusCode == "200") {
|
||||||
|
var data = JSON.parse(body);
|
||||||
|
if (!issue){
|
||||||
|
if (randflag) {
|
||||||
|
data = data[Math.floor(Math.random() * data.length)];
|
||||||
|
} else {
|
||||||
|
data = data[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (_.has(data["pull_request"], "html_url")){
|
||||||
|
data["pull_request"] = " with code";
|
||||||
|
} else {
|
||||||
|
data["pull_request"] = "";
|
||||||
|
}
|
||||||
|
if (data["state"]=="open") {
|
||||||
|
data["state"] = "\u000303" + data["state"];
|
||||||
|
} else {
|
||||||
|
data["state"] = "\u000304" + data["state"];
|
||||||
|
}
|
||||||
|
var labels = "";
|
||||||
|
for (var i=0; i < data["labels"].length; i++) { // for-in doesn't like me
|
||||||
|
var color = "\u0003" + (parseInt(data["labels"][i]["color"],16) % 15);
|
||||||
|
labels += " " + color + data["labels"][i]["name"];
|
||||||
|
}
|
||||||
|
data["label"] = labels;
|
||||||
|
event.reply(dbot.t("issue",data));
|
||||||
|
event.reply(data["html_url"]);
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t("issuenotfound"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
'~commits': function(event) {
|
||||||
|
exec("git rev-list --all | wc -l", function(error, stdout, stderr) {
|
||||||
|
stdout = stdout.trim();
|
||||||
|
request({"url":"http://numbersapi.com/" + stdout + "?fragment&default=XXX"}, function(error, response, body){
|
||||||
|
if (body != "XXX"){
|
||||||
|
event.reply(dbot.t("commitcountfun",{"fact": body, "count": stdout}));
|
||||||
|
} else {
|
||||||
|
// nothing fun about the number, let's try the year
|
||||||
|
request({"url":"http://numbersapi.com/" + stdout + "/year?fragment&default=XXX"}, function(error, response, body){
|
||||||
|
if (body != "XXX"){
|
||||||
|
event.reply(dbot.t("commitcountyear",{"fact": body, "count": stdout}));
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t("commitcountboring",{"count": stdout}));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.commands = commands;
|
||||||
|
|
||||||
|
this.on = 'PRIVMSG';
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.fetch = function(dbot) {
|
||||||
|
return new github(dbot);
|
||||||
|
};
|
94
modules-stock/github/strings.json
Normal file
94
modules-stock/github/strings.json
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
{
|
||||||
|
"repocount": {
|
||||||
|
"en": "{user} has {count} public repos.",
|
||||||
|
"cy": "Mae {count} archifdai cyhoeddus gan {user}.",
|
||||||
|
"de": "{user} hat {count} öffnetliche Repos.",
|
||||||
|
"fr": "{user} a {count} dépôt(s) public(s).",
|
||||||
|
"it": "{user} ha {count} deposito/i pubblico/i."
|
||||||
|
},
|
||||||
|
"statusgood": {
|
||||||
|
"en": "\u000309Shit's fine",
|
||||||
|
"cy": "\u000309Cachu'n ddirwy",
|
||||||
|
"de": "\u000309Alles in Ordnung",
|
||||||
|
"fr": "\u000309Cette merde tourne bien",
|
||||||
|
"it": "\u000309Funziona a meraviglia."
|
||||||
|
},
|
||||||
|
"statusminor": {
|
||||||
|
"en": "\u000308Shit's touchy",
|
||||||
|
"cy": "\u000308Cachu'n fregus",
|
||||||
|
"de": "\u000308Kleinere Probleme vorhanden",
|
||||||
|
"fr": "\u000308Cette merde a un petit problème",
|
||||||
|
"it": "\u000308Piccoli problemi all' orizzonte"
|
||||||
|
},
|
||||||
|
"statusmajor": {
|
||||||
|
"en": "\u000304Shit's fucked:",
|
||||||
|
"cy": "\u000304Cachu wedi cyrraedd y ffan:",
|
||||||
|
"de": "\u000304Du bist am Arsch",
|
||||||
|
"fr": "\u000304Cette merde est foutue : ",
|
||||||
|
"it": "\u000304Sei nella merda : "
|
||||||
|
},
|
||||||
|
"location": {
|
||||||
|
"en": "You can find that shit at:",
|
||||||
|
"cy": "Gallwch ddod o hyd y cachu yn:",
|
||||||
|
"de": "Kann gefunden werden unter:",
|
||||||
|
"fr": "Tu peux trouver cette merde ici : ",
|
||||||
|
"it": "Puoi trovare questa coglionata a: "
|
||||||
|
},
|
||||||
|
"forkedrepo": {
|
||||||
|
"en": "{name} is a forked {language} repo with {open_issues} unresolved issues [{forks}F {watchers}W]",
|
||||||
|
"cy": "{name} ydy archif {language} fforchog gyda {open_issues} materion heb eu datrys [{forks}F {watchers}W]",
|
||||||
|
"de": "{name} ist eine geteilte {language} Repo mit {open_issues} ungelösten Problemen [{forks}F {watchers}W]",
|
||||||
|
"fr": "{name} est un dépôt fourché {language} avec {open_issues} problème(s) non résolu(s) [{forks}F {watchers}W]",
|
||||||
|
"it": "{name} è un deposito biforcato {language} con {open_issues} problema/i irrisolto/i [{forks}F {watchers}W]"
|
||||||
|
},
|
||||||
|
"unforkedrepo": {
|
||||||
|
"en": "{name} is a {language} repo with {open_issues} unresolved issues [{forks}F {watchers}W]",
|
||||||
|
"cy": "{name} ydy archif {language} gyda {open_issues} materion heb eu datrys [{forks}F {watchers}W]",
|
||||||
|
"de": "{name} ist eine {language} Repo mit {open_issues} ungelösten Problemen [{forks}F {watchers}W]",
|
||||||
|
"fr": "{name} est un dépôt {language} avec {open_issues} problème(s) non résolu(s) [{forks}F {watchers}W]",
|
||||||
|
"it": "{name} è un deposito {language} con {open_issues} problema/i irrisolto/i [{forks}F {watchers}W]"
|
||||||
|
},
|
||||||
|
"usernotfound": {
|
||||||
|
"en": "User not found.",
|
||||||
|
"cy": "Defnyddiwr heb ei ganfod.",
|
||||||
|
"de": "Benutzer nicht gefunden.",
|
||||||
|
"fr": "Utilisateur non trouvé.",
|
||||||
|
"it": "Utente non trovato."
|
||||||
|
},
|
||||||
|
"issuenotfound": {
|
||||||
|
"en": "Unable to find that issue.",
|
||||||
|
"cy": "Wedi methu dod o hyd mater hwnnw",
|
||||||
|
"de": "Kann dieses Problem nicht finden.",
|
||||||
|
"fr": "Impossible de trouver ce problème.",
|
||||||
|
"it": "Impossibile trovare questo problema."
|
||||||
|
},
|
||||||
|
"issue": {
|
||||||
|
"en": "Issue \u000308{number}\u0003: {title} [{state}{pull_request}\u000315; {comments} comments]{label}",
|
||||||
|
"cy": "Mater \u000308{number}\u0003: {title} [{state}{pull_request}\u000315; {comments} sylwadau]{label}",
|
||||||
|
"de": "Problem \u000308{number}\u0003: {title} [{state}{pull_request}\u000315; {comments} comments]{label}",
|
||||||
|
"fr": "Problème \u000308{number}\u0003: {title} [{state}{pull_request}\u000315; {comments} commentaires]{label}",
|
||||||
|
"it": "Problema \u000308{number}\u0003: {title} [{state}{pull_request}\u000315; {comments} commento/i]{label}"
|
||||||
|
},
|
||||||
|
"commitcountboring": {
|
||||||
|
"en": "My code has been committed {count} times.",
|
||||||
|
"cy": "Mae fy cod wedi cael ei gyflawni ar {count} adegau.",
|
||||||
|
"de": "Mein Code wurde {count} mal bestätigt.",
|
||||||
|
"fr": "Mon code a été modifié {count} fois.",
|
||||||
|
"it": "Il mio codice è stato modificato {count} volta/e."
|
||||||
|
},
|
||||||
|
"commitcountfun": {
|
||||||
|
"en": "My repository has the same number of commits as {fact} ({count}).",
|
||||||
|
"cy": "Yr un nifer o ymrwymo fel {fact} gan fy archif ({count}).",
|
||||||
|
"de": "Meine Repository hat die gleiche Anzahl Commits wie {fact} ({count}).",
|
||||||
|
"fr": "Mon dépôt a le même nombre de modifications que {fact} ({count}).",
|
||||||
|
"it": "Il mio deposito ha lo stesso numero di modifiche come {fact} ({count})."
|
||||||
|
},
|
||||||
|
"commitcountyear": {
|
||||||
|
"en": "My repository's commits number {count}, the year that {fact}.",
|
||||||
|
"cy": "Nifer o ymrwymo gan fy archif: {count}, y flwyddyn y {fact}.",
|
||||||
|
"de": "Anzahl der Commits in meinem Repository {count}, des Jahres {fact}",
|
||||||
|
"fr": "Mon dépot compte {count} modifications, l'année où {fact}.",
|
||||||
|
"it": "Il mio deposito ha {count} modifica/che, l' anno che {fact}."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
29
modules-stock/gmaps/gmaps.js
Normal file
29
modules-stock/gmaps/gmaps.js
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/**
|
||||||
|
* Module Name: Google Maps
|
||||||
|
* Description: GMaps and ting
|
||||||
|
*/
|
||||||
|
var gm = require('googlemaps'),
|
||||||
|
_ = require('underscore')._;
|
||||||
|
|
||||||
|
var gmaps = function(dbot) {
|
||||||
|
this.commands = {
|
||||||
|
'~from': function(event) {
|
||||||
|
var from = event.input[1],
|
||||||
|
to = event.input[2],
|
||||||
|
departureNow = Math.floor((new Date()).getTime()/1000);
|
||||||
|
|
||||||
|
gm.directions(from, to, function(err, result) {
|
||||||
|
if(!err && result && result.status !== 'ZERO_RESULTS') {
|
||||||
|
event.reply('If you leave right now, it will take ' + result.routes[0].legs[0].duration.text + ' to get from ' + from + ' to ' + to + ' via public transport.');
|
||||||
|
} else {
|
||||||
|
event.reply('Apparently one cannot get from ' + from + ' to ' + to + ' using public transport. Do you accept the challenge?');
|
||||||
|
}
|
||||||
|
}, 'false', 'transit', null, null,null, null, null, departureNow);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.commands['~from'].regex = [/^from (.*) to (.*)/, 3];
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.fetch = function(dbot) {
|
||||||
|
return new gmaps(dbot);
|
||||||
|
};
|
4
modules-stock/goodreads/config.json
Normal file
4
modules-stock/goodreads/config.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"api_key": "sethere",
|
||||||
|
"outputPrefix": "\u00033goodreads\u000f"
|
||||||
|
}
|
293
modules-stock/goodreads/goodreads.js
Normal file
293
modules-stock/goodreads/goodreads.js
Normal file
@ -0,0 +1,293 @@
|
|||||||
|
/**
|
||||||
|
* Module Name: GoodReads
|
||||||
|
* Description: Interacts with the GoodReads API to provide book-oriented functionality to dbot
|
||||||
|
*/
|
||||||
|
|
||||||
|
var util = require('util'),
|
||||||
|
_ = require('underscore')._,
|
||||||
|
rp = require('request-promise-native'),
|
||||||
|
parseString = util.promisify(require('xml2js').parseString);
|
||||||
|
|
||||||
|
var GoodReads = function(dbot) {
|
||||||
|
this.apiRoot = 'https://www.goodreads.com';
|
||||||
|
|
||||||
|
this.internalAPI = {
|
||||||
|
'outputError': (evt, e) => {
|
||||||
|
switch(e) {
|
||||||
|
case 'goodreads-error': evt.reply('Error talking to GoodReads.'); return;
|
||||||
|
case 'book-not-found': evt.reply(dbot.t('gr_nobook')); return;
|
||||||
|
case 'no-description': evt.reply('No description was found for the book you asked for.'); return;
|
||||||
|
case 'author-not-found': evt.reply(dbot.t('gr_noauthor')); return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(e);
|
||||||
|
evt.reply('Something went wrong and I don\'t know what.');
|
||||||
|
},
|
||||||
|
|
||||||
|
'formatProfile': profile => {
|
||||||
|
var shelves = {};
|
||||||
|
_.each(profile.user_shelves.user_shelf, shelf => {
|
||||||
|
shelves[shelf.name] = shelf.book_count['_'];
|
||||||
|
});
|
||||||
|
profile.user_shelves = shelves;
|
||||||
|
return profile;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.api = {
|
||||||
|
'findBook': async term => {
|
||||||
|
//https://www.goodreads.com/search/index.xml
|
||||||
|
var body = await rp({
|
||||||
|
uri: this.apiRoot + '/search/index.xml',
|
||||||
|
qs: {
|
||||||
|
key: this.config.api_key,
|
||||||
|
q: term.split(' ').join('+')
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var response = await parseString(body, { explicitArray: false });
|
||||||
|
if(!_.has(response, 'GoodreadsResponse')) throw 'goodreads-error';
|
||||||
|
|
||||||
|
var result = response.GoodreadsResponse.search.results;
|
||||||
|
if(!result || !_.has(result, 'work')) throw 'book-not-found';
|
||||||
|
if(!result.work[0]) throw 'book-not-found';
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: result.work[0].best_book.id['_'],
|
||||||
|
title: result.work[0].best_book.title,
|
||||||
|
author: result.work[0].best_book.author.name,
|
||||||
|
rating: result.work[0].average_rating
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
'getSummaryForBook': async id => {
|
||||||
|
//https://www.goodreads.com/book/show.xml
|
||||||
|
var body = await rp({
|
||||||
|
uri: this.apiRoot + '/book/show.xml',
|
||||||
|
qs: {
|
||||||
|
key: this.config.api_key,
|
||||||
|
id: id
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var response = await parseString(body, { explicitArray: false });
|
||||||
|
if(!_.has(response, 'GoodreadsResponse')) throw 'goodreads-error';
|
||||||
|
|
||||||
|
var result = response.GoodreadsResponse.book;
|
||||||
|
if(!result) throw 'book-not-found';
|
||||||
|
if(!_.has(result, 'description')) throw 'no-description';
|
||||||
|
|
||||||
|
return result.description;
|
||||||
|
},
|
||||||
|
|
||||||
|
'findAuthor': async term => {
|
||||||
|
//https://www.goodreads.com/api/author_url/<ID>
|
||||||
|
var body = await rp({
|
||||||
|
url: this.apiRoot + '/api/author_url/' + term,
|
||||||
|
qs: {
|
||||||
|
key: this.config.api_key
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var response = await parseString(body, {explicitArray: false });
|
||||||
|
if(!_.has(response, 'GoodreadsResponse')) throw 'goodreads-error';
|
||||||
|
|
||||||
|
var result = response.GoodreadsResponse.author;
|
||||||
|
if(!result) throw 'author-not-found';
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: result['$'].id,
|
||||||
|
author: result.name
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
'getProfileById': async id => {
|
||||||
|
//https://www.goodreads.com/user/show.xml
|
||||||
|
try {
|
||||||
|
var body = await rp({
|
||||||
|
url: this.apiRoot + '/user/show.xml',
|
||||||
|
qs: {
|
||||||
|
key: this.config.api_key,
|
||||||
|
id: id
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
if(e.statusCode && e.statusCode == 404) {
|
||||||
|
throw 'user-not-found';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
var response = await parseString(body, { explicitArray: false });
|
||||||
|
if(!_.has(response, 'GoodreadsResponse')) throw 'goodreads-error';
|
||||||
|
|
||||||
|
var result = response.GoodreadsResponse.user;
|
||||||
|
if(!result) throw 'user-not-found';
|
||||||
|
|
||||||
|
return this.internalAPI.formatProfile(result);
|
||||||
|
},
|
||||||
|
|
||||||
|
'getProfileByName': async username => {
|
||||||
|
//https://www.goodreads.com/user/show.xml
|
||||||
|
try {
|
||||||
|
var body = await rp({
|
||||||
|
url: this.apiRoot + '/user/show.xml',
|
||||||
|
qs: {
|
||||||
|
key: this.config.api_key,
|
||||||
|
username: username
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
if(e.statusCode && e.statusCode == 404) {
|
||||||
|
throw 'user-not-found';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
var response = await parseString(body, { explicitArray: false });
|
||||||
|
if(!_.has(response, 'GoodreadsResponse')) throw 'goodreads-error';
|
||||||
|
|
||||||
|
var result = response.GoodreadsResponse.user;
|
||||||
|
if(!result) throw 'user-not-found';
|
||||||
|
|
||||||
|
return this.internalAPI.formatProfile(result);
|
||||||
|
},
|
||||||
|
|
||||||
|
'getShelfForUserId': async (id, shelf) => {
|
||||||
|
//https://www.goodreads.com/review/list.xml?v=2
|
||||||
|
var body = await rp({
|
||||||
|
url: this.apiRoot + '/review/list.xml',
|
||||||
|
qs: {
|
||||||
|
v: '2',
|
||||||
|
key: this.config.api_key,
|
||||||
|
id: id,
|
||||||
|
shelf: shelf
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var response = await parseString(body, { explicitArray: false });
|
||||||
|
if(!_.has(response, 'GoodreadsResponse')) throw 'goodreads-error';
|
||||||
|
|
||||||
|
let result = response.GoodreadsResponse.reviews.review;
|
||||||
|
if(!result) return [];
|
||||||
|
|
||||||
|
if(!_.isArray(result)) {
|
||||||
|
result = [result];
|
||||||
|
}
|
||||||
|
|
||||||
|
return _.map(result, r => {
|
||||||
|
return {
|
||||||
|
id: r.book.id['_'],
|
||||||
|
title: r.book.title_without_series
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.commands = {
|
||||||
|
'~book' : async evt => {
|
||||||
|
try {
|
||||||
|
var book = await this.api.findBook(evt.input[1]);
|
||||||
|
evt.reply(dbot.t('gr_book', {
|
||||||
|
author: book.author,
|
||||||
|
title: book.title,
|
||||||
|
rating: book.rating,
|
||||||
|
link: this.apiRoot + '/book/show/' + book.id
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
catch(e) { this.internalAPI.outputError(evt, e); }
|
||||||
|
},
|
||||||
|
|
||||||
|
'~booksummary': async evt => {
|
||||||
|
try {
|
||||||
|
var book = await this.api.findBook(evt.input[1]);
|
||||||
|
var summary = await this.api.getSummaryForBook(book.id);
|
||||||
|
evt.reply(dbot.t('gr_summary', {
|
||||||
|
title: book.title,
|
||||||
|
summary: summary,
|
||||||
|
link: this.apiRoot + '/book/show/' + book.id
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
catch(e) { this.internalAPI.outputError(evt, e); }
|
||||||
|
},
|
||||||
|
|
||||||
|
'~author' : async evt => {
|
||||||
|
try {
|
||||||
|
evt.reply(dbot.t('gr_author', await this.api.findAuthor(evt.input[1])));
|
||||||
|
}
|
||||||
|
catch(e) { this.internalAPI.outputError(evt, e); }
|
||||||
|
},
|
||||||
|
|
||||||
|
'~reading': async (evt, profile) => {
|
||||||
|
try {
|
||||||
|
let books = await this.api.getShelfForUserId(profile.id, 'currently-reading');
|
||||||
|
var booksCount = books.length;
|
||||||
|
if(!booksCount) {
|
||||||
|
evt.reply(dbot.t('gr_not_reading', { user: evt.rUser.currentNick }));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let tooMany = booksCount > 5;
|
||||||
|
if (tooMany) books = _.sample(books, 5);
|
||||||
|
|
||||||
|
evt.reply(dbot.t('gr_is_reading', { user: evt.rUser.currentNick, count: booksCount }));
|
||||||
|
_.each(books, b => {
|
||||||
|
evt.reply(ostr = b.title + ' - https://www.goodreads.com/book/show/' + b.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (tooMany) {
|
||||||
|
evt.reply('... And ' + (booksCount - 5) + ' more - https://www.goodreads.com/review/list/' + profile.id + '?shelf=currently-reading');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(e) { this.internalAPI.outputError(evt, e); }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.commands['~book'].regex = [/^book (.*)/, 2];
|
||||||
|
this.commands['~booksummary'].regex = [/^booksummary (.*)/, 2];
|
||||||
|
this.commands['~author'].regex = [/^author ([\d\w\s-]*)/, 2];
|
||||||
|
|
||||||
|
this.commands['~reading'].requiresProfile = true;
|
||||||
|
|
||||||
|
_.each(this.commands, ((cmd, cmdName) => {
|
||||||
|
if(cmd.requiresProfile) {
|
||||||
|
this.commands[cmdName] = (async evt => {
|
||||||
|
var grUsername = evt.rProfile.goodreads;
|
||||||
|
|
||||||
|
if(!grUsername) {
|
||||||
|
evt.reply(evt.rUser.currentNick + ': Set a Goodreads username with "~set goodreads username"');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let grId = evt.rProfile.goodreads_id;
|
||||||
|
|
||||||
|
try {
|
||||||
|
var profile;
|
||||||
|
if(grId) {
|
||||||
|
profile = await this.api.getProfileById(grId);
|
||||||
|
} else {
|
||||||
|
profile = await this.api.getProfileByName(grUsername);
|
||||||
|
grId = profile.id;
|
||||||
|
dbot.api.profile.setProperty(evt.server, evt.user, 'goodreads_id', grId, function(){});
|
||||||
|
}
|
||||||
|
|
||||||
|
await cmd(evt, profile);
|
||||||
|
}
|
||||||
|
catch(e) {
|
||||||
|
if(e === 'user-not-found') evt.reply('User not found. Is your GoodReads username set correctly?');
|
||||||
|
else this.internalAPI.outputError(evt, e);
|
||||||
|
}
|
||||||
|
}).bind(this);
|
||||||
|
}
|
||||||
|
}).bind(this))
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
exports.fetch = dbot => new GoodReads(dbot);
|
23
modules-stock/goodreads/strings.json
Normal file
23
modules-stock/goodreads/strings.json
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"gr_book": {
|
||||||
|
"en": "[{title} by {author} - {rating}] - {link}"
|
||||||
|
},
|
||||||
|
"gr_summary": {
|
||||||
|
"en": "[{title}] - {summary} - {link}"
|
||||||
|
},
|
||||||
|
"gr_author": {
|
||||||
|
"en": "[{author}] - https://www.goodreads.com/author/show/{id}"
|
||||||
|
},
|
||||||
|
"gr_nobook": {
|
||||||
|
"en": "No book by that name was found."
|
||||||
|
},
|
||||||
|
"gr_noauthor": {
|
||||||
|
"en": "No author by that name was found."
|
||||||
|
},
|
||||||
|
"gr_not_reading": {
|
||||||
|
"en": "{user} is not currently reading any books."
|
||||||
|
},
|
||||||
|
"gr_is_reading": {
|
||||||
|
"en": "{user} is currently reading the following {count} books:"
|
||||||
|
}
|
||||||
|
}
|
6
modules-stock/goodreads/usage.json
Normal file
6
modules-stock/goodreads/usage.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"~book": "~book [bookname] - returns the title, author, rating, and GoodReads link",
|
||||||
|
"~booksummary": "~booksummary [bookname] - returns the summary for the requested book",
|
||||||
|
"~author": "~author [authorname] - returns the GoodReads link for the requested author",
|
||||||
|
"~reading": "~reading - displays up to 5 of the books you are currently reading"
|
||||||
|
}
|
26
modules-stock/ignore/README.md
Normal file
26
modules-stock/ignore/README.md
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
## Ignore
|
||||||
|
|
||||||
|
Ignore modules.
|
||||||
|
|
||||||
|
### Description
|
||||||
|
|
||||||
|
Commands with which users can choose to ignore listeners and commands from
|
||||||
|
certain modules persistently, by storing their choices in the database. This is
|
||||||
|
an interface for the JSBot ignoreTag functionality which actually implements
|
||||||
|
the ignoration.
|
||||||
|
|
||||||
|
### Configuration
|
||||||
|
|
||||||
|
All modules may return with them an 'ignorable' property, which defines whether
|
||||||
|
or not their functionality may be ignored by users.
|
||||||
|
|
||||||
|
### Commands
|
||||||
|
|
||||||
|
#### ~ignore [module]
|
||||||
|
Ignore a given module. If the user does not specify a module, or provides an
|
||||||
|
invalid one a list of modules which are available to ignore will be given.
|
||||||
|
|
||||||
|
#### ~unignore [module]
|
||||||
|
Unignore a previously ignored module. If the user does not specify a module, or
|
||||||
|
provides an invalid choice a list of modules which are currently ignored will be
|
||||||
|
given.
|
49
modules-stock/ignore/api.js
Normal file
49
modules-stock/ignore/api.js
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
var _ = require('underscore')._;
|
||||||
|
|
||||||
|
var api = function(dbot) {
|
||||||
|
return {
|
||||||
|
// Is user ignoring command/module?
|
||||||
|
'isUserIgnoring': function(user, item, callback) {
|
||||||
|
this.internalAPI.isUserImpeded(user, item, 'ignores', callback);
|
||||||
|
},
|
||||||
|
|
||||||
|
// Is user banned from command/module?
|
||||||
|
'isUserBanned': function(user, item, callback) {
|
||||||
|
this.internalAPI.isUserImpeded(user, item, 'bans', callback);
|
||||||
|
},
|
||||||
|
|
||||||
|
// Is channel ignoring module?
|
||||||
|
// TODO: Command support
|
||||||
|
'isChannelIgnoring': function(channelName, item, callback) {
|
||||||
|
var isIgnoring = false,
|
||||||
|
channel = false;
|
||||||
|
|
||||||
|
this.db.search('channel_ignores', {
|
||||||
|
'server': server,
|
||||||
|
'name': channel
|
||||||
|
}, function(result) {
|
||||||
|
channel = result;
|
||||||
|
}, function(err) {
|
||||||
|
if(!err && channel && _.include(channel.ignores, item)) {
|
||||||
|
isIgnoring = true;
|
||||||
|
}
|
||||||
|
callback(isIgnoring);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
// Resolve a nick and return their user and ignores object
|
||||||
|
'getUserIgnores': function(user, callback) {
|
||||||
|
this.db.read('ignores', user.id, function(err, ignores) {
|
||||||
|
if(!err && ignores) {
|
||||||
|
callback(false, ignores);
|
||||||
|
} else {
|
||||||
|
callback(true, null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.fetch = function(dbot) {
|
||||||
|
return api(dbot);
|
||||||
|
};
|
6
modules-stock/ignore/config.json
Normal file
6
modules-stock/ignore/config.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"ignorable": false,
|
||||||
|
"dependencies": [ "users" ],
|
||||||
|
"dbKeys": [ "ignores", "bans" ],
|
||||||
|
"dbType": "redis"
|
||||||
|
}
|
304
modules-stock/ignore/ignore.js
Normal file
304
modules-stock/ignore/ignore.js
Normal file
@ -0,0 +1,304 @@
|
|||||||
|
/**
|
||||||
|
* Module Name: Ignore
|
||||||
|
* Description: Handles commands in which users can choose to ignore listeners
|
||||||
|
* and commands from certain modules. It also populates the JSBot instance with
|
||||||
|
* this information, since that actually performs the ignorance. Also provides
|
||||||
|
* commands for moderators to choose the bot to ignore certain channels.
|
||||||
|
*/
|
||||||
|
var _ = require('underscore')._,
|
||||||
|
databank = require('databank'),
|
||||||
|
uuid = require('node-uuid'),
|
||||||
|
NoSuchThingError = databank.NoSuchThingError;
|
||||||
|
|
||||||
|
var ignore = function(dbot) {
|
||||||
|
this.internalAPI = {
|
||||||
|
'isUserImpeded': function(user, item, by, callback) {
|
||||||
|
this.api.getUserIgnores(user, function(err, ignores) {
|
||||||
|
var isImpeded = false;
|
||||||
|
if(!err && ignores) {
|
||||||
|
if(_.has(dbot.commands, item) && !_.include(ignores[by], item)) {
|
||||||
|
item = dbot.commands[item].module;
|
||||||
|
}
|
||||||
|
if(_.include(ignores[by], item) || _.include(ignores[by], '*')) {
|
||||||
|
isImpeded = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
callback(isImpeded);
|
||||||
|
});
|
||||||
|
}.bind(this)
|
||||||
|
};
|
||||||
|
|
||||||
|
var commands = {
|
||||||
|
'~ignore': function(event) {
|
||||||
|
var module = event.params[1];
|
||||||
|
var ignorableModules = _.chain(dbot.modules)
|
||||||
|
.filter(function(module, name) {
|
||||||
|
return dbot.config.modules[module].ignorable === true;
|
||||||
|
})
|
||||||
|
.pluck('name')
|
||||||
|
.value();
|
||||||
|
|
||||||
|
if(_.isUndefined(module)) {
|
||||||
|
event.reply(dbot.t('ignore_usage', {
|
||||||
|
'user': event.user,
|
||||||
|
'modules': ignorableModules.join(', ')
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
if(module == '*' || _.include(ignorableModules, module)) {
|
||||||
|
this.api.getUserIgnores(event.rUser, function(err, ignores) {
|
||||||
|
if(!ignores) {
|
||||||
|
ignores = {
|
||||||
|
'id': event.rUser.id,
|
||||||
|
'ignores': [],
|
||||||
|
'bans': []
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!_.include(ignores.ignores, module)) {
|
||||||
|
ignores.ignores.push(module);
|
||||||
|
this.db.save('ignores', event.rUser.id, ignores, function(err) {
|
||||||
|
if(!err) {
|
||||||
|
dbot.instance.ignoreTag(event.user, module);
|
||||||
|
event.reply(dbot.t('ignored', {
|
||||||
|
'user': event.user,
|
||||||
|
'module': module
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t('already_ignoring', { 'user': event.user }));
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t('invalid_ignore', { 'user': event.user }));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
'~unignore': function(event) {
|
||||||
|
var module = event.params[1];
|
||||||
|
|
||||||
|
this.api.getUserIgnores(event.rUser, function(err, ignores) {
|
||||||
|
if(err || !ignores || _.isUndefined(module)) {
|
||||||
|
if(ignores) {
|
||||||
|
event.reply(dbot.t('unignore_usage', {
|
||||||
|
'user': event.user,
|
||||||
|
'modules': ignores.ignores.join(', ')
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t('empty_unignore_usage', {
|
||||||
|
'user': event.user
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(_.include(ignores.ignores, module)) {
|
||||||
|
ignores.ignores = _.without(ignores.ignores, module);
|
||||||
|
this.db.save('ignores', event.rUser.id, ignores, function(err) {
|
||||||
|
if(!err) {
|
||||||
|
dbot.instance.removeIgnore(event.user, module)
|
||||||
|
event.reply(dbot.t('unignored', {
|
||||||
|
'user': event.user,
|
||||||
|
'module': module
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t('invalid_unignore', { 'user': event.user }));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
},
|
||||||
|
|
||||||
|
'~ban': function(event) {
|
||||||
|
var nick = event.input[1],
|
||||||
|
item = event.input[2];
|
||||||
|
|
||||||
|
if(item == '*' || _.include(dbot.config.moduleNames, item) || _.include(dbot.commands, item)) {
|
||||||
|
dbot.api.users.resolveUser(event.server, nick, function(err, user) {
|
||||||
|
this.api.getUserIgnores(user, function(err, ignores) {
|
||||||
|
if(!ignores) {
|
||||||
|
ignores = {
|
||||||
|
'id': user.id,
|
||||||
|
'ignores': [],
|
||||||
|
'bans': []
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!_.include(ignores.bans, item)) {
|
||||||
|
ignores.bans.push(item);
|
||||||
|
this.db.save('ignores', user.id, ignores, function(err) {
|
||||||
|
if(!err) {
|
||||||
|
event.reply(dbot.t('banned_success', {
|
||||||
|
'user': event.user,
|
||||||
|
'banned': nick,
|
||||||
|
'module': item
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t('already_banned', {
|
||||||
|
'user': event.user,
|
||||||
|
'banned': nick
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
}.bind(this));
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t('invalid_ban', { 'user': event.user }));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
'~unban': function(event) {
|
||||||
|
var nick = event.input[1],
|
||||||
|
item = event.input[2];
|
||||||
|
|
||||||
|
dbot.api.users.resolveUser(event.server, nick, function(err, user) {
|
||||||
|
this.api.getUserIgnores(user, function(err, ignores) {
|
||||||
|
if(err || !ignores) {
|
||||||
|
event.reply(dbot.t('invalid_unban', {
|
||||||
|
'user': event.user,
|
||||||
|
'banned': nick
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
if(_.include(ignores.bans, item)) {
|
||||||
|
ignores.bans = _.without(ignores.bans, item);
|
||||||
|
this.db.save('ignores', user.id, ignores, function(err) {
|
||||||
|
event.reply(dbot.t('unbanned_success', {
|
||||||
|
'user': event.user,
|
||||||
|
'banned': nick,
|
||||||
|
'module': item
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t('invalid_unban', {
|
||||||
|
'user': event.user,
|
||||||
|
'banned': nick
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
}.bind(this));
|
||||||
|
},
|
||||||
|
|
||||||
|
'~ignorechannel': function(event) {
|
||||||
|
var channelName = event.input[1],
|
||||||
|
module = event.input[2];
|
||||||
|
|
||||||
|
// Ignoring the value of 'ignorable' at the moment
|
||||||
|
if(module == '*' || _.include(dbot.config.moduleNames, module)) {
|
||||||
|
var channel = false;
|
||||||
|
|
||||||
|
this.db.search('channel_ignores', {
|
||||||
|
'server': event.server,
|
||||||
|
'name': channelName
|
||||||
|
}, function(result) {
|
||||||
|
channel = result;
|
||||||
|
}, function(err) {
|
||||||
|
if(!channel) {
|
||||||
|
var id = uuid.v4();
|
||||||
|
channel = {
|
||||||
|
'id': id,
|
||||||
|
'server': event.server,
|
||||||
|
'name': channelName,
|
||||||
|
'ignores': []
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!_.include(channel.ignores, module)) {
|
||||||
|
channel.ignores.push(module);
|
||||||
|
this.db.save('channel_ignores', channel.id, channel, function(err) {
|
||||||
|
dbot.instance.ignoreTag(channel.name, module);
|
||||||
|
event.reply(dbot.t('ignoring_channel', {
|
||||||
|
'module': module,
|
||||||
|
'channel': channelName
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t('already_ignoring_channel', {
|
||||||
|
'module': module,
|
||||||
|
'channel': channelName
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t('module_not_exist', { 'module': module }));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
'~unignorechannel': function(event) {
|
||||||
|
var channelName = event.input[1],
|
||||||
|
module = event.input[2],
|
||||||
|
channel = false;
|
||||||
|
|
||||||
|
this.db.search('channel_ignores', {
|
||||||
|
'server': event.server,
|
||||||
|
'name': channelName
|
||||||
|
}, function(result) {
|
||||||
|
channel = result;
|
||||||
|
}, function(err) {
|
||||||
|
if(channel && _.include(channel.ignores, module)) {
|
||||||
|
channel.ignores = _.without(channel.ignores, module);
|
||||||
|
this.db.save('channel_ignores', channel.id, channel, function(err) {
|
||||||
|
dbot.instance.removeIgnore(channel.name, module);
|
||||||
|
event.reply(dbot.t('unignoring_channel', {
|
||||||
|
'module': module,
|
||||||
|
'channel': channelName
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t('not_ignoring_channel', {
|
||||||
|
'module': module,
|
||||||
|
'channel': channelName
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
commands['~ban'].regex = [/^ban ([^ ]+) ([^ ]+)$/, 3];
|
||||||
|
commands['~unban'].regex = [/^unban ([^ ]+) ([^ ]+)$/, 3];
|
||||||
|
commands['~ignorechannel'].regex = [/^ignorechannel ([^ ]+) ([^ ]+)$/, 3];
|
||||||
|
commands['~unignorechannel'].regex = [/^unignorechannel ([^ ]+) ([^ ]+)$/, 3];
|
||||||
|
|
||||||
|
commands['~ban'].access = 'power_user';
|
||||||
|
commands['~unban'].access = 'power_user';
|
||||||
|
commands['~ignorechannel'].access = 'moderator';
|
||||||
|
commands['~unignorechannel'].access = 'moderator';
|
||||||
|
|
||||||
|
this.commands = commands;
|
||||||
|
|
||||||
|
this.onLoad = function() {
|
||||||
|
dbot.instance.clearIgnores();
|
||||||
|
|
||||||
|
this.db.scan('ignores', function(ignores) {
|
||||||
|
dbot.api.users.getUser(ignores.id, function(err, user) {
|
||||||
|
if(user) {
|
||||||
|
_.each(ignores.ignores, function(module) {
|
||||||
|
dbot.instance.ignoreTag(user.currentNick, module);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, function(err) { });
|
||||||
|
|
||||||
|
this.db.scan('channel_ignores', function(channel) {
|
||||||
|
_.each(channel.ignores, function(module) {
|
||||||
|
dbot.instance.ignoreTag(channel.name, module);
|
||||||
|
});
|
||||||
|
}, function(err) { });
|
||||||
|
|
||||||
|
dbot.api.event.addHook('new_current_nick', function(user, oldNick) {
|
||||||
|
this.api.getUserIgnores(user, function(err, ignores) {
|
||||||
|
if(ignores) {
|
||||||
|
_.each(ignores.ignores, function(module) {
|
||||||
|
dbot.instance.removeIgnore(oldNick, module);
|
||||||
|
dbot.instance.ignoreTag(user.currentNick, module);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
}.bind(this));
|
||||||
|
}.bind(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.fetch = function(dbot) {
|
||||||
|
return new ignore(dbot);
|
||||||
|
};
|
183
modules-stock/ignore/strings.json
Normal file
183
modules-stock/ignore/strings.json
Normal file
@ -0,0 +1,183 @@
|
|||||||
|
{
|
||||||
|
"ignore_usage": {
|
||||||
|
"en": "{user}: Usage: ~ignore [module]. Modules you can ignore are: {modules}.",
|
||||||
|
"es": "{user}: Modo de empleo: ~ignore [módulo]. Módulos que tú puedes ignorar son: {modules}.",
|
||||||
|
"na'vi": "{user}: Sar: ~ignore ['u]. U, nga ke tìng mikyun: {modules}.",
|
||||||
|
"cy": "{user}: Defnydd: ~ignore [modiwl]. Modiwlau a allech anwybyddu yw: {modules}.",
|
||||||
|
"nl": "{user}: Gebruik: ~ignore [module]. Modules die negeert kunnen worden zijn: {modules}.",
|
||||||
|
"de": "{user}: Benutzung: ~ignore [module]. Module, die ausgeschaltet werden können: {modules}.",
|
||||||
|
"fr": "{user}: Utilisation: ~ignore [module]. Les modules que vous pouvez ignorer sont: {modules}.",
|
||||||
|
"it": "{user}: Uso: ~ignore [module]. I moduli che puoi ignorare sono: {modules}."
|
||||||
|
},
|
||||||
|
"already_ignoring": {
|
||||||
|
"en": "{user}: You're already ignoring that module.",
|
||||||
|
"es": "{user}: Ya ignoras este módulo.",
|
||||||
|
"na'vi": "{user}: 'uri nga ke tìng mikyun srekrr.",
|
||||||
|
"cy": "{user}: Mi rwyt ti'n anwybyddu'r modiwl yna'n barod.",
|
||||||
|
"nl": "{user}: Je negeert deze module al.",
|
||||||
|
"de": "{user}: Dieses Modul ist bereits ausgeschaltet.",
|
||||||
|
"fr": "{user}: Vous ignorez déjà ce module.",
|
||||||
|
"it": "{user}: Stai già ignorando questo modulo"
|
||||||
|
},
|
||||||
|
"ignored": {
|
||||||
|
"en": "{user}: Now ignoring {module}.",
|
||||||
|
"es": "{user}: Estás ignorando {module}.",
|
||||||
|
"na'vi": "{user}: Nga ke terìng mikyun {module}ne set.",
|
||||||
|
"cy": "{user}: Nawr yn anwybyddu {module}",
|
||||||
|
"nl": "{user}: {module} wordt nu genegeerd.",
|
||||||
|
"de": "{user}: {module} wird nun ausgeschaltet.",
|
||||||
|
"fr": "{user}: {module} désormais ignoré.",
|
||||||
|
"it": "{user}: {module} sarà adesso ignorato"
|
||||||
|
},
|
||||||
|
"invalid_ignore": {
|
||||||
|
"en": "{user}: That isn't a valid module name.",
|
||||||
|
"es": "{user}: Ese no es un nombre de un módulo valido.",
|
||||||
|
"na'vi": "{user}: Tsatstxo eyawr ke lu.",
|
||||||
|
"cy": "{user}: Nid oedd hwna'n modiwl dilys",
|
||||||
|
"nl": "{user}: Dat is geen geldige modulenaam.",
|
||||||
|
"de": "{user}: Dies ist kein Name eines Moduls.",
|
||||||
|
"fr": "{user}: Ceci ne correspond pas à un nom de module valide.",
|
||||||
|
"it": "{user}: Questo non è un nome di modulo valido"
|
||||||
|
},
|
||||||
|
"unignore_usage": {
|
||||||
|
"en": "{user}: Usage: ~unignore [module]. Modules you are currently ignoring: {modules}.",
|
||||||
|
"es": "{user}: Modo de empleo: ~unignore [módulo]. Módulos que ignoras ahora mismo: {modules}.",
|
||||||
|
"na'vi": "{user}: Sar: ~unignore ['u]. Uri, nga ke terìng mikyun: {modules}.",
|
||||||
|
"cy": "{user}: Defnydd: ~unignore [modiwl]. Modiwlau rydech yn anwybyddu ar hyn o bryd: {modules}",
|
||||||
|
"nl": "{user}: Gebruik: ~unignore [module]. Modules die momenteel worden genegeerd: {modules}.",
|
||||||
|
"de": "{user}: Benutzung: ~unignore [module]. Module, die im Moment ausgeschaltet sind: {modules}.",
|
||||||
|
"fr": "{user}: Utilisation: ~unignore [module]. Modules que vous ignorez actuellement: {modules}.",
|
||||||
|
"it": "{user}: Uso: ~unignore [module]. Module che ignori attualmente: {modules}."
|
||||||
|
},
|
||||||
|
"empty_unignore_usage": {
|
||||||
|
"en": "{user}: Usage: ~unignore [module].",
|
||||||
|
"es": "{user}: Modo de empleo: ~unignore [módulo].",
|
||||||
|
"na'vi": "{user}: Sar: ~unignore ['u].",
|
||||||
|
"cy": "{user}: Defnydd: ~unignore [modiwl].",
|
||||||
|
"nl": "{user}: Gebruik: ~unignore [module].",
|
||||||
|
"de": "{user}: Benutzung: ~unignore [module].",
|
||||||
|
"fr": "{user}: Utilisation: ~unignore [module].",
|
||||||
|
"it": "{user}: Uso: ~unignore [module]."
|
||||||
|
},
|
||||||
|
"invalid_unignore": {
|
||||||
|
"en": "{user}: You're not ignoring that module or it doesn't exist.",
|
||||||
|
"es": "{user}: No ignoras este módulo o no existe.",
|
||||||
|
"na'vi":"{user}: Nga terìng mikyun fu fì'ul fìtsengit ke tok.",
|
||||||
|
"cy": "{user}: Nid wyt ti'n anwybyddu'r modiwl yna neu nid yw e'n bodoli",
|
||||||
|
"nl": "{user}: Deze module bestaat niet of wordt niet genegeerd.",
|
||||||
|
"de": "{user}: Dieses Modul ist entweder ausgeschaltet oder existiert nicht.",
|
||||||
|
"fr": "{user}: Vous n'ignorez pas ce module ou il n'existe pas.",
|
||||||
|
"it": "{user}: Non stai ignorando questo modulo o non esiste."
|
||||||
|
},
|
||||||
|
"unignored": {
|
||||||
|
"en": "{user}: No longer ignoring {module}.",
|
||||||
|
"es": "{user}: Ya no ignoras {module}.",
|
||||||
|
"na'vi": "{user}: Nga terìng mikyun {module}ne set",
|
||||||
|
"cy": "{user}: Ddim yn anwybyddu {module} bellach",
|
||||||
|
"nl": "{user}: {module} wordt niet langer genegeerd.",
|
||||||
|
"de": "{user}: {module} ist nicht länger ausgeschaltet.",
|
||||||
|
"fr": "{user}: {module} n'est plus ignoré à présent.",
|
||||||
|
"it": "{user}: {module} non viene attualmente più ignorato"
|
||||||
|
},
|
||||||
|
"ban_usage": {
|
||||||
|
"en": "{user}: Usage: ~ban [user] [module/command]. Use * for all modules and commands.",
|
||||||
|
"cy": "{user}: Defnydd: ~ban [defnyddiwr] [modiwl/gorchymyn]. Defnyddio * am pob modiwlau a gorchmynion.",
|
||||||
|
"nl": "{user}: Gebruik: ~ban [gebruiker] [module/commando]. Gebruik * voor alle modules en alle commandos.",
|
||||||
|
"de": "{user}: Benutzung ~ban [Benutzer] [module/Befehl]. Benutze * für alle Module und Befehle.",
|
||||||
|
"fr": "{user}: Utilisation: ~ban [user] [module/command]. Utilisez * pour tous les modules et commandes.",
|
||||||
|
"it": "{user}: Uso: ~ban [user] [module/command]. Utilizza * per tutti i moduli e commandi."
|
||||||
|
},
|
||||||
|
"already_banned": {
|
||||||
|
"en": "{user}: {banned} is already banned from that module.",
|
||||||
|
"cy": "{user}: {banned} eisoes wedi ei wahardd o'r modiwl.",
|
||||||
|
"nl": "{user}: {banned} is al geband van deze module.",
|
||||||
|
"de": "{user}: {banned} ist bereits von diesem Modul gebannt.",
|
||||||
|
"fr": "{user}: {banned} est déjà interdit d'utiliser ce module.",
|
||||||
|
"it": "{user}: {banned} è già bandito da usare questo modulo."
|
||||||
|
},
|
||||||
|
"banned_success": {
|
||||||
|
"en": "{user}: {banned} is now banned from {module}.",
|
||||||
|
"cy": "{user}: {banned} ei wahardd yn awr am {module}.",
|
||||||
|
"nl": "{user}: {banned} mag {module} nu niet meer gebruiken.",
|
||||||
|
"de": "{user}: {banned} ist nun von {module} gebannt.",
|
||||||
|
"fr": "{user}: {banned} est maintenant interdit d'utiliser {module}.",
|
||||||
|
"it": "{user}: {banned} è stato adesso bandito da usare {module}."
|
||||||
|
},
|
||||||
|
"invalid_ban": {
|
||||||
|
"en": "{user}: That isn't a valid module name.",
|
||||||
|
"cy": "{user}: Nid oedd hwna'n modiwl dilys",
|
||||||
|
"nl": "{user}: Dat is geen geldige modulenaam.",
|
||||||
|
"de": "{user}: Dies ist kein Name eines Moduls.",
|
||||||
|
"fr": "{user}: Ceci n'est pas un nom de module valide.",
|
||||||
|
"it": "{user}: Queso non è il nome di un modulo valido."
|
||||||
|
},
|
||||||
|
"unban_usage": {
|
||||||
|
"en": "{user}: Usage: ~unban [user] [module].",
|
||||||
|
"cy": "{user}: Defnydd: ~unban [defnyddiwr] [modiwl].",
|
||||||
|
"nl": "{user}: Gebruik: ~unban [gebruiker] [module].",
|
||||||
|
"de": "{user}: Benutzung: ~unban [Benutzer] [module].",
|
||||||
|
"fr": "{user}: Utilisation: ~unban [user] [module].",
|
||||||
|
"it": "{user}: Uso: ~unban [user] [module]."
|
||||||
|
},
|
||||||
|
"invalid_unban": {
|
||||||
|
"en": "{user}: {banned} is not banned from that module or it doesn't exist.",
|
||||||
|
"cy": "{user}: Nid oedd {banned} wedi ei wahardd o'r modiwl, neu nid yw'n bodoli.",
|
||||||
|
"nl": "{user}: {banned} is niet geband van die module of de module bestaat niet.",
|
||||||
|
"de": "{user}: {banned} ist von diesem Modul nicht gebannt, oder es existiert nicht.",
|
||||||
|
"fr": "{user}: {banned} n'est pas interdit d'utiliser ce module, ou il n'existe pas.",
|
||||||
|
"it": "{user}: {banned} non è stato bandito da questo modulo o non esiste."
|
||||||
|
},
|
||||||
|
"unbanned_success": {
|
||||||
|
"en": "{user}: {banned} is no longer banned from {module}.",
|
||||||
|
"cy": "{user}: Nid yw {banned} yn cael ei wahardd mwyach.",
|
||||||
|
"nl": "{user}: {banned} mag {module} weer gebruiken.",
|
||||||
|
"de": "{user}: {banned} wurde von {module} entbannt.",
|
||||||
|
"fr": "{user}: {banned} n'est plus interdit d'utiliser {module}.",
|
||||||
|
"it": "{user}: {banned} non è più bandito dall' utilizzare {module}."
|
||||||
|
},
|
||||||
|
"ignoring_channel": {
|
||||||
|
"en": "Now ignoring {module} in {channel}.",
|
||||||
|
"na'vi": "Oe ke stayawm {module}ur mì {channel}",
|
||||||
|
"cy": "Bellach yn anwybyddu {module} yn {channel}.",
|
||||||
|
"nl": "{module} wordt nu genegeerd in {channel}.",
|
||||||
|
"de": "{module} in {channel} ist nun ausgeschaltet.",
|
||||||
|
"fr": "{module} dans {channel} maintenant ignoré.",
|
||||||
|
"it": "{module} in {channel} viene adesso ignorato."
|
||||||
|
},
|
||||||
|
"already_ignoring_channel": {
|
||||||
|
"en": "Already ignoring {module} in {channel}.",
|
||||||
|
"na'vi": "Oe ke stayawm {module}ur mì {channel} li",
|
||||||
|
"cy": "Eisoes anwybyddu {module} yn {channel}",
|
||||||
|
"nl": "{module} wordt al genegeerd in {channel}.",
|
||||||
|
"de": "{module} in {channel} ist bereits ausgeschaltet.",
|
||||||
|
"fr": "{module} dans {channel} déjà ignoré.",
|
||||||
|
"it": "{module} in {channel} già ignorato."
|
||||||
|
},
|
||||||
|
"module_not_exist": {
|
||||||
|
"en": "{module} isn't loaded or doesn't exist.",
|
||||||
|
"na'vi": "Oel ke omum teri {module}it fu {module} ke fkeytok",
|
||||||
|
"cy": "Dydy {module} ddim yn lwythodd, neu ddim yn bodoli.",
|
||||||
|
"nl": "{module} is niet geladen of bestaat niet.",
|
||||||
|
"de": "{module} ist nicht geladen oder existiert nicht.",
|
||||||
|
"fr": "{module} n'est pas chargé ou n'existe pas.",
|
||||||
|
"it": "{module} non caricato o non esiste"
|
||||||
|
},
|
||||||
|
"unignoring_channel": {
|
||||||
|
"en": "No longer ignoring {module} in {channel}.",
|
||||||
|
"na'vi": "Oel stayawm {module}ur mì {channel} set.",
|
||||||
|
"cy": "Nid anwybyddu {module} yn {channel} mwyach.",
|
||||||
|
"nl": "{module} wordt niet meer genegeerd in {channel}.",
|
||||||
|
"de": "{module} in {channel} ist nicht länger ausgeschaltet.",
|
||||||
|
"fr": "{module} dans {channel} n'est plus ignoré à présent.",
|
||||||
|
"it": "{module} in {channel} non viene più ignorato."
|
||||||
|
},
|
||||||
|
"not_ignoring_channel": {
|
||||||
|
"en": "{module} wasn't being ignored in {channel}.",
|
||||||
|
"na'vi": "Oel stayawm {module}ur mì {channel} li.",
|
||||||
|
"cy": "Nid yw {module} yn cael ei anwybyddu yn {channel}.",
|
||||||
|
"nl": "{module} werd niet genegeerd in {channel}.",
|
||||||
|
"de": "{module} war in {channel} nicht ausgeschaltet.",
|
||||||
|
"fr": "{module} n'était pas ignoré dans {channel}.",
|
||||||
|
"it": "{module} non veniva ignorato in {channel}"
|
||||||
|
}
|
||||||
|
}
|
65
modules-stock/imgur/README.md
Normal file
65
modules-stock/imgur/README.md
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
## imgur
|
||||||
|
|
||||||
|
Various imgur functionality.
|
||||||
|
|
||||||
|
### Description
|
||||||
|
|
||||||
|
Posts information on imgur links which are pasted into the channel and provides
|
||||||
|
functionality to generate a random imgur link.
|
||||||
|
|
||||||
|
### Config
|
||||||
|
|
||||||
|
#### imagelength: 5
|
||||||
|
Length of slugs generated by the random imgur functionality.
|
||||||
|
|
||||||
|
#### nsfwwarn: true
|
||||||
|
Warn that images generated by the ~ri command may be NSFW.
|
||||||
|
|
||||||
|
#### apikey
|
||||||
|
Key to use with the imgur API.
|
||||||
|
|
||||||
|
#### highscore: ricount
|
||||||
|
Quote category to use for a 'highscore;' used to run games with the web
|
||||||
|
/random page, by storing a highscore based on some arbitrary rule in the
|
||||||
|
chosen quote category (say, how far can you get before seeing a turtle). Then,
|
||||||
|
on the imgur random page you can press 'c' to see a countdown towards the last
|
||||||
|
stored value in the highscore quote category. If you beat the highscore, simply
|
||||||
|
add the winning score to the quote category.
|
||||||
|
|
||||||
|
### Commands
|
||||||
|
|
||||||
|
#### ~ri
|
||||||
|
Generate a random imgur image and post a link to it in the channel.
|
||||||
|
|
||||||
|
### API
|
||||||
|
|
||||||
|
#### getRandomImage(callback)
|
||||||
|
Generate a random imgur image by generating random slugs and then testing for
|
||||||
|
their existence until it finds one which exists (and hasn't been deleted).
|
||||||
|
Callback is given with two parameters, the URL of the generated image, and the
|
||||||
|
slug for the generated image.
|
||||||
|
|
||||||
|
#### getImageInfoString(slug, callback)
|
||||||
|
Return a string containing info about the image with the given slug from the
|
||||||
|
imgur API. Callback is called with one argument, the info string.
|
||||||
|
|
||||||
|
#### getImageInfo(slug, callback)
|
||||||
|
Return data from the imgur API on an image with the given slug. Callback is
|
||||||
|
called with one argument, the information returned by the API.
|
||||||
|
|
||||||
|
### Web
|
||||||
|
|
||||||
|
#### /imgur/random
|
||||||
|
|
||||||
|
A web page which loads a random image from imgur. You can press the space bar to
|
||||||
|
load a new image, and information about the images are shown on the top-left of
|
||||||
|
the page. You can press 'c' to view a highscore count (as documented above).
|
||||||
|
|
||||||
|
#### /imgur/stats
|
||||||
|
|
||||||
|
Show statistics on the total use of the imgur module.
|
||||||
|
|
||||||
|
### Hooks
|
||||||
|
|
||||||
|
#### link
|
||||||
|
Posts information about an imgur link when one is linked in the channel.
|
14
modules-stock/imgur/config.json
Normal file
14
modules-stock/imgur/config.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"dbKeys": [ "imgur" ],
|
||||||
|
"dependencies": [ "web", "api", "link" ],
|
||||||
|
"imagelength": 5,
|
||||||
|
"ricachelength": 7,
|
||||||
|
"nsfwwarn": true,
|
||||||
|
"apikey": "86fd3a8da348b65",
|
||||||
|
"highscore": "ricount",
|
||||||
|
"autoadd": {
|
||||||
|
"e49e686582ce3f60cb51d00c10924861": "facebookman",
|
||||||
|
"b11b634c74562bcd4e5d17b0d90987be": "raffleguy"
|
||||||
|
},
|
||||||
|
"outputPrefix": "\u00038imgur\u000f"
|
||||||
|
}
|
330
modules-stock/imgur/imgur.js
Normal file
330
modules-stock/imgur/imgur.js
Normal file
@ -0,0 +1,330 @@
|
|||||||
|
/**
|
||||||
|
* Module Name: imgur
|
||||||
|
* Description: Various imgur functionality
|
||||||
|
*/
|
||||||
|
|
||||||
|
var _ = require('underscore')._,
|
||||||
|
request = require('request'),
|
||||||
|
async = require('async'),
|
||||||
|
crypto = require('crypto'),
|
||||||
|
humanise = require('humanize');
|
||||||
|
|
||||||
|
var imgur = function(dbot) {
|
||||||
|
this.ApiRoot = 'https://api.imgur.com/3/';
|
||||||
|
this.ExcludeRes = [
|
||||||
|
{ 'w': 800, 'h': 600 },
|
||||||
|
{ 'w': 1024, 'h': 768 },
|
||||||
|
{ 'w': 1280, 'h': 768 },
|
||||||
|
{ 'w': 1280, 'h': 960 },
|
||||||
|
{ 'w': 1366, 'h': 768 },
|
||||||
|
{ 'w': 1600, 'h': 900 },
|
||||||
|
{ 'w': 1680, 'h': 1050 },
|
||||||
|
{ 'w': 1920, 'h': 1080 },
|
||||||
|
{ 'w': 1024, 'h': 640 }
|
||||||
|
];
|
||||||
|
this.riCache = [];
|
||||||
|
|
||||||
|
this.internalAPI = {
|
||||||
|
'infoString': function(imgData) {
|
||||||
|
info = '';
|
||||||
|
if(!_.isUndefined(imgData) && _.has(imgData, 'data') && !_.isUndefined(imgData.data.type)) {
|
||||||
|
imgData = imgData.data;
|
||||||
|
if(imgData.title) {
|
||||||
|
info += imgData.title + ' - ';
|
||||||
|
}
|
||||||
|
if(imgData.type) {
|
||||||
|
if(imgData.animated) {
|
||||||
|
info += 'an animated ' + imgData.type.split('/')[1] + ' with ';
|
||||||
|
} else {
|
||||||
|
info += 'a ' + imgData.type.split('/')[1] + ' with ';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
info += 'an image with ';
|
||||||
|
}
|
||||||
|
info += imgData.views + ' views (';
|
||||||
|
info += imgData.width + 'x' + imgData.height + ')';
|
||||||
|
|
||||||
|
info += ' ('+humanise.filesize(imgData.size)+')';
|
||||||
|
}
|
||||||
|
|
||||||
|
return info;
|
||||||
|
}.bind(this),
|
||||||
|
|
||||||
|
'albumInfoString': function(albumData) {
|
||||||
|
var info = '';
|
||||||
|
if(!_.isUndefined(albumData) && _.has(albumData, 'data') && !_.isUndefined(albumData.data.id)) {
|
||||||
|
albumData = albumData.data;
|
||||||
|
if(albumData.title) {
|
||||||
|
info += albumData.title + ' - ';
|
||||||
|
}
|
||||||
|
if(albumData.description) {
|
||||||
|
info += albumData.description.split('\n')[0] + ' is ';
|
||||||
|
}
|
||||||
|
info += 'an album with ' + albumData.images_count + ' images ';
|
||||||
|
info += 'and ' + albumData.views + ' views';
|
||||||
|
if(albumData.nsfw) {
|
||||||
|
info += ' - NSFW';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}.bind(this),
|
||||||
|
|
||||||
|
'galleryInfoString': function(galData) {
|
||||||
|
var info = '';
|
||||||
|
if(!_.isUndefined(galData) && _.has(galData, 'data') && !_.isUndefined(galData.data.is_album)) {
|
||||||
|
if(galData.data.is_album === true) {
|
||||||
|
info = this.internalAPI.albumInfoString(galData);
|
||||||
|
} else {
|
||||||
|
info = this.internalAPI.infoString(galData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return info;
|
||||||
|
}.bind(this)
|
||||||
|
};
|
||||||
|
|
||||||
|
this.api = {
|
||||||
|
'getRandomImage': function(callback) {
|
||||||
|
var random = function(len) {
|
||||||
|
var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
|
||||||
|
return len ? chars.charAt(~~(Math.random()*chars.length)) + random(len-1) : "";
|
||||||
|
};
|
||||||
|
|
||||||
|
var ext = [ 'gif', 'png', 'jpg' ];
|
||||||
|
var testSlug = random(5);
|
||||||
|
var testUrl = 'http://i.imgur.com/' +
|
||||||
|
testSlug +
|
||||||
|
'.' + ext[_.random(0, ext.length - 1)],
|
||||||
|
fbman = false;
|
||||||
|
dbot.db.imgur.totalHttpRequests += 1;
|
||||||
|
|
||||||
|
request(testUrl, function(error, response, body) {
|
||||||
|
// 492 is body.length of a removed image
|
||||||
|
if(!error && response.statusCode == 200 && body.length != 492) {
|
||||||
|
dbot.db.imgur.totalImages += 1;
|
||||||
|
var hash = crypto.createHash('md5').update(body).digest("hex");
|
||||||
|
if(_.has(dbot.modules, 'quotes')){
|
||||||
|
// autoadd: {"abcdef": "facebookman"}
|
||||||
|
if(_.has(dbot.config.modules.imgur.autoadd,hash)){
|
||||||
|
fbman = true;
|
||||||
|
var category = this.config.autoadd[hash];
|
||||||
|
if (_.contains(category, testUrl)){
|
||||||
|
// there's probably less than 62^5 chance of this happening
|
||||||
|
} else {
|
||||||
|
dbot.api.quotes.addQuote(category, testUrl,
|
||||||
|
dbot.config.name, function() { });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
callback(testUrl, testSlug, hash, fbman);
|
||||||
|
} else {
|
||||||
|
this.api.getRandomImage(callback);
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
},
|
||||||
|
|
||||||
|
'getGoodRandomImage': function(callback) {
|
||||||
|
this.api.getRandomImage(function(url, slug, hash, fbman) {
|
||||||
|
this.api.getImageInfo(slug, function(imgData) {
|
||||||
|
if(!_.isUndefined(imgData) &&
|
||||||
|
imgData.data &&
|
||||||
|
imgData.data.height > 500 && imgData.data.width > 500 &&
|
||||||
|
!_.any(this.ExcludeRes, function(res) {
|
||||||
|
return imgData.data.height == res.h && imgData.data.width == res.w;
|
||||||
|
})) {
|
||||||
|
callback(url, imgData);
|
||||||
|
} else if(fbman === true) {
|
||||||
|
callback(url, imgData);
|
||||||
|
} else {
|
||||||
|
this.api.getGoodRandomImage(callback);
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
}.bind(this));
|
||||||
|
},
|
||||||
|
|
||||||
|
'getImageInfoString': function(slug, callback) {
|
||||||
|
this.api.getImageInfo(slug, function(imgData) {
|
||||||
|
callback(this.internalAPI.infoString(imgData));
|
||||||
|
}.bind(this));
|
||||||
|
},
|
||||||
|
|
||||||
|
'getImageInfo': function(slug, callback) {
|
||||||
|
request.get({
|
||||||
|
'url': 'https://api.imgur.com/3/image/' + slug + '.json',
|
||||||
|
'json': true,
|
||||||
|
'headers': {
|
||||||
|
'Authorization': 'Client-ID ' + this.config.apikey
|
||||||
|
}
|
||||||
|
}, function(err, response, body) {
|
||||||
|
dbot.db.imgur.totalApiRequests += 1;
|
||||||
|
callback(body);
|
||||||
|
}.bind(this));
|
||||||
|
},
|
||||||
|
|
||||||
|
'getAlbumInfo': function(slug, callback) {
|
||||||
|
request.get({
|
||||||
|
'url': 'https://api.imgur.com/3/album/' + slug + '.json',
|
||||||
|
'json': true,
|
||||||
|
'headers': {
|
||||||
|
'Authorization': 'Client-ID ' + this.config.apikey
|
||||||
|
}
|
||||||
|
}, function(err, response, body) {
|
||||||
|
this.db.totalApiRequests += 1;
|
||||||
|
callback(body);
|
||||||
|
}.bind(this));
|
||||||
|
},
|
||||||
|
|
||||||
|
'getGalleryInfo': function(slug, callback) {
|
||||||
|
request.get({
|
||||||
|
'url': 'https://api.imgur.com/3/gallery/' + slug + '.json',
|
||||||
|
'json': true,
|
||||||
|
'headers': {
|
||||||
|
'Authorization': 'Client-ID ' + this.config.apikey
|
||||||
|
}
|
||||||
|
}, function(err, response, body) {
|
||||||
|
this.db.totalApiRequests += 1;
|
||||||
|
callback(body);
|
||||||
|
}.bind(this));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.api['getRandomImage'].external = true;
|
||||||
|
this.api['getRandomImage'].extMap = [ 'callback' ];
|
||||||
|
this.api['getImageInfoString'].external = true;
|
||||||
|
this.api['getImageInfoString'].extMap = [ 'slug', 'callback' ];
|
||||||
|
|
||||||
|
this.commands = {
|
||||||
|
'~ri': function(event) {
|
||||||
|
var local = event.user;
|
||||||
|
if(event.params[1]) {
|
||||||
|
local = event.params.splice(1, event.params.length - 1).join(' ').trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
var postImage = function(link, imgData) {
|
||||||
|
var info = this.internalAPI.infoString(imgData);
|
||||||
|
event.reply('['+this.config.outputPrefix + '] ' + local + ': ' + link + ' [' + info + ']');
|
||||||
|
}.bind(this);
|
||||||
|
var newCacheImage = function(link, imgData) {
|
||||||
|
this.riCache.push([link, imgData]);
|
||||||
|
}.bind(this);
|
||||||
|
var callback = postImage;
|
||||||
|
|
||||||
|
if(this.riCache.length > 0) {
|
||||||
|
var image = this.riCache.pop();
|
||||||
|
postImage(image[0], image[1]);
|
||||||
|
callback = newCacheImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.api.getGoodRandomImage(callback);
|
||||||
|
},
|
||||||
|
|
||||||
|
// Legacy RI
|
||||||
|
'~lri': function(event) {
|
||||||
|
var local = event.user;
|
||||||
|
if(event.params[1]) {
|
||||||
|
local = event.params.splice(1, event.params.length - 1).join(' ').trim();
|
||||||
|
}
|
||||||
|
this.api.getRandomImage(function(link, slug) {
|
||||||
|
this.api.getImageInfo(slug, function(imgData) {
|
||||||
|
var info = this.internalAPI.infoString(imgData);
|
||||||
|
event.reply('['+this.config.outputPrefix + '] ' + local + ': ' + link + ' [' + info + ']');
|
||||||
|
}.bind(this));
|
||||||
|
}.bind(this));
|
||||||
|
},
|
||||||
|
|
||||||
|
// Super RI
|
||||||
|
'~sri': function(event) {
|
||||||
|
var local = event.user;
|
||||||
|
if(event.params[1]) {
|
||||||
|
local = event.params.splice(1, event.params.length - 1).join(' ').trim();
|
||||||
|
}
|
||||||
|
request.get({
|
||||||
|
'url': this.ApiRoot + 'gallery/random/random/',
|
||||||
|
'json': true,
|
||||||
|
'headers': {
|
||||||
|
'Authorization': 'Client-ID ' + this.config.apikey
|
||||||
|
}
|
||||||
|
}, function(err, response, body) {
|
||||||
|
if(!_.isUndefined(body) && body.data && body.data[0] != undefined) {
|
||||||
|
var num = _.random(0, body.data.length - 1);
|
||||||
|
this.api.getGalleryInfo(body.data[num].id, function(gal) {
|
||||||
|
event.reply('['+this.config.outputPrefix + '] ' + local + ': ' + gal.data.link + ' [' +
|
||||||
|
this.internalAPI.galleryInfoString(gal) + ']');
|
||||||
|
}.bind(this));
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
},
|
||||||
|
|
||||||
|
'~imgur': function(event) {
|
||||||
|
var term = event.input[1];
|
||||||
|
request.get({
|
||||||
|
'url': this.ApiRoot + 'gallery/search/',
|
||||||
|
'json': true,
|
||||||
|
'headers': {
|
||||||
|
'Authorization': 'Client-ID ' + this.config.apikey
|
||||||
|
},
|
||||||
|
'qs': {
|
||||||
|
'q': term
|
||||||
|
}
|
||||||
|
}, function(err, response, body) {
|
||||||
|
if(!_.isUndefined(body) && body.data && body.data[0] != undefined) {
|
||||||
|
var num = _.random(0, body.data.length - 1);
|
||||||
|
this.api.getGalleryInfo(body.data[num].id, function(gal) {
|
||||||
|
event.reply(dbot.t('imgurinfo', {
|
||||||
|
'info': this.internalAPI.galleryInfoString(gal)
|
||||||
|
}) + ' - ' + gal.data.link);
|
||||||
|
}.bind(this));
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t('imgur_noresults'));
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.commands['~imgur'].regex = [/^imgur ([\d\w\s-]*)/, 2];
|
||||||
|
|
||||||
|
this.onLoad = function() {
|
||||||
|
var imgurHandler = function(matches, name, callback) {
|
||||||
|
if(matches[1]) {
|
||||||
|
var dataCallback = function(data) {
|
||||||
|
var info;
|
||||||
|
if(name == 'imgurimage') {
|
||||||
|
info = this.internalAPI.infoString(data);
|
||||||
|
} else if(name == 'imguralbum') {
|
||||||
|
info = this.internalAPI.albumInfoString(data);
|
||||||
|
} else if(name == 'imgurgallery') {
|
||||||
|
info = this.internalAPI.galleryInfoString(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(info) callback(dbot.t('imgurinfo', { 'info': info }));
|
||||||
|
}.bind(this);
|
||||||
|
|
||||||
|
if(name == 'imgurimage') {
|
||||||
|
this.api.getImageInfo(matches[1], dataCallback);
|
||||||
|
} else if(name == 'imguralbum') {
|
||||||
|
this.api.getAlbumInfo(matches[1], dataCallback);
|
||||||
|
} else if(name == 'imgurgallery') {
|
||||||
|
this.api.getGalleryInfo(matches[1], dataCallback);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.bind(this);
|
||||||
|
|
||||||
|
dbot.api.link.addHandler('imguralbum', /https?:\/\/imgur\.com\/a\/([a-zA-Z0-9]+)/, imgurHandler);
|
||||||
|
dbot.api.link.addHandler('imgurgallery', /https?:\/\/imgur\.com\/gallery\/([a-zA-Z0-9]+)/, imgurHandler);
|
||||||
|
dbot.api.link.addHandler('imgurimage', /https?:\/\/i\.imgur\.com\/([a-zA-Z0-9]+)\.([jpg|png|gif])/, imgurHandler);
|
||||||
|
dbot.api.link.addHandler('imgurimage', /https?:\/\/imgur\.com\/([a-zA-Z0-9]+)/, imgurHandler);
|
||||||
|
|
||||||
|
async.times(this.config.ricachelength, function(n, next) {
|
||||||
|
this.api.getGoodRandomImage(function(link, imgData) {
|
||||||
|
this.riCache.push([ link, imgData ]);
|
||||||
|
next();
|
||||||
|
}.bind(this));
|
||||||
|
}.bind(this), function() {});
|
||||||
|
|
||||||
|
if(!_.has(dbot.db.imgur, 'totalHttpRequests')) dbot.db.imgur.totalHttpRequests = 0;
|
||||||
|
if(!_.has(dbot.db.imgur, 'totalApiRequests')) dbot.db.imgur.totalApiRequests = 0;
|
||||||
|
if(!_.has(dbot.db.imgur, 'totalImages')) dbot.db.imgur.totalImages = 0;
|
||||||
|
this.db = dbot.db.imgur;
|
||||||
|
}.bind(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.fetch = function(dbot) {
|
||||||
|
return new imgur(dbot);
|
||||||
|
}
|
23
modules-stock/imgur/pages.js
Normal file
23
modules-stock/imgur/pages.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
var _ = require('underscore')._;
|
||||||
|
|
||||||
|
var pages = function(dbot) {
|
||||||
|
return {
|
||||||
|
'/imgur/random': function(req, res) {
|
||||||
|
var highScore = 0;
|
||||||
|
res.render('imgurr', { "highscore" : highScore });
|
||||||
|
},
|
||||||
|
|
||||||
|
'/imgur/stats': function(req, res) {
|
||||||
|
res.render('imgurstats', {
|
||||||
|
'name': dbot.config.name,
|
||||||
|
'totalHttpRequests': this.db.totalHttpRequests,
|
||||||
|
'totalApiRequests': this.db.totalApiRequests,
|
||||||
|
'totalImages': this.db.totalImages
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.fetch = function(dbot) {
|
||||||
|
return pages(dbot);
|
||||||
|
};
|
22
modules-stock/imgur/strings.json
Normal file
22
modules-stock/imgur/strings.json
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"nsfw": {
|
||||||
|
"en": "might be NSFW",
|
||||||
|
"na'vi": "kxawm ke wivìntxu evengur",
|
||||||
|
"cy": "Gallai fod yn anniogel ar gwaith",
|
||||||
|
"nl": "bevat mogelijk gevoelige beelden",
|
||||||
|
"de": "Könnte 18+ Material enthalten",
|
||||||
|
"fr": "peut être risqué pour le travail (NSFW)",
|
||||||
|
"it": "può essere rischioso al lavoro (NSFW)"
|
||||||
|
},
|
||||||
|
"imgurinfo": {
|
||||||
|
"en": "[{info}]",
|
||||||
|
"de": "[{info}]",
|
||||||
|
"fr": "[{info}]",
|
||||||
|
"it": "[{info}]"
|
||||||
|
},
|
||||||
|
"imgur_noresults": {
|
||||||
|
"en": "No results found.",
|
||||||
|
"de": "Kein Suchergebnis.",
|
||||||
|
"it": "Nessun risultato"
|
||||||
|
}
|
||||||
|
}
|
40
modules-stock/js/README.md
Normal file
40
modules-stock/js/README.md
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
## JS
|
||||||
|
|
||||||
|
Run JavaScript.
|
||||||
|
|
||||||
|
### Description
|
||||||
|
|
||||||
|
This module provides two commands which allow the execution of Javascript code
|
||||||
|
from the bot.
|
||||||
|
|
||||||
|
### Commands
|
||||||
|
|
||||||
|
#### ~js [code]
|
||||||
|
For regular users, there is the *~js* command, which is completely sandboxed,
|
||||||
|
but can still be used for calculation and the like.
|
||||||
|
|
||||||
|
> ~js Array(16).join('wat'-1) + " Batman!";
|
||||||
|
'NaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaNNaN Batman!'
|
||||||
|
|
||||||
|
This feature is fairly safe as the user doesn't have access to anything
|
||||||
|
dangerous, and is safe from infinite loops or locking DBot up because the code
|
||||||
|
which is run is killed if it does not finish within a short amount of time.
|
||||||
|
|
||||||
|
#### ~ajs [code]
|
||||||
|
For administrators, the incredibly useful *~ajs* command is also available. The
|
||||||
|
input for this command is simply 'eval'-ed and therefore has full access to
|
||||||
|
DBot's memory. Of course, this is incredibly unsafe, but I find it rather fun;
|
||||||
|
remember to only give extremely trusted friends administrator access to your
|
||||||
|
DBot instance, as there's nothing to stop them wiping the database or probably
|
||||||
|
even your hard drive - if you're worried about that kind of thing, do not load
|
||||||
|
this module.
|
||||||
|
|
||||||
|
However, it's useful for many things, such as administrative activity for
|
||||||
|
which there isn't a command in the admin module. For example, you could hot-add
|
||||||
|
a new administrator like this:
|
||||||
|
|
||||||
|
> ~ajs dbot.admin.push('batman');
|
||||||
|
2
|
||||||
|
|
||||||
|
You can also use it for debugging, or even adding new commands while DBot is
|
||||||
|
running.
|
9
modules-stock/js/config.json
Normal file
9
modules-stock/js/config.json
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"commands": {
|
||||||
|
"~js": {
|
||||||
|
"disabled": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"dependencies": [ "command" ],
|
||||||
|
"ignorable": true
|
||||||
|
}
|
51
modules-stock/js/js.js
Normal file
51
modules-stock/js/js.js
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
/**
|
||||||
|
* Module Name: JS
|
||||||
|
* Description: Allows users to run sandboxed JS code, printing the result in
|
||||||
|
* the channel. Also allows admins to run un-sandboxed Javascript code with
|
||||||
|
* access to the DepressionBot instance memory.
|
||||||
|
*/
|
||||||
|
var vm = require('vm');
|
||||||
|
var sbox = require('sandbox');
|
||||||
|
|
||||||
|
var js = function(dbot) {
|
||||||
|
var commands = {
|
||||||
|
// Run JS code sandboxed, return result to channel.
|
||||||
|
'~js': function(event) {
|
||||||
|
try {
|
||||||
|
var s = new sbox();
|
||||||
|
s.run(event.input[1], function(output) {
|
||||||
|
event.reply(output.result);
|
||||||
|
}.bind(this));
|
||||||
|
} catch(err) {}
|
||||||
|
},
|
||||||
|
|
||||||
|
// Run JS code un-sandboxed, with access to DBot memory (admin-only).
|
||||||
|
'~ajs': function(event) {
|
||||||
|
var callback = function() {
|
||||||
|
var args = Array.prototype.slice.call(arguments);
|
||||||
|
for(var i=0;i<args.length;i++) {
|
||||||
|
var arg = args[i];
|
||||||
|
if(_.isObject(arg) && !_.isArray(arg)) {
|
||||||
|
arg = '[object Object]: ' + _.keys(arg).join(', ');
|
||||||
|
}
|
||||||
|
event.reply('Callback[' + i + ']: ' + arg);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var ret = eval(event.input[1]);
|
||||||
|
if(ret !== undefined) {
|
||||||
|
event.reply(ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
commands['~js'].regex = [/^js (.*)/, 2];
|
||||||
|
commands['~ajs'].regex = [/^ajs (.*)/, 2];
|
||||||
|
commands['~ajs'].access = 'admin';
|
||||||
|
|
||||||
|
this.name = 'js';
|
||||||
|
this.ignorable = true;
|
||||||
|
this.commands = commands;
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.fetch = function(dbot) {
|
||||||
|
return new js(dbot);
|
||||||
|
};
|
4
modules-stock/js/usage.json
Normal file
4
modules-stock/js/usage.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"~js": "~js [command]",
|
||||||
|
"~ajs": "~ajs [command]"
|
||||||
|
}
|
5
modules-stock/karma/config.json
Normal file
5
modules-stock/karma/config.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"announce": [ { "server": "tripsit", "name": "#dbot" } ],
|
||||||
|
"dbKeys": [ "karma" ],
|
||||||
|
"dbType": "redis"
|
||||||
|
}
|
201
modules-stock/karma/karma.js
Normal file
201
modules-stock/karma/karma.js
Normal file
@ -0,0 +1,201 @@
|
|||||||
|
/**
|
||||||
|
* Module Name: Karma
|
||||||
|
* Description: Thanking, with Karma!
|
||||||
|
*/
|
||||||
|
var _ = require('underscore')._;
|
||||||
|
|
||||||
|
var karma = function(dbot) {
|
||||||
|
this.lastKarma = {};
|
||||||
|
|
||||||
|
this.internalAPI = {
|
||||||
|
'getKarma': function(item, callback) {
|
||||||
|
this.db.read('karma', item.toLowerCase(), callback);
|
||||||
|
}.bind(this),
|
||||||
|
|
||||||
|
'setKarma': function(item, value, callback) {
|
||||||
|
this.db.save('karma', item.toLowerCase(), {
|
||||||
|
'item': item.toLowerCase(),
|
||||||
|
'karma': value
|
||||||
|
}, callback);
|
||||||
|
}.bind(this)
|
||||||
|
};
|
||||||
|
|
||||||
|
this.commands = {
|
||||||
|
'karma': function(event) {
|
||||||
|
var item = event.params[1] || event.user;
|
||||||
|
this.internalAPI.getKarma(item, function(err, karma) {
|
||||||
|
if(!err && karma) {
|
||||||
|
karma = karma.karma;
|
||||||
|
} else {
|
||||||
|
karma = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.reply(dbot.t('karma', {
|
||||||
|
'item': item,
|
||||||
|
'karma': karma
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
'setkarma': function(event) {
|
||||||
|
var item = event.params[1],
|
||||||
|
value = parseInt(event.params[2]);
|
||||||
|
|
||||||
|
this.internalAPI.setKarma(item, value, function(err, karma) {
|
||||||
|
event.reply(dbot.t('newkarma', {
|
||||||
|
'item': item,
|
||||||
|
'value': value
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
'unkarmaiest': function(event) {
|
||||||
|
var karmas = {};
|
||||||
|
this.db.scan('karma', function(karma) {
|
||||||
|
if(karma && !_.isUndefined(karma.item)) {
|
||||||
|
karmas[karma.item] = karma.karma;
|
||||||
|
}
|
||||||
|
}.bind(this), function(err) {
|
||||||
|
var qSizes = _.chain(karmas)
|
||||||
|
.pairs()
|
||||||
|
.sortBy(function(category) { return category[1]; })
|
||||||
|
.first(10)
|
||||||
|
.value();
|
||||||
|
|
||||||
|
var qString = 'Unkarmaiest: ';
|
||||||
|
for(var i=0;i<qSizes.length;i++) {
|
||||||
|
qString += qSizes[i][0] + " (" + qSizes[i][1] + "), ";
|
||||||
|
}
|
||||||
|
|
||||||
|
event.reply(qString.slice(0, -2));
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
'karmaiest': function(event) {
|
||||||
|
var karmas = {};
|
||||||
|
this.db.scan('karma', function(karma) {
|
||||||
|
if(karma && !_.isUndefined(karma.item)) {
|
||||||
|
karmas[karma.item] = karma.karma;
|
||||||
|
}
|
||||||
|
}.bind(this), function(err) {
|
||||||
|
var qSizes = _.chain(karmas)
|
||||||
|
.pairs()
|
||||||
|
.sortBy(function(category) { return category[1]; })
|
||||||
|
.reverse()
|
||||||
|
.first(10)
|
||||||
|
.value();
|
||||||
|
|
||||||
|
var qString = 'Karmaiest: ';
|
||||||
|
for(var i=0;i<qSizes.length;i++) {
|
||||||
|
qString += qSizes[i][0] + " (" + qSizes[i][1] + "), ";
|
||||||
|
}
|
||||||
|
|
||||||
|
event.reply(qString.slice(0, -2));
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
'wattest': function(event) {
|
||||||
|
var karmas = {};
|
||||||
|
this.db.scan('karma', function(karma) {
|
||||||
|
if(karma && !_.isUndefined(karma.item)) {
|
||||||
|
if(karma.item.match(/_wat$/)) {
|
||||||
|
karmas[karma.item] = karma.karma;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.bind(this), function(err) {
|
||||||
|
var qSizes = _.chain(karmas)
|
||||||
|
.pairs()
|
||||||
|
.sortBy(function(category) { return category[1]; })
|
||||||
|
.reverse()
|
||||||
|
.first(10)
|
||||||
|
.value();
|
||||||
|
|
||||||
|
var qString = 'Karmaiest: ';
|
||||||
|
for(var i=0;i<qSizes.length;i++) {
|
||||||
|
qString += qSizes[i][0] + " (" + qSizes[i][1] + "), ";
|
||||||
|
}
|
||||||
|
|
||||||
|
event.reply(qString.slice(0, -2));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
this.commands.setkarma.access = 'admin';
|
||||||
|
|
||||||
|
this.listener = function(event) {
|
||||||
|
dbot.api.ignore.isUserBanned(event.rUser, 'karma', function(isBanned) {
|
||||||
|
if(!isBanned) {
|
||||||
|
var match = event.message.match(/^(.+)(\+\+|\-\-)$/);
|
||||||
|
if(event.user !== dbot.config.name && match && match[1].length < 25) {
|
||||||
|
match[1] = match[1].replace(/(\+|\-)/g,'').replace(/:/g,'').trim();
|
||||||
|
|
||||||
|
var timeout = 5000;
|
||||||
|
/* if(event.channel.name == '#stims' || event.channel.name == '##meth' || event.channel.name == '##sweden') {
|
||||||
|
timeout = 20000;
|
||||||
|
}*/
|
||||||
|
if(_.has(this.lastKarma, event.rUser.id) && this.lastKarma[event.rUser.id]+ timeout > Date.now()) {
|
||||||
|
return event.reply('Try again in a few seconds : - )');
|
||||||
|
} else if(event.rUser.currentNick.toLowerCase() === match[1].toLowerCase() || event.rUser.primaryNick.toLowerCase() === match[1].toLowerCase()) {
|
||||||
|
return event.reply('Stop playing with yourself : - )');
|
||||||
|
} else if(event.channel == event.user) {
|
||||||
|
return event.reply('Don\'t be a Secretive Sally : - )');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(event.channel.name == '##wat') {
|
||||||
|
match[1] = match[1].replace(/_wat$/, '');
|
||||||
|
match[1] += '_wat';
|
||||||
|
}
|
||||||
|
|
||||||
|
this.internalAPI.getKarma(match[1], function(err, karma) {
|
||||||
|
if(!karma) {
|
||||||
|
karma = 0;
|
||||||
|
} else {
|
||||||
|
karma = karma.karma;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(match[2] === '--') {
|
||||||
|
if(match[1].toLowerCase() =='weed') {
|
||||||
|
karma -= 2;
|
||||||
|
} else {
|
||||||
|
karma -= 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(match[1].toLowerCase() == 'weed') {
|
||||||
|
karma += 2;
|
||||||
|
} else {
|
||||||
|
karma += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.internalAPI.setKarma(match[1], karma, function(err, karma) {
|
||||||
|
this.lastKarma[event.rUser.id] = Date.now();
|
||||||
|
var pre;
|
||||||
|
if(karma.karma > 0) {
|
||||||
|
pre = '[\u00039karma\u000f]';
|
||||||
|
karma.karma = '\u00039 '+karma.karma+'\u000f';
|
||||||
|
} else if(karma.karma < 0) {
|
||||||
|
pre = '[\u00034karma\u000f]';
|
||||||
|
karma.karma = '\u00034 '+karma.karma+'\u000f';
|
||||||
|
} else {
|
||||||
|
pre = '[\u00036karma\u000f]';
|
||||||
|
karma.karma = '\u00036 '+karma.karma+'\u000f';
|
||||||
|
}
|
||||||
|
event.reply(pre + ' ' + dbot.t('newkarma', {
|
||||||
|
'item': match[1],
|
||||||
|
'value': karma.karma
|
||||||
|
}));
|
||||||
|
if(_.has(dbot.modules, 'log')) {
|
||||||
|
dbot.api.log.logWithChannel(event.server, event.channel, event.rUser.primaryNick, event.message);
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
}.bind(this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.bind(this));
|
||||||
|
}.bind(this);
|
||||||
|
this.on = 'PRIVMSG';
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.fetch = function(dbot) {
|
||||||
|
return new karma(dbot);
|
||||||
|
};
|
8
modules-stock/karma/strings.json
Normal file
8
modules-stock/karma/strings.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"karma": {
|
||||||
|
"en": "[karma] {item} has {karma} karma"
|
||||||
|
},
|
||||||
|
"newkarma": {
|
||||||
|
"en": "{item} now has{value} karma"
|
||||||
|
}
|
||||||
|
}
|
29
modules-stock/kick/README.md
Normal file
29
modules-stock/kick/README.md
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
## Kick
|
||||||
|
|
||||||
|
Kicking and kicking-related accessories.
|
||||||
|
|
||||||
|
### Description
|
||||||
|
This module counts the number of times people are kicked from and kick people
|
||||||
|
from channels, and provides commands for viewing this data. It also has the bot
|
||||||
|
attempt to rejoin the channel if it is kicked.
|
||||||
|
|
||||||
|
### Commands
|
||||||
|
|
||||||
|
#### ~kickcount [username]
|
||||||
|
Show the number of times a given user has been kicked and has kicked other
|
||||||
|
people.
|
||||||
|
|
||||||
|
#### ~kickstats
|
||||||
|
Show a list of top kickers and kickees.
|
||||||
|
|
||||||
|
#### ~ckick [#channel] [username] [reason]
|
||||||
|
Kick a user from a channel.
|
||||||
|
|
||||||
|
#### ~cban [#channel] [username] [reason]
|
||||||
|
Ban a user from a channel.
|
||||||
|
|
||||||
|
#### ~nban {optional: Duration in Hours} [username] [reason]
|
||||||
|
Ban a user from the network.
|
||||||
|
|
||||||
|
#### ~nunban [username] [reason]
|
||||||
|
Unban a user from the network.
|
512
modules-stock/kick/commands.js
Normal file
512
modules-stock/kick/commands.js
Normal file
@ -0,0 +1,512 @@
|
|||||||
|
var _ = require('underscore')._,
|
||||||
|
uuid = require('node-uuid');
|
||||||
|
|
||||||
|
var commands = function (dbot) {
|
||||||
|
var commands = {
|
||||||
|
/*** Kick Management ***/
|
||||||
|
'~quiet': function (event) {
|
||||||
|
var server = event.server,
|
||||||
|
quieter = event.rUser,
|
||||||
|
duration = event.input[1],
|
||||||
|
channel = (event.input[2] || event.channel.name).trim(),
|
||||||
|
quietee = event.input[3].trim(),
|
||||||
|
reason = event.input[4] || "N/A";
|
||||||
|
|
||||||
|
this.api.quietUser(server, quieter, duration, channel, quietee, reason, function (response) {
|
||||||
|
event.reply(response);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
'~timeout': function (event) {
|
||||||
|
var server = event.server,
|
||||||
|
quieter = event.rUser,
|
||||||
|
duration = this.config.timeoutTime,
|
||||||
|
channel = event.channel.name,
|
||||||
|
quietee = event.input[1],
|
||||||
|
reason = event.input[2] || "N/A";
|
||||||
|
|
||||||
|
reason += ' #timeout';
|
||||||
|
|
||||||
|
dbot.api.users.resolveUser(server, quietee, function (err, user) {
|
||||||
|
if (!err && user) {
|
||||||
|
if (!_.has(this.recentTimeouts, user.id)) {
|
||||||
|
this.recentTimeouts[user.id] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.recentTimeouts[user.id] += 1;
|
||||||
|
setTimeout(function () {
|
||||||
|
this.recentTimeouts[user.id] -= 1;
|
||||||
|
if (this.recentTimeouts[user.id] == 0) {
|
||||||
|
delete this.recentTimeouts[user.id];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.bind(this), 3600000);
|
||||||
|
|
||||||
|
if (this.recentTimeouts[user.id] == 3) {
|
||||||
|
duration = null;
|
||||||
|
reason += ' #permatimeout';
|
||||||
|
dbot.say(event.server, dbot.config.servers[event.server].admin_channel, quietee + ' has been given three timeouts in the last hour, and so has been quieted indefinitely in ' + channel + '. Please review.');
|
||||||
|
}
|
||||||
|
|
||||||
|
this.api.quietUser(server, quieter, duration, channel, quietee, reason, function (response) {
|
||||||
|
event.reply(response);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.bind(this));
|
||||||
|
},
|
||||||
|
|
||||||
|
'~unquiet': function (event) {
|
||||||
|
var server = event.server,
|
||||||
|
quieter = event.user,
|
||||||
|
channel = (event.input[1] || event.channel.name).trim(),
|
||||||
|
quietee = event.input[2].trim();
|
||||||
|
|
||||||
|
if (_.has(this.hosts[server], quietee)) {
|
||||||
|
if (_.include(this.config.quietBans, channel)) {
|
||||||
|
this.api.unban(server, this.hosts[server][quietee], channel);
|
||||||
|
} else {
|
||||||
|
this.api.unquiet(server, this.hosts[server][quietee], channel);
|
||||||
|
}
|
||||||
|
event.reply(dbot.t('unquieted', {
|
||||||
|
'quietee': quietee
|
||||||
|
}));
|
||||||
|
dbot.api.report.notify('unquiet', server, event.rUser, channel,
|
||||||
|
dbot.t('unquiet_notify', {
|
||||||
|
'unquieter': quieter,
|
||||||
|
'quietee': quietee
|
||||||
|
}), false, quietee);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
'~ckick': function (event) {
|
||||||
|
var server = event.server,
|
||||||
|
kicker = event.user,
|
||||||
|
kickee = event.input[2],
|
||||||
|
channel = event.input[1],
|
||||||
|
reason = event.input[3];
|
||||||
|
|
||||||
|
if (_.isUndefined(channel)) {
|
||||||
|
channel = event.channel.name;
|
||||||
|
}
|
||||||
|
channel = channel.trim();
|
||||||
|
|
||||||
|
this.api.kick(server, kickee, channel, reason + ' (requested by ' + kicker + ')');
|
||||||
|
|
||||||
|
dbot.api.report.notify('kick', server, event.rUser, channel, dbot.t('ckicked', {
|
||||||
|
'kicker': kicker,
|
||||||
|
'kickee': kickee,
|
||||||
|
'reason': reason
|
||||||
|
}), false, kickee);
|
||||||
|
},
|
||||||
|
|
||||||
|
// Kick and ban from all channels on the network.
|
||||||
|
'~nban': function (event) {
|
||||||
|
if (!event.input)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var server = event.server,
|
||||||
|
banner = event.user,
|
||||||
|
timeout = event.input[1],
|
||||||
|
banee = event.input[2],
|
||||||
|
reason = event.input[3],
|
||||||
|
adminChannel = dbot.config.servers[server].admin_channel,
|
||||||
|
channels = _.keys(dbot.instance.connections[server].channels),
|
||||||
|
network = event.server;
|
||||||
|
|
||||||
|
if (this.config.network_name[event.server]) {
|
||||||
|
network = this.config.network_name[event.server];
|
||||||
|
}
|
||||||
|
|
||||||
|
dbot.api.nickserv.getUserHost(event.server, banee, function (host) {
|
||||||
|
// Add host record entry
|
||||||
|
if (host) {
|
||||||
|
var didKill = false;
|
||||||
|
|
||||||
|
if ((reason.match('#line') || reason.match('#specialk') || reason.match('#kline')) && _.include(dbot.access.moderator(), event.rUser.primaryNick)) {
|
||||||
|
didKill = true;
|
||||||
|
var t = ' !P ';
|
||||||
|
if (timeout) {
|
||||||
|
t = ' !T ' + timeout + ' ';
|
||||||
|
}
|
||||||
|
dbot.say(event.server, 'operserv', 'akill add ' + banee + t + banee + ' banned by ' + banner + ': ' + reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do not ban if user was killed - redundant
|
||||||
|
if(!didKill) {
|
||||||
|
// Ban from current channel first
|
||||||
|
this.api.ban(server, host, event.channel);
|
||||||
|
this.api.kick(server, banee, event.channel, reason +
|
||||||
|
' (network-wide ban)');
|
||||||
|
channels = _.without(channels, event.channel);
|
||||||
|
if (!_.isUndefined(adminChannel)) {
|
||||||
|
channels = _.without(channels, adminChannel);
|
||||||
|
} else {
|
||||||
|
adminChannel = event.channel.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ban the user from all channels
|
||||||
|
var i = 0;
|
||||||
|
var banChannel = function (channels) {
|
||||||
|
if (i >= channels.length)
|
||||||
|
return;
|
||||||
|
var channel = channels[i];
|
||||||
|
this.api.ban(server, host, channel);
|
||||||
|
this.api.kick(server, banee, channel, reason +
|
||||||
|
' (network-wide ban)');
|
||||||
|
i++;
|
||||||
|
banChannel(channels);
|
||||||
|
}
|
||||||
|
.bind(this);
|
||||||
|
banChannel(channels);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.hosts[event.server][banee] = host;
|
||||||
|
|
||||||
|
// Create notify string
|
||||||
|
if (!_.isUndefined(timeout)) {
|
||||||
|
timeout = timeout.trim();
|
||||||
|
|
||||||
|
var msTimeout = new Date(new Date().getTime() + (parseFloat(timeout) * 3600000));
|
||||||
|
if (_.has(dbot.modules, 'remind')) {
|
||||||
|
msTimeout = dbot.api.remind.parseTime(timeout);
|
||||||
|
if (!msTimeout) {
|
||||||
|
return event.reply('Invalid time. Remember you must give e.g. 5m now.');
|
||||||
|
}
|
||||||
|
timeout = timeout.replace(/([\d]+)d/, '$1 days').replace(/([\d]+)h/, '$1 hours ').replace(/([\d]+)m/, '$1 minutes ').replace(/([\d]+)s/, '$1 seconds').trim();
|
||||||
|
} else {
|
||||||
|
timeout += ' hours';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do not schedule unbans if the user was killed as no ban was put in place
|
||||||
|
if(!didKill) {
|
||||||
|
if (!_.has(this.tempBans, event.server))
|
||||||
|
this.tempBans[event.server] = {};
|
||||||
|
this.tempBans[event.server][banee] = msTimeout;
|
||||||
|
this.internalAPI.addTempBan(event.server, banee, msTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
var notifyString = dbot.t('tbanned', {
|
||||||
|
'network': network,
|
||||||
|
'banner': banner,
|
||||||
|
'banee': banee,
|
||||||
|
'hours': timeout,
|
||||||
|
'host': host,
|
||||||
|
'reason': reason
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
var notifyString = dbot.t('nbanned', {
|
||||||
|
'network': network,
|
||||||
|
'banner': banner,
|
||||||
|
'banee': banee,
|
||||||
|
'host': host,
|
||||||
|
'reason': reason
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add db entry documenting ban
|
||||||
|
if (this.config.document_bans) {
|
||||||
|
var id = uuid.v4();
|
||||||
|
var banRecord = {
|
||||||
|
'id': id,
|
||||||
|
'time': new Date().getTime(),
|
||||||
|
'server': server,
|
||||||
|
'banee': banee,
|
||||||
|
'banner': banner,
|
||||||
|
'host': host,
|
||||||
|
'reason': reason
|
||||||
|
};
|
||||||
|
this.db.save('nbans', id, banRecord, function () {});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Notify moderators, banee
|
||||||
|
if (!_.isUndefined(adminChannel)) {
|
||||||
|
channels = _.without(channels, adminChannel);
|
||||||
|
} else {
|
||||||
|
adminChannel = event.channel.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
dbot.api.report.notify('ban', server, event.rUser, adminChannel, notifyString, false, banee);
|
||||||
|
dbot.say(event.server, adminChannel, notifyString);
|
||||||
|
|
||||||
|
if (!_.isUndefined(timeout)) {
|
||||||
|
dbot.say(event.server, banee, dbot.t('tbanned_notify', {
|
||||||
|
'network': network,
|
||||||
|
'banner': banner,
|
||||||
|
'reason': reason,
|
||||||
|
'hours': timeout,
|
||||||
|
'admin_channel': adminChannel
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
|
dbot.say(event.server, banee, dbot.t('nbanned_notify', {
|
||||||
|
'network': network,
|
||||||
|
'banner': banner,
|
||||||
|
'reason': reason,
|
||||||
|
'hours': timeout,
|
||||||
|
'admin_channel': adminChannel
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
// err
|
||||||
|
dbot.say(event.server, 'NickServ', 'FREEZE ' + banee + ' ON ' + reason);
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t('no_user', {
|
||||||
|
'user': banee
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.bind(this));
|
||||||
|
},
|
||||||
|
|
||||||
|
'~nunban': function (event) {
|
||||||
|
var unbanee = event.params[1],
|
||||||
|
host = event.params[2] || undefined,
|
||||||
|
unbanner = event.rUser;
|
||||||
|
|
||||||
|
this.api.networkUnban(event.server, unbanee, unbanner, host, function (err) {
|
||||||
|
if (err) {
|
||||||
|
event.reply(dbot.t('nunban_error', {
|
||||||
|
'unbanee': unbanee
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/*** Kick Stats ***/
|
||||||
|
|
||||||
|
// Give the number of times a given user has been kicked and has kicked
|
||||||
|
// other people.
|
||||||
|
'~kickcount': function (event) {
|
||||||
|
var username = event.params[1];
|
||||||
|
|
||||||
|
if (!_.has(dbot.db.kicks, username)) {
|
||||||
|
var kicks = '0';
|
||||||
|
} else {
|
||||||
|
var kicks = dbot.db.kicks[username];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_.has(dbot.db.kickers, username)) {
|
||||||
|
var kicked = '0';
|
||||||
|
} else {
|
||||||
|
var kicked = dbot.db.kickers[username];
|
||||||
|
}
|
||||||
|
|
||||||
|
event.reply(dbot.t('user_kicks', {
|
||||||
|
'user': username,
|
||||||
|
'kicks': kicks,
|
||||||
|
'kicked': kicked
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
|
||||||
|
// Output a list of the people who have been kicked the most and those
|
||||||
|
// who have kicked other people the most.
|
||||||
|
'~kickstats': function (event) {
|
||||||
|
var orderedKickLeague = function (list, topWhat) {
|
||||||
|
var kickArr = _.chain(list)
|
||||||
|
.pairs()
|
||||||
|
.sortBy(function (kick) {
|
||||||
|
return kick[1]
|
||||||
|
})
|
||||||
|
.reverse()
|
||||||
|
.first(10)
|
||||||
|
.value();
|
||||||
|
|
||||||
|
var kickString = "Top " + topWhat + ": ";
|
||||||
|
for (var i = 0; i < kickArr.length; i++) {
|
||||||
|
kickString += kickArr[i][0] + " (" + kickArr[i][1] + "), ";
|
||||||
|
}
|
||||||
|
|
||||||
|
return kickString.slice(0, -2);
|
||||||
|
};
|
||||||
|
|
||||||
|
event.reply(orderedKickLeague(dbot.db.kicks, 'Kicked'));
|
||||||
|
event.reply(orderedKickLeague(dbot.db.kickers, 'Kickers'));
|
||||||
|
},
|
||||||
|
|
||||||
|
'~votequiet': function (event) {
|
||||||
|
var target = event.input[1],
|
||||||
|
reason = event.input[2];
|
||||||
|
|
||||||
|
if (_.has(event.channel.nicks, target)) {
|
||||||
|
dbot.api.users.resolveUser(event.server, target, function (err, user) {
|
||||||
|
if (!err && user) {
|
||||||
|
if (_.include(dbot.access.power_user(), user.primaryNick) || target == dbot.config.name) {
|
||||||
|
return event.reply('User is immune to votequiet.');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_.has(this.voteQuiets, user.id)) {
|
||||||
|
this.voteQuiets[user.id] = {
|
||||||
|
'user': user.id,
|
||||||
|
'reason': reason,
|
||||||
|
'channel': event.channel,
|
||||||
|
'yes': [event.rUser.primaryNick],
|
||||||
|
'no': []
|
||||||
|
};
|
||||||
|
event.reply(event.user + ' has started a vote to quiet ' + target + ' for "' + reason + '." Type either "~voteyes ' + target + '" or "~voteno ' + target + '" in the next 90 seconds.');
|
||||||
|
|
||||||
|
this.voteQuiets[user.id].timer = setTimeout(function () {
|
||||||
|
var vq = this.voteQuiets[user.id];
|
||||||
|
vq.spent = true;
|
||||||
|
if (vq.yes.length >= 3 && vq.no.length < 2) {
|
||||||
|
event.reply('Attempt to quiet ' + target + ' succeeded. Count: Yes (' + vq.yes.length + '). No (' + vq.no.length + ').');
|
||||||
|
|
||||||
|
this.api.quietUser(event.server, event.rUser, '10m', event.channel, target, reason + '[votequiet]', function (response) {
|
||||||
|
clearTimeout(vq.timer);
|
||||||
|
event.reply(response);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
event.reply('Attempt to quiet ' + target + ' failed. Count: Yes (' + vq.yes.length + '). No (' + vq.no.length + ').');
|
||||||
|
}
|
||||||
|
|
||||||
|
var nString = 'A votequiet was attempted on ' + target + ' in ' + event.channel + '. It was initiated by ' + event.rUser.primaryNick + '. ' +
|
||||||
|
vq.yes.join(', ') + ' voted yes (' + vq.yes.length + '). ';
|
||||||
|
if (vq.no.length > 0) {
|
||||||
|
nString += vq.no.join(', ') + ' voted no (' + vq.no.length + ').'
|
||||||
|
}
|
||||||
|
|
||||||
|
dbot.api.report.notify('votequiet', event.server, event.rUser, event.channel, nString, false, target);
|
||||||
|
|
||||||
|
setTimeout(function () {
|
||||||
|
delete this.voteQuiets[user.id];
|
||||||
|
}
|
||||||
|
.bind(this), 600000);
|
||||||
|
}
|
||||||
|
.bind(this), 90000);
|
||||||
|
} else {
|
||||||
|
if (this.voteQuiets[user.id].spent) {
|
||||||
|
event.reply('A votequiet attempt has already been made on this user in the last 10 minutes.');
|
||||||
|
} else {
|
||||||
|
var vq = this.voteQuiets[user.id]
|
||||||
|
if (!_.include(vq.yes, event.rUser.primaryNick)) {
|
||||||
|
vq.yes.push(event.rUser.primaryNick);
|
||||||
|
|
||||||
|
event.reply('There is already a votequiet attempt active for this user, adding yes vote to existing poll.');
|
||||||
|
event.reply('Voted yes on votequiet for ' + target + '. New count: Yes (' + vq.yes.length + '). No (' + vq.no.length + ').');
|
||||||
|
|
||||||
|
if (vq.yes.length == 4) {
|
||||||
|
event.reply('Attempt to quiet ' + target + ' succeeded. Count: Yes (' + vq.yes.length + '). No (' + vq.no.length + ').');
|
||||||
|
this.api.quietUser(event.server, event.rUser, '10m', event.channel, target, reason + '[votequiet]', function (response) {
|
||||||
|
clearTimeout(vq.timer);
|
||||||
|
vq.spent = true;
|
||||||
|
setTimeout(function () {
|
||||||
|
delete this.voteQuiets[user.id];
|
||||||
|
}
|
||||||
|
.bind(this), 600000);
|
||||||
|
event.reply(response);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
event.reply('There is already a votequiet attempt active for this user, and you already voted yes!');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
event.reply('Target does not seem to be in the channel.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.bind(this));
|
||||||
|
} else {
|
||||||
|
event.reply('Target does not seem to be in the channel.');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
'~voteyes': function (event) {
|
||||||
|
var target = event.params[1];
|
||||||
|
|
||||||
|
dbot.api.users.resolveUser(event.server, target, function (err, user) {
|
||||||
|
if (!err && user) {
|
||||||
|
if (user.id == event.rUser.id) {
|
||||||
|
return event.reply('You cannot vote on your own silencing. Be good.');
|
||||||
|
}
|
||||||
|
if (_.has(this.voteQuiets, user.id) && !this.voteQuiets[user.id].spent) {
|
||||||
|
var vq = this.voteQuiets[user.id];
|
||||||
|
if (event.channel != vq.channel) {
|
||||||
|
return event.reply('Vote must be in ' + vq.channel);
|
||||||
|
}
|
||||||
|
if (!_.include(vq.yes, event.rUser.primaryNick) && !_.include(vq.no, event.rUser.primaryNick)) {
|
||||||
|
vq.yes.push(event.rUser.primaryNick);
|
||||||
|
event.reply('Voted yes on votequiet for ' + target + '. New count: Yes (' + vq.yes.length + '). No (' + vq.no.length + ').');
|
||||||
|
|
||||||
|
if (vq.yes.length == 4) {
|
||||||
|
event.reply('Attempt to quiet ' + target + ' succeeded. Count: Yes (' + vq.yes.length + '). No (' + vq.no.length + ').');
|
||||||
|
this.api.quietUser(event.server, event.rUser, '10m', event.channel, target, vq.reason + '[votequiet]', function (response) {
|
||||||
|
clearTimeout(vq.timer);
|
||||||
|
vq.spent = true;
|
||||||
|
setTimeout(function () {
|
||||||
|
delete this.voteQuiets[user.id];
|
||||||
|
}
|
||||||
|
.bind(this), 600000);
|
||||||
|
event.reply(response);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
event.reply('You have already voted.');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
event.reply('There is no active votequiet for this user. You can start one by typing "~votequiet ' + target + ' [reason].');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
event.reply('No idea who that is m8');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.bind(this));
|
||||||
|
},
|
||||||
|
|
||||||
|
'~voteno': function (event) {
|
||||||
|
var target = event.params[1];
|
||||||
|
|
||||||
|
dbot.api.users.resolveUser(event.server, target, function (err, user) {
|
||||||
|
if (!err && user) {
|
||||||
|
if (user.id == event.rUser.id) {
|
||||||
|
return event.reply('You cannot vote on your own silencing. Be good.');
|
||||||
|
}
|
||||||
|
if (_.has(this.voteQuiets, user.id) && !this.voteQuiets[user.id].spent) {
|
||||||
|
var vq = this.voteQuiets[user.id];
|
||||||
|
if (event.channel != vq.channel) {
|
||||||
|
return event.reply('Vote must be in ' + vq.channel);
|
||||||
|
}
|
||||||
|
if (!_.include(vq.yes, event.rUser.primaryNick) && !_.include(vq.no, event.rUser.primaryNick)) {
|
||||||
|
vq.no.push(event.rUser.primaryNick);
|
||||||
|
event.reply('Voted no on votequiet for ' + target + '. New count: Yes (' + vq.yes.length + '). No (' + vq.no.length + ').');
|
||||||
|
} else {
|
||||||
|
event.reply('You have already voted.');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
event.reply('There is no active votequiet for this user. You can start one by typing "~votequiet ' + target + ' [reason].');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
event.reply('No idea who that is m8');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.bind(this));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
_.each(commands, function (command) {
|
||||||
|
command.access = 'moderator';
|
||||||
|
});
|
||||||
|
|
||||||
|
commands['~kickcount'].access = 'regular';
|
||||||
|
commands['~kickstats'].access = 'regular';
|
||||||
|
commands['~votequiet'].access = 'regular';
|
||||||
|
commands['~voteyes'].access = 'regular';
|
||||||
|
commands['~voteno'].access = 'regular';
|
||||||
|
commands['~quiet'].access = 'voice';
|
||||||
|
commands['~timeout'].access = 'voice';
|
||||||
|
commands['~unquiet'].access = 'voice';
|
||||||
|
commands['~nban'].access = 'power_user';
|
||||||
|
commands['~nunban'].access = 'power_user';
|
||||||
|
|
||||||
|
commands['~ckick'].regex = /^ckick (#[^ ]+ )?([^ ]+) ?(.*)?$/;
|
||||||
|
commands['~nban'].regex = /^nban (\d[\d\.dhmsy]+)? ?([^ ]+) (.+)$/;
|
||||||
|
commands['~quiet'].regex = /^quiet (\d[\d\.hmsy]+)? ?(#[^ ]+ )?([^ ]+) ?(.*)?$/;
|
||||||
|
commands['~timeout'].regex = /^timeout ([^ ]+) ?(.*)?$/;
|
||||||
|
commands['~unquiet'].regex = /^unquiet (#[^ ]+ )?([^ ]+) ?$/;
|
||||||
|
commands['~votequiet'].regex = [/^votequiet ([^ ]+) (.+)$/, 3];
|
||||||
|
|
||||||
|
return commands;
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.fetch = function (dbot) {
|
||||||
|
return commands(dbot);
|
||||||
|
};
|
18
modules-stock/kick/config.json
Normal file
18
modules-stock/kick/config.json
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"dbKeys": [ "kicks", "kickers", "hosts", "tempBans" ],
|
||||||
|
"dependencies": [ "command", "report", "users" ],
|
||||||
|
"ignorable": true,
|
||||||
|
"countSilently": true,
|
||||||
|
"quietBans": [
|
||||||
|
"#wherever"
|
||||||
|
],
|
||||||
|
"network_name": {
|
||||||
|
"aberwiki": "OAOSIDL"
|
||||||
|
},
|
||||||
|
"chanserv": "ChanServ",
|
||||||
|
"document_bans": false,
|
||||||
|
"dbType": "redis",
|
||||||
|
"requireWebLogin": true,
|
||||||
|
"webAccess": "power_user",
|
||||||
|
"timeoutTime": "10m"
|
||||||
|
}
|
270
modules-stock/kick/kick.js
Normal file
270
modules-stock/kick/kick.js
Normal file
@ -0,0 +1,270 @@
|
|||||||
|
var _ = require('underscore')._;
|
||||||
|
|
||||||
|
var kick = function (dbot) {
|
||||||
|
if (!_.has(dbot.db, 'recentTimeouts')) {
|
||||||
|
dbot.db.recentTimeouts = {};
|
||||||
|
}
|
||||||
|
this.recentTimeouts = dbot.db.recentTimeouts;
|
||||||
|
|
||||||
|
this.api = {
|
||||||
|
'ban': function (server, host, channel) {
|
||||||
|
dbot.instance.connections[server].send('MODE ' + channel + ' +b *!*@' + host);
|
||||||
|
},
|
||||||
|
|
||||||
|
'quiet': function (server, host, channel) {
|
||||||
|
dbot.instance.connections[server].send('MODE ' + channel + ' +q *!*@' + host);
|
||||||
|
},
|
||||||
|
|
||||||
|
'unquiet': function (server, host, channel) {
|
||||||
|
dbot.instance.connections[server].send('MODE ' + channel + ' -q *!*@' + host);
|
||||||
|
},
|
||||||
|
|
||||||
|
'devoice': function (server, nick, channel) {
|
||||||
|
dbot.instance.connections[server].send('MODE ' + channel + ' -v ' + nick);
|
||||||
|
},
|
||||||
|
|
||||||
|
'voice': function (server, nick, channel) {
|
||||||
|
dbot.instance.connections[server].send('MODE ' + channel + ' +v ' + nick);
|
||||||
|
},
|
||||||
|
|
||||||
|
'kick': function (server, user, channel, msg) {
|
||||||
|
dbot.instance.connections[server].send('KICK ' + channel + ' ' + user + ' :' + msg);
|
||||||
|
},
|
||||||
|
|
||||||
|
'kill': function (server, user, reason) {
|
||||||
|
dbot.instance.connections[server].send('kill ' + user + ' ' + reason);
|
||||||
|
},
|
||||||
|
|
||||||
|
'unban': function (server, host, channel) {
|
||||||
|
// TODO: Wrest control from chanserv
|
||||||
|
//dbot.say(server, this.config.chanserv, 'unban ' + channel + ' *!*@' + host);
|
||||||
|
dbot.instance.connections[server].send('MODE ' + channel + ' -b *!*@' + host);
|
||||||
|
},
|
||||||
|
|
||||||
|
'quietUser': function (server, quieter, duration, channel, quietee, reason, callback) {
|
||||||
|
dbot.api.nickserv.getUserHost(server, quietee, function (host) {
|
||||||
|
// Add host record entry
|
||||||
|
if (host) {
|
||||||
|
this.hosts[server][quietee] = host;
|
||||||
|
|
||||||
|
if (!_.isUndefined(duration) && !_.isNull(duration)) {
|
||||||
|
duration = duration.trim();
|
||||||
|
var msTimeout = new Date(new Date().getTime() + (parseFloat(duration) * 60000));
|
||||||
|
if (_.has(dbot.modules, 'remind')) {
|
||||||
|
msTimeout = dbot.api.remind.parseTime(duration);
|
||||||
|
if (!msTimeout) {
|
||||||
|
return callback('Invalid time. Remember you must give e.g. 5m now.');
|
||||||
|
}
|
||||||
|
duration = duration.replace(/([\d]+)d/, '$1 years').replace(/([\d]+)d/, '$1 days').replace(/([\d]+)h/, '$1 hours ').replace(/([\d]+)m/, '$1 minutes ').replace(/([\d]+)s/, '$1 seconds').trim();
|
||||||
|
} else {
|
||||||
|
duration += ' minutes';
|
||||||
|
}
|
||||||
|
|
||||||
|
var vStatus = dbot.instance.connections[server].channels[channel].nicks[quietee].voice;
|
||||||
|
dbot.api.timers.addTimeout(msTimeout, function () {
|
||||||
|
if (_.has(this.hosts[server], quietee)) {
|
||||||
|
if (_.include(this.config.quietBans, channel)) {
|
||||||
|
this.api.unban(server, this.hosts[server][quietee], channel);
|
||||||
|
this.api.voice(server, quietee, channel);
|
||||||
|
} else {
|
||||||
|
this.api.unquiet(server, this.hosts[server][quietee], channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
dbot.api.users.resolveUser(server, dbot.config.name, function (err, user) {
|
||||||
|
dbot.api.report.notify('unquiet', server, user, channel,
|
||||||
|
dbot.t('unquiet_notify', {
|
||||||
|
'unquieter': dbot.config.name,
|
||||||
|
'quietee': quietee
|
||||||
|
}), false, quietee);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.bind(this));
|
||||||
|
callback(dbot.t('tquieted', {
|
||||||
|
'quietee': quietee,
|
||||||
|
'minutes': duration
|
||||||
|
}));
|
||||||
|
dbot.api.report.notify('quiet', server, quieter.primaryNick, channel,
|
||||||
|
dbot.t('tquiet_notify', {
|
||||||
|
'minutes': duration,
|
||||||
|
'quieter': quieter.primaryNick,
|
||||||
|
'quietee': quietee,
|
||||||
|
'reason': reason
|
||||||
|
}), false, quietee);
|
||||||
|
} else {
|
||||||
|
callback(dbot.t('quieted', {
|
||||||
|
'quietee': quietee
|
||||||
|
}));
|
||||||
|
dbot.api.report.notify('quiet', server, quieter.primaryNick, channel,
|
||||||
|
dbot.t('quiet_notify', {
|
||||||
|
'quieter': quieter.primaryNick,
|
||||||
|
'quietee': quietee,
|
||||||
|
'reason': reason
|
||||||
|
}), false, quietee);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.api.devoice(server, quietee, channel);
|
||||||
|
|
||||||
|
if (_.include(this.config.quietBans, channel)) {
|
||||||
|
this.api.ban(server, this.hosts[server][quietee], channel);
|
||||||
|
} else {
|
||||||
|
this.api.quiet(server, host, channel);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reason.indexOf('#warn') !== -1) {
|
||||||
|
dbot.api.warning.warn(server, quieter, quietee,
|
||||||
|
'Quieted in ' + channel + ' for ' + reason, channel,
|
||||||
|
function () {});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
event.reply(dbot.t('no_user', {
|
||||||
|
'user': quietee
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.bind(this));
|
||||||
|
},
|
||||||
|
|
||||||
|
'networkUnban': function (server, unbanee, unbanner, manualHost, callback) {
|
||||||
|
var channels = dbot.config.servers[server].channels,
|
||||||
|
network = this.config.network_name[server] || server,
|
||||||
|
adminChannel = dbot.config.servers[server].admin_channel;
|
||||||
|
|
||||||
|
if (!_.isUndefined(manualHost)) {
|
||||||
|
this.hosts[server][unbanee] = manualHost;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_.has(this.hosts, server) && _.has(this.hosts[server], unbanee) && _.isString(this.hosts[server][unbanee])) {
|
||||||
|
var host = this.hosts[server][unbanee];
|
||||||
|
|
||||||
|
// Notify Staff
|
||||||
|
if (_.isUndefined(adminChannel)) {
|
||||||
|
adminChannel = event.channel.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
var notifyString = dbot.t('nunbanned', {
|
||||||
|
'network': network,
|
||||||
|
'unbanee': unbanee,
|
||||||
|
'host': host,
|
||||||
|
'unbanner': unbanner.currentNick
|
||||||
|
});
|
||||||
|
dbot.api.report.notify('unban', server, unbanner, adminChannel, notifyString, false, unbanee);
|
||||||
|
dbot.say(server, adminChannel, notifyString);
|
||||||
|
|
||||||
|
// Notify Unbanee
|
||||||
|
dbot.say(server, unbanee, dbot.t('nunban_notify', {
|
||||||
|
'network': network,
|
||||||
|
'unbanee': unbanee,
|
||||||
|
'unbanner': unbanner.currentNick
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Unban
|
||||||
|
var i = 0;
|
||||||
|
var unbanChannel = function (channels) {
|
||||||
|
if (i >= channels.length)
|
||||||
|
return;
|
||||||
|
var channel = channels[i];
|
||||||
|
this.api.unban(server, host, channel);
|
||||||
|
setTimeout(function () {
|
||||||
|
i++;
|
||||||
|
unbanChannel(channels);
|
||||||
|
}, 1000);
|
||||||
|
}
|
||||||
|
.bind(this);
|
||||||
|
unbanChannel(channels);
|
||||||
|
|
||||||
|
dbot.say(server, 'NickServ', 'FREEZE ' + unbanee + ' OFF');
|
||||||
|
callback(null); // Success
|
||||||
|
} else {
|
||||||
|
// Attempt to look up the host on-the-fly
|
||||||
|
dbot.api.nickserv.getUserHost(server, unbanee, unbanner, function (host) {
|
||||||
|
if (host) {
|
||||||
|
if (!_.has(this.hosts, server))
|
||||||
|
this.hosts[server] = {};
|
||||||
|
this.hosts[server][unbanee] = host;
|
||||||
|
this.api.networkUnban(server, unbanee, unbanner);
|
||||||
|
} else {
|
||||||
|
callback(true); // No host could be found
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.bind(this));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.internalAPI = {
|
||||||
|
'addTempBan': function (server, banee, timeout) {
|
||||||
|
dbot.api.users.resolveUser(server, dbot.config.name, function (err, bot) {
|
||||||
|
dbot.api.timers.addTimeout(timeout, function () {
|
||||||
|
this.api.networkUnban(server, banee, bot, undefined, function (err) {});
|
||||||
|
delete this.tempBans[server][banee];
|
||||||
|
}
|
||||||
|
.bind(this));
|
||||||
|
}
|
||||||
|
.bind(this));
|
||||||
|
}
|
||||||
|
.bind(this)
|
||||||
|
};
|
||||||
|
|
||||||
|
this.listener = function (event) {
|
||||||
|
if (event.kickee == dbot.config.name) {
|
||||||
|
dbot.instance.join(event, event.channel.name);
|
||||||
|
event.reply(dbot.t('kicked_dbot', {
|
||||||
|
'botname': dbot.config.name
|
||||||
|
}));
|
||||||
|
dbot.db.kicks[dbot.config.name] += 1;
|
||||||
|
} else {
|
||||||
|
if (!_.has(dbot.db.kicks, event.kickee)) {
|
||||||
|
dbot.db.kicks[event.kickee] = 1;
|
||||||
|
} else {
|
||||||
|
dbot.db.kicks[event.kickee] += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_.has(dbot.db.kickers, event.user)) {
|
||||||
|
dbot.db.kickers[event.user] = 1;
|
||||||
|
} else {
|
||||||
|
dbot.db.kickers[event.user] += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.config.countSilently) {
|
||||||
|
event.reply(event.kickee + '-- (' + dbot.t('user_kicks', {
|
||||||
|
'user': event.kickee,
|
||||||
|
'kicks': dbot.db.kicks[event.kickee],
|
||||||
|
'kicked': dbot.db.kickers[event.kickee]
|
||||||
|
}) + ')');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.bind(this);
|
||||||
|
this.on = 'KICK';
|
||||||
|
|
||||||
|
this.onLoad = function () {
|
||||||
|
if (!_.has(dbot.db, 'hosts')) {
|
||||||
|
dbot.db.hosts = {};
|
||||||
|
_.each(dbot.config.servers, function (v, k) {
|
||||||
|
dbot.db.hosts[k] = {};
|
||||||
|
}, this);
|
||||||
|
}
|
||||||
|
if (!_.has(dbot.db, 'tempBans'))
|
||||||
|
dbot.db.tempBans = {};
|
||||||
|
this.hosts = dbot.db.hosts;
|
||||||
|
this.tempBans = dbot.db.tempBans;
|
||||||
|
this.voteQuiets = {};
|
||||||
|
|
||||||
|
_.each(this.tempBans, function (bans, server) {
|
||||||
|
_.each(bans, function (timeout, nick) {
|
||||||
|
timeout = new Date(timeout);
|
||||||
|
this.internalAPI.addTempBan(server, nick, timeout);
|
||||||
|
}, this);
|
||||||
|
}, this);
|
||||||
|
|
||||||
|
if (_.has(dbot.modules, 'web')) {
|
||||||
|
dbot.api.web.addIndexLink('/bans', 'Ban List');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.bind(this);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.fetch = function (dbot) {
|
||||||
|
return new kick(dbot);
|
||||||
|
};
|
46
modules-stock/kick/pages.js
Normal file
46
modules-stock/kick/pages.js
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
var _ = require('underscore')._;
|
||||||
|
|
||||||
|
var pages = function (dbot) {
|
||||||
|
return {
|
||||||
|
'/bans': function (req, res) {
|
||||||
|
res.render('servers', {
|
||||||
|
'servers': _.keys(dbot.config.servers)
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
'/underbans': function (req, res) {
|
||||||
|
this.db.search('nbans', {
|
||||||
|
'server': server
|
||||||
|
}, function (ban) {
|
||||||
|
if (ban.reason.match('#underban')) {
|
||||||
|
bans.push(ban);
|
||||||
|
}
|
||||||
|
}, function () {
|
||||||
|
res.render('bans', {
|
||||||
|
'server': server,
|
||||||
|
'bans': bans
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
'/bans/:server': function (req, res) {
|
||||||
|
var server = req.params.server,
|
||||||
|
bans = [];
|
||||||
|
|
||||||
|
this.db.search('nbans', {
|
||||||
|
'server': server
|
||||||
|
}, function (ban) {
|
||||||
|
bans.push(ban);
|
||||||
|
}, function () {
|
||||||
|
res.render('bans', {
|
||||||
|
'server': server,
|
||||||
|
'bans': bans
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.fetch = function (dbot) {
|
||||||
|
return pages(dbot);
|
||||||
|
};
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user