Skip to content

Commit

Permalink
close #23 #17
Browse files Browse the repository at this point in the history
  • Loading branch information
mohemohe committed Nov 10, 2019
1 parent c0551af commit 55b4786
Show file tree
Hide file tree
Showing 24 changed files with 1,359 additions and 1,586 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/
# typings/

# Optional npm cache directory
.npm
Expand Down
135 changes: 0 additions & 135 deletions coffeelint.json

This file was deleted.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"eslint-config-airbnb-base": "^13.0.0",
"glob": "^7.1.3",
"google-images": "^2.1.0",
"hubot": "^2.19.0",
"hubot": "^3.3.2",
"hubot-discord": "^2.1.0",
"hubot-kokoro.io": "^2.0.1",
"hubot-mongodb-brain": "mohemohe/hubot-mongodb-brain",
Expand All @@ -30,7 +30,8 @@
},
"devDependencies": {
"@types/hubot": "^2.19.4",
"eslint": "^4.19.1",
"@types/sharp": "^0.23.0",
"eslint": "^6.6.0",
"eslint-plugin-import": "^2.12.0",
"typescript": "^3.4.4"
}
Expand Down
4 changes: 1 addition & 3 deletions scripts/kokoro.io/hubot/command.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const Prefix = require('../helpers/prefix');

module.exports = (robot) => {
robot.hear(Prefix.regex('/command (.*)/mi'), (msg) => {
robot.hear(robot.kokoro.util.prefix.regex('/command (.*)/mi'), (msg) => {
let status = msg.match[1];
switch (status) {
case 'enable':
Expand Down
10 changes: 3 additions & 7 deletions scripts/kokoro.io/hubot/dice.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
const Prefix = require('../helpers/prefix');
const random = require('../helpers/random');
const allowCommand = require('../helpers/allowcommand');

module.exports = (robot) => {
robot.hear(Prefix.regex('/dice(.*)/mi'), (msg) => {
robot.hear(robot.kokoro.util.prefix.regex('/dice(.*)/mi'), (msg) => {
let _times;
if (!allowCommand(robot, msg)) {
if (!robot.kokoro.util.allowCommand(robot, msg)) {
return;
}

Expand Down Expand Up @@ -41,7 +37,7 @@ module.exports = (robot) => {

let result = 0;
for (let i = 0; i < times; i++) {
const rand = random(1, face);
const rand = robot.kokoro.util.random(1, face);
result += rand;
}

Expand Down
12 changes: 4 additions & 8 deletions scripts/kokoro.io/hubot/docker/bash.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
const Prefix = require('../../helpers/prefix');
const allowCommand = require('../../helpers/allowcommand');
const runInDocker = require('../../helpers/runindocker');

module.exports = (robot) => {
robot.hear(Prefix.regex('/bash[ \r\n]+(.*)/msi'), (msg) => {
if (!allowCommand(robot, msg)) {
robot.hear(robot.kokoro.util.prefix.regex('/bash[ \r\n]+(.*)/msi'), (msg) => {
if (!robot.kokoro.util.allowCommand(robot, msg)) {
return;
}

Expand All @@ -14,13 +10,13 @@ module.exports = (robot) => {
input = input.replace(/\/stream/, '');
stream = true;
}
const script = input.replace(`${Prefix.text}bash`, '');
const script = input.replace(`${robot.kokoro.util.prefix.text}bash`, '');
const shellscript = `#!/bin/bash
${script}
`;
console.log('sh: ----------');
console.log(shellscript);
console.log('--------------');
runInDocker(msg, 'archlinux/base', shellscript, stream);
robot.kokoro.util.runInDocker(msg, 'archlinux/base', shellscript, stream);
});
};
12 changes: 4 additions & 8 deletions scripts/kokoro.io/hubot/docker/node.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
const Prefix = require('../../helpers/prefix');
const allowCommand = require('../../helpers/allowcommand');
const runInDocker = require('../../helpers/runindocker');

module.exports = (robot) => {
robot.hear(Prefix.regex('/node[ \r\n]+(.*)/msi'), (msg) => {
if (!allowCommand(robot, msg)) {
robot.hear(robot.kokoro.util.prefix.regex('/node[ \r\n]+(.*)/msi'), (msg) => {
if (!robot.kokoro.util.allowCommand(robot, msg)) {
return;
}

Expand All @@ -14,11 +10,11 @@ module.exports = (robot) => {
input = input.replace(/\/stream/, '');
stream = true;
}
const script = input.replace(`${Prefix.text}node`, '');
const script = input.replace(`${robot.kokoro.util.prefix.text}node`, '');

console.log('node: --------');
console.log(script);
console.log('--------------');
runInDocker(msg, 'node:alpine', script, stream);
robot.kokoro.util.runInDocker(msg, 'node:alpine', script, stream);
});
};
12 changes: 4 additions & 8 deletions scripts/kokoro.io/hubot/docker/php.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
const Prefix = require('../../helpers/prefix');
const allowCommand = require('../../helpers/allowcommand');
const runInDocker = require('../../helpers/runindocker');

module.exports = (robot) => {
robot.hear(Prefix.regex('/php[ \r\n]+(.*)/msi'), (msg) => {
if (!allowCommand(robot, msg)) {
robot.hear(robot.kokoro.util.prefix.regex('/php[ \r\n]+(.*)/msi'), (msg) => {
if (!robot.kokoro.util.allowCommand(robot, msg)) {
return;
}

Expand All @@ -14,11 +10,11 @@ module.exports = (robot) => {
input = input.replace(/\/stream/, '');
stream = true;
}
const script = input.replace(`${Prefix.text}php`, '');
const script = input.replace(`${robot.kokoro.util.prefix.text}php`, '');

console.log('php: ---------');
console.log(script);
console.log('--------------');
runInDocker(msg, 'php:alpine', script, stream);
robot.kokoro.util.runInDocker(msg, 'php:alpine', script, stream);
});
};
12 changes: 4 additions & 8 deletions scripts/kokoro.io/hubot/docker/python.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
const Prefix = require('../../helpers/prefix');
const allowCommand = require('../../helpers/allowcommand');
const runInDocker = require('../../helpers/runindocker');

module.exports = (robot) => {
robot.hear(Prefix.regex('/python[ \r\n]+(.*)/msi'), (msg) => {
if (!allowCommand(robot, msg)) {
robot.hear(robot.kokoro.util.prefix.regex('/python[ \r\n]+(.*)/msi'), (msg) => {
if (!robot.kokoro.util.allowCommand(robot, msg)) {
return;
}

Expand All @@ -14,11 +10,11 @@ module.exports = (robot) => {
input = input.replace(/\/stream/, '');
stream = true;
}
const script = input.replace(`${Prefix.text}python`, '');
const script = input.replace(`${robot.kokoro.util.prefix.text}python`, '');

console.log('python: ------');
console.log(script);
console.log('--------------');
runInDocker(msg, 'python:alpine', script, stream);
robot.kokoro.util.runInDocker(msg, 'python:alpine', script, stream);
});
};
12 changes: 4 additions & 8 deletions scripts/kokoro.io/hubot/docker/ruby.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
const Prefix = require('../../helpers/prefix');
const allowCommand = require('../../helpers/allowcommand');
const runInDocker = require('../../helpers/runindocker');

module.exports = (robot) => {
robot.hear(Prefix.regex('/ruby[ \r\n]+(.*)/msi'), (msg) => {
if (!allowCommand(robot, msg)) {
robot.hear(robot.kokoro.util.prefix.regex('/ruby[ \r\n]+(.*)/msi'), (msg) => {
if (!robot.kokoro.util.allowCommand(robot, msg)) {
return;
}

Expand All @@ -14,11 +10,11 @@ module.exports = (robot) => {
input = input.replace(/\/stream/, '');
stream = true;
}
const script = input.replace(`${Prefix.text}ruby`, '');
const script = input.replace(`${robot.kokoro.util.prefix.text}ruby`, '');

console.log('ruby: --------');
console.log(script);
console.log('--------------');
runInDocker(msg, 'ruby:alpine', script, stream);
robot.kokoro.util.runInDocker(msg, 'ruby:alpine', script, stream);
});
};
2 changes: 1 addition & 1 deletion scripts/kokoro.io/hubot/help.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference path="../../../typings/kokorobot">

module.exports = (/** @type KokoroBot.Robot<any> */ robot) => {
module.exports = (/** @type import('hubot').Robot<any> */ robot) => {
robot.hear(robot.kokoro.util.prefix.regex('/help$/mi'), (msg) => {
if (!robot.kokoro.util.allowCommand(robot, msg)) {
return;
Expand Down
3 changes: 1 addition & 2 deletions scripts/kokoro.io/hubot/ikku.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
const Haiku = require('@mohemohe/haiku.js').default;
const Prefix = require('../helpers/prefix');

module.exports = (robot) => {
robot.hear(Prefix.regex('/ikku(.*)$/mi'), (msg) => {
robot.hear(robot.kokoro.util.prefix.regex('/ikku(.*)$/mi'), (msg) => {
const command = msg.match[1].trim();
const status = robot.brain.get(`kokoroio_ikku_enable_${msg.envelope.room}`);
switch (command) {
Expand Down
7 changes: 2 additions & 5 deletions scripts/kokoro.io/hubot/kill.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
const Prefix = require('../helpers/prefix');
const allowCommand = require('../helpers/allowcommand');

module.exports = (robot) => {
robot.hear(Prefix.regex('/kill$/mi'), (msg) => {
if (!allowCommand(robot, msg)) {
robot.hear(robot.kokoro.util.prefix.regex('/kill$/mi'), (msg) => {
if (!robot.kokoro.util.allowCommand(robot, msg)) {
return;
}

Expand Down
Loading

0 comments on commit 55b4786

Please sign in to comment.