Compare commits
2 Commits
0c6107fd7a
...
82879e7587
Author | SHA1 | Date |
---|---|---|
Santiago Forero | 82879e7587 | |
Santiago Forero | afd621e6c1 |
|
@ -118,3 +118,5 @@ dist
|
||||||
.yarn/install-state.gz
|
.yarn/install-state.gz
|
||||||
.pnp.*
|
.pnp.*
|
||||||
|
|
||||||
|
# databases
|
||||||
|
json.sqlite
|
|
@ -0,0 +1,20 @@
|
||||||
|
const db = require('quick.db')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'grow',
|
||||||
|
description: 'Grow your cactus.',
|
||||||
|
execute(event, args, bot) {
|
||||||
|
if(db.get(event.nick + '_score') == null) db.set(event.nick + '_score', 0)
|
||||||
|
if(db.get(event.nick + '_hpg') == null) db.set(event.nick + '_hpg', 2)
|
||||||
|
|
||||||
|
|
||||||
|
db.add(event.nick + '_score', db.get(event.nick + '_hpg'))
|
||||||
|
|
||||||
|
bot.say(event.target, "You grew " + db.get(event.nick + '_hpg') + " cm")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bot.say(event.target, "You are now " + db.get(event.nick + '_score') + " cm")
|
||||||
|
|
||||||
|
},
|
||||||
|
};
|
|
@ -0,0 +1,13 @@
|
||||||
|
module.exports = {
|
||||||
|
name: 'help',
|
||||||
|
description: 'Get info and help about this bot.',
|
||||||
|
execute(event, args, bot) {
|
||||||
|
bot.say(event.target, 'Hi, I\'m Cactus, you can live the life of a cactus and grow to become the tallest! My maintainer is forero, my prefix is \'=\' and my commands are: ')
|
||||||
|
|
||||||
|
bot.commands.forEach((value, key, map) => {
|
||||||
|
bot.say(event.target, value.name + ": " + value.description)
|
||||||
|
})
|
||||||
|
|
||||||
|
bot.say(event.target, 'Source: https://tildegit.org/forero/cactus-irc/')
|
||||||
|
},
|
||||||
|
};
|
|
@ -0,0 +1,20 @@
|
||||||
|
const db = require('quick.db')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'profile',
|
||||||
|
description: 'See your profile or someone else\'s profile.',
|
||||||
|
execute(event, args, bot) {
|
||||||
|
user = args[0] || event.nick;
|
||||||
|
|
||||||
|
bot.say(event.target, user + "' profile")
|
||||||
|
|
||||||
|
if(db.get(user + '_score') == null) db.set(user + '_score', 0)
|
||||||
|
if(db.get(user + '_hpg') == null) db.set(user + '_hpg', 2)
|
||||||
|
|
||||||
|
bot.say(event.target, 'Current height: ' + db.get(user + '_score') + ' cm')
|
||||||
|
|
||||||
|
|
||||||
|
bot.say(event.target, "Height per growth: " + db.get(user + '_hpg') + " cm")
|
||||||
|
|
||||||
|
},
|
||||||
|
};
|
|
@ -0,0 +1,73 @@
|
||||||
|
const IRC = require('irc-framework');
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
|
var bot = new IRC.Client();
|
||||||
|
|
||||||
|
bot.connect({
|
||||||
|
host: 'irc.tilde.chat',
|
||||||
|
port: 6697,
|
||||||
|
nick: 'Cactus',
|
||||||
|
tls: true
|
||||||
|
});
|
||||||
|
|
||||||
|
const prefix = "="
|
||||||
|
|
||||||
|
bot.commands = new Map();
|
||||||
|
|
||||||
|
const commandFiles = fs.readdirSync(`./commands`).filter(file => file.endsWith('.js'));
|
||||||
|
|
||||||
|
for (const file of commandFiles) {
|
||||||
|
const command = require(`./commands/${file}`);
|
||||||
|
|
||||||
|
bot.commands.set(command.name, command);
|
||||||
|
}
|
||||||
|
|
||||||
|
bot.on('message', event => {
|
||||||
|
const args = event.message.slice(prefix.length).trim().split(/ +/);
|
||||||
|
if(event.message == '!botlist') {
|
||||||
|
|
||||||
|
bot.commands.get('help').execute(event, args, bot);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!event.message.startsWith(prefix)) return;
|
||||||
|
const commandName = args.shift().toLowerCase();
|
||||||
|
|
||||||
|
const command = bot.commands.get(commandName)
|
||||||
|
|
||||||
|
if (!command) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
command.execute(event, args, bot);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
bot.say(event.target, 'there was an error trying to execute that command!');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bot.on('registered', event => {
|
||||||
|
console.log(event)
|
||||||
|
bot.join('#bots')
|
||||||
|
bot.join('#cactus')
|
||||||
|
|
||||||
|
bot.say('NickServ', 'identify 1021513305')
|
||||||
|
})
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
"name": "cactus-irc",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://tildegit.org/forero/cactus-irc"
|
||||||
|
},
|
||||||
|
"author": "Santiago Forero",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"irc-framework": "^4.11.0",
|
||||||
|
"quick.db": "^7.1.3"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue