help system

This commit is contained in:
Flummi 2017-12-04 17:40:24 +01:00
parent 61079e4000
commit d209b2b54e
8 changed files with 58 additions and 1 deletions

View File

@ -56,6 +56,7 @@ read().then(() => {
function trigger(args) { function trigger(args) {
this.call = args.call; this.call = args.call;
this.help = args.help || false;
this.level = args.level || 0; this.level = args.level || 0;
this.active = args.hasOwnProperty("active") ? args.active : true; this.active = args.hasOwnProperty("active") ? args.active : true;
this.clients = args.clients || ["irc", "tg"]; this.clients = args.clients || ["irc", "tg"];

View File

@ -15,6 +15,10 @@ Object.keys(data).forEach(cur => {
export default bot => { export default bot => {
bot._trigger.set("dope", new bot.trigger({ bot._trigger.set("dope", new bot.trigger({
call: /^(\.|\/)dope/i, call: /^(\.|\/)dope/i,
help: {
text: "Smoke weed everyday",
usage: "[b].dope[/b] [i](<nick>)[/i]"
},
f: e => { f: e => {
const strain_types = Object.keys(data.dope_strains); const strain_types = Object.keys(data.dope_strains);
const action_types = Object.keys(data.dope_actions); const action_types = Object.keys(data.dope_actions);
@ -28,6 +32,10 @@ export default bot => {
bot._trigger.set("meth", new bot.trigger({ bot._trigger.set("meth", new bot.trigger({
call: /^(\.|\/)meth/i, call: /^(\.|\/)meth/i,
help: {
text: "Snort some meth *_*",
usage: "[b].meth[/b] [i](<nick>)[/i]"
},
f: e => { f: e => {
e.replyAction(`legt [b]${e.args[0] || e.user.nick}[/b] eine dicke Line Meth \\________`); e.replyAction(`legt [b]${e.args[0] || e.user.nick}[/b] eine dicke Line Meth \\________`);
} }

19
src/inc/trigger/help.mjs Normal file
View File

@ -0,0 +1,19 @@
export default bot => {
bot._trigger.set("help", new bot.trigger({
call: /^(\.|\/)help/i,
f: e => {
if(e.args[0] && [...bot._trigger.keys()].includes(e.args[0])) {
const help = bot._trigger.get(e.args[0]).help;
e.reply(help.text);
e.reply(`usage: ${help.usage}`);
}
else {
let triggers = [];
[...bot._trigger.entries()]
.filter(trigger => trigger[1].help)
.forEach(trigger => triggers.push(trigger[0]));
e.reply(`available commands: ${triggers.map(blah => `[b]${blah}[/b]`).join(", ")}`);
}
}
}));
};

View File

@ -4,6 +4,7 @@ import cookie from "./cookie";
import core from "./core"; import core from "./core";
import debug from "./debug"; import debug from "./debug";
import drugs from "./drugs"; import drugs from "./drugs";
import help from "./help";
import kernel from "./kernel"; import kernel from "./kernel";
import mcmaniac from "./mcmaniac"; import mcmaniac from "./mcmaniac";
import parser from "./parser"; import parser from "./parser";
@ -17,7 +18,7 @@ import wttr from "./wttr";
export default [ export default [
cfg, coins, cookie, core, debug, cfg, coins, cookie, core, debug,
drugs, kernel, mcmaniac, drugs, help, kernel, mcmaniac,
parser, quotes, rape, sandbox, parser, quotes, rape, sandbox,
urban, nxy, uwe, wttr urban, nxy, uwe, wttr
]; ];

View File

@ -3,6 +3,10 @@ import sql from "../sql";
export default bot => { export default bot => {
bot._trigger.set("rape", new bot.trigger({ bot._trigger.set("rape", new bot.trigger({
call: /^(\.|\/)rape/i, call: /^(\.|\/)rape/i,
help: {
text: "Rapes a nick and eventually charge for it",
usage: "[b].rape[/b] [i](<nick>)[/i]"
},
f: e => { f: e => {
const nick = e.args[0] || e.user.nick; const nick = e.args[0] || e.user.nick;
const rand = Math.round(Math.random()); const rand = Math.round(Math.random());
@ -27,6 +31,10 @@ export default bot => {
bot._trigger.set("owe", new bot.trigger({ bot._trigger.set("owe", new bot.trigger({
call: /^(\.|\/)owe/i, call: /^(\.|\/)owe/i,
help: {
text: "Shows how much a nick owes",
usage: "[b].owe[/b] [i](<nick>)[/i]"
},
f: e => { f: e => {
const nick = e.args[0] || e.user.nick; const nick = e.args[0] || e.user.nick;
sql.any("select fines from nxy_users where lower(nick) = lower($1) limit 1", [nick]) sql.any("select fines from nxy_users where lower(nick) = lower($1) limit 1", [nick])

View File

@ -5,6 +5,10 @@ const url = "https://api.urbandictionary.com/v0/define"
export default bot => { export default bot => {
bot._trigger.set("urbandict", new bot.trigger({ bot._trigger.set("urbandict", new bot.trigger({
call: /^(\.|\/)ud .*/i, call: /^(\.|\/)ud .*/i,
help: {
text: "Searches for a term on Urbandict and returns first result",
usage: "[b].ud[/b] [i]<term>[/i] [i](<index>)[/i]"
},
f: e => { f: e => {
let index = 1; let index = 1;
if(!isNaN(e.args[e.args.length - 1]) && e.args.length > 1) if(!isNaN(e.args[e.args.length - 1]) && e.args.length > 1)

View File

@ -23,6 +23,10 @@ Object.keys(data).forEach(cur => {
export default bot => { export default bot => {
bot._trigger.set("kiss", new bot.trigger({ bot._trigger.set("kiss", new bot.trigger({
call: /^(\.|\/)kiss/i, call: /^(\.|\/)kiss/i,
help: {
text: "Kisses a user",
usage: "[b].kiss[/b] [i](<nick>)[/i]"
},
f: e => { f: e => {
e.reply(`(づ。◕‿‿◕。)づ" [color=red]。。・゜゜・。。・゜❤[/color] [b]${e.args[0] || e.user.nick}[/b] [color=red]❤[/color]`); e.reply(`(づ。◕‿‿◕。)づ" [color=red]。。・゜゜・。。・゜❤[/color] [b]${e.args[0] || e.user.nick}[/b] [color=red]❤[/color]`);
} }
@ -30,6 +34,10 @@ export default bot => {
bot._trigger.set("hug", new bot.trigger({ bot._trigger.set("hug", new bot.trigger({
call: /^(\.|\/)hug/i, call: /^(\.|\/)hug/i,
help: {
text: "Hugs a user",
usage: "[b].hug[/b] [i](<nick>)[/i]"
},
f: e => { f: e => {
e.reply(`[color=red]♡❤♡♥[/color] [b]${e.args[0] || e.user.nick}[/b] [color=red]♥♡❤♡♥[/color]`); e.reply(`[color=red]♡❤♡♥[/color] [b]${e.args[0] || e.user.nick}[/b] [color=red]♥♡❤♡♥[/color]`);
} }

View File

@ -3,6 +3,10 @@ import rp from "request-promise";
export default bot => { export default bot => {
bot._trigger.set("wttr", new bot.trigger({ bot._trigger.set("wttr", new bot.trigger({
call: /^\.wttr .*/i, call: /^\.wttr .*/i,
help: {
text: "Gets the weather from wttr.in",
usage: "[b].wttr[/b] [i]<location>[/i]"
},
clients: ["irc"], clients: ["irc"],
f: e => { f: e => {
let args = e.message.trim().substring(6); let args = e.message.trim().substring(6);
@ -60,6 +64,10 @@ export default bot => {
bot._trigger.set("weather", new bot.trigger({ bot._trigger.set("weather", new bot.trigger({
call: /^(\.|\/)weather .*/i, call: /^(\.|\/)weather .*/i,
help: {
text: "Gets the weather from Yahoo weather API",
usage: "[b].weather[/b] [i]<location>[/i]"
},
f: e => { f: e => {
const loc = e.message.trim().substring(9); const loc = e.message.trim().substring(9);
const url = `https://query.yahooapis.com/v1/public/yql?format=json&q=` const url = `https://query.yahooapis.com/v1/public/yql?format=json&q=`