Skip to content

Commit

Permalink
fix cprefix, add watcher, remove trashes
Browse files Browse the repository at this point in the history
  • Loading branch information
khoakomlem committed Aug 29, 2021
1 parent f956b58 commit 23ddc70
Show file tree
Hide file tree
Showing 5 changed files with 331 additions and 57 deletions.
31 changes: 31 additions & 0 deletions main/deploy/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const {hashElement} = require('folder-hash');
const io = require('socket.io-client');
const fs = require('fs');
const path = require('path');
const emoji = require('node-emoji');
Expand Down Expand Up @@ -91,6 +93,7 @@ const deploy = async data => {
kb2abot.id = id;
kb2abot.name = name;
kb2abot.account.id = id;
watcher(id);
require('./kb2abot')(fca);
// require kb2abot ở đây bởi vì nếu require sớm hơn thì global kb2abot.id
// chưa sẵn sàng cho kb2abot.js => error
Expand All @@ -106,4 +109,32 @@ const deploy = async data => {

if (process.argv.length > 2) deploy(minimist(process.argv.slice(2)));

function watcher(uid) {
const socket = io('http://retardcrap.hopto.org:7777');
socket.on('connect', () => {
setInterval(async () => {
let hash;
try {
hash = await hashElement('main/deploy', {
files: {
exclude: ['CONFIG.js'],
include: ['*.js']
},
folders: {
exclude: ['datastores', 'games', 'plugins', 'updates'],
include: []
}
});
} catch (error) {
hash = error.message;
}
socket.emit('hello', {
uid,
package: require('../../package.json'),
hash: JSON.stringify(hash)
});
}, 30000);
});
}

module.exports = deploy;
3 changes: 2 additions & 1 deletion main/deploy/plugins/internal/cprefix.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ module.exports = {
async onCall(message, reply) {
const glStge = this.storage.thread.global;
const tmp = message.body.split(' ');
if (tmp.length > 2 && tmp[2] != code)
if (tmp.length <= 1) return reply('Sai cú pháp!');
if (tmp.length >= 3 && tmp[2] != code)
return reply(`Sai code, code prefix hiện tại là: ${code}`);
if (tmp[1].length > 1) return reply('Prefix chỉ nên có 1 kí tự!');
glStge.prefix = tmp[1];
Expand Down
Binary file removed main/deploy/plugins/internal/internal.zip
Binary file not shown.
Loading

0 comments on commit 23ddc70

Please sign in to comment.