From 52d0d1f99d048f3d6551d619308de9be6c185c4e Mon Sep 17 00:00:00 2001 From: Flummi Date: Tue, 21 Nov 2017 00:37:22 +0100 Subject: [PATCH] trigger trigger trigger --- src/inc/clients/irc.js | 6 +- src/inc/clients/tg.js | 2 +- src/inc/trigger/abschieben.js | 22 ----- src/inc/trigger/butterkaese.js | 14 --- src/inc/trigger/drugs.js | 61 ++++--------- src/inc/trigger/kaffee.js | 19 ---- src/inc/trigger/lachs.js | 11 --- src/inc/trigger/notschlachten.js | 14 --- src/inc/trigger/useless.js | 148 +++++++++++++++++++++++++++++++ 9 files changed, 168 insertions(+), 129 deletions(-) delete mode 100644 src/inc/trigger/abschieben.js delete mode 100644 src/inc/trigger/butterkaese.js delete mode 100644 src/inc/trigger/kaffee.js delete mode 100644 src/inc/trigger/lachs.js delete mode 100644 src/inc/trigger/notschlachten.js create mode 100644 src/inc/trigger/useless.js diff --git a/src/inc/clients/irc.js b/src/inc/clients/irc.js index a764a6f..bcc5427 100644 --- a/src/inc/clients/irc.js +++ b/src/inc/clients/irc.js @@ -85,9 +85,9 @@ class irc { message: tmp.params[1], time: ~~(Date.now() / 1000), raw: tmp, - reply: msg => this.send(`PRIVMSG ${tmp.params[0]} :${this.format(msg)}`), - replyAction: msg => this.send(`PRIVMSG ${tmp.params[0]} :\u0001ACTION ${this.format(msg)}\u0001`), - replyNotice: msg => this.send(`NOTICE ${tmp.params[0]} :${this.format(msg)}`), + reply: msg => this.send(`PRIVMSG ${tmp.params[0]} :${this.format(""+msg)}`), + replyAction: msg => this.send(`PRIVMSG ${tmp.params[0]} :\u0001ACTION ${this.format(""+msg)}\u0001`), + replyNotice: msg => this.send(`NOTICE ${tmp.params[0]} :${this.format(""+msg)}`), _chan: this.server.channel[tmp.params[0]], _user: this.server.user, _cmd: this._cmd, diff --git a/src/inc/clients/tg.js b/src/inc/clients/tg.js index 862855d..d15ae8d 100644 --- a/src/inc/clients/tg.js +++ b/src/inc/clients/tg.js @@ -52,7 +52,7 @@ class tg { }; } format(msg) { - return msg + return ""+msg .replace(/\[b\](.*?)\[\/b\]/g, "$1") // bold .replace(/\[i\](.*?)\[\/i\]/g, "$1") // italic ; diff --git a/src/inc/trigger/abschieben.js b/src/inc/trigger/abschieben.js deleted file mode 100644 index e1c2984..0000000 --- a/src/inc/trigger/abschieben.js +++ /dev/null @@ -1,22 +0,0 @@ -const Dest = [ - "nach Syrien", "in die Ukraine", "nach Timbuktu", "nach Uruguay", - "nach Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch", - "nach Bagdad", "nach Nordkorea", "nach Kurdistan", "nach Bayern", - "nach Japan", "nach Irak", "in den Iran", "nach Saudi-Arabien", - "nach Libyen", "nach Niger", "nach Uganda", "nach Afghanistan" -]; - -module.exports = bot => { - bot._trigger.set("abschieben", { - call: /^(.|\/)abschieben/i, - level: 0, - active: true, - clients: ["irc", "tg"], - f: e => { - let args = e.message.trim().split(" "); - args.shift(); - args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; - e.replyAction(`schiebt [b]${args[0]}[/b] ${Dest[~~(Math.random() * Dest.length)]} ab.`); - } - }); -}; diff --git a/src/inc/trigger/butterkaese.js b/src/inc/trigger/butterkaese.js deleted file mode 100644 index 5edab84..0000000 --- a/src/inc/trigger/butterkaese.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = bot => { - bot._trigger.set("butterkaese", { - call: /^(.|\/)butterkäse/i, - level: 0, - active: true, - clients: ["irc", "tg"], - f: e => { - let args = e.message.trim().split(" "); - args.shift(); - args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; - e.replyAction(`drischt mit einem großen Stück Butterkäse auf [b]${args[0]}[/b] ein.`); - } - }); -}; diff --git a/src/inc/trigger/drugs.js b/src/inc/trigger/drugs.js index c706eb0..dd7d3e9 100644 --- a/src/inc/trigger/drugs.js +++ b/src/inc/trigger/drugs.js @@ -1,47 +1,15 @@ -const strains = { - 'sativa': [ - 'Sour Diesel', 'Green Crack', 'Jack Herer', 'Durban Poison', - 'Lemon Haze', 'Strawberry Cough', 'Super Silver Haze', - 'Alaskan Thunder Fuck', 'Super Lemon Haze', 'Amnesia Haze', - 'Maui Wowie', 'Chocolope', 'Harlequin' - ], - 'indica': [ - 'Granddaddy Purple', 'Bubba Kush', 'Northern Lights', - 'Blue Cheese', 'Purple Kush', 'Blueberry', 'Grape Ape', - 'Blackberry Kush', 'Master Kush', 'God\'s Gift', - 'LA Confidential', 'Death Star', 'Purple Urkle', - 'Afghan Kush', 'Skywalker', 'White Rhino', 'Hindu Kush' - ], - 'hybrid': [ - 'Blue Dream', 'Girl Scout Cookies', 'OG Kush', 'White Widow', - 'Gorilla Glue #4', 'Pineapple Express', 'Trainwreck', - 'AK-47', 'Headband', 'Chemdawg', 'Cheese', 'Cherry Pie', - 'Skywalker OG', 'Tahoe OG Kush', 'Lemon Kush', - 'Platinum Girl Scout Cookies', 'Golden Goat', 'Agent Orange' - ] +import sql from "../sql.js"; + +const data = { + dope_actions: {}, + dope_strains: {} }; -const actions = { - 'joint': [ - ['passes', 'to'], - ['rolls', 'for'], - ['lights', 'for'] - ], - 'bong': [ - ['passes', 'to'], - ['preps', 'for'], - ['lights', 'for'] - ], - 'vape': [ - ['passes', 'to'] - ], - 'blunt': [ - ['passes', 'to'], - ['rolls', 'for'], - ['lights', 'for'] - ] -}; -const strain_types = Object.keys(strains); -const action_types = Object.keys(actions); + +Object.keys(data).forEach(cur => { + sql.exec(`select \`data\` from \`useless\` where \`trigger\` = '${cur}' limit 1`, (err, row) => { + data[cur] = JSON.parse(row[0].data); + }); +}); module.exports = bot => { bot._trigger.set("dope", { @@ -54,10 +22,13 @@ module.exports = bot => { args.shift(); args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; + const strain_types = Object.keys(data.dope_strains); + const action_types = Object.keys(data.dope_actions); + const strain_type = strain_types[~~(Math.random() * strain_types.length)] , consume_type = action_types[~~(Math.random() * action_types.length)] - , action = actions[consume_type][~~(Math.random() * actions[consume_type].length)] - , strain = strains[strain_type][~~(Math.random() * strains[strain_type].length)]; + , action = data.dope_actions[consume_type][~~(Math.random() * data.dope_actions[consume_type].length)] + , strain = data.dope_strains[strain_type][~~(Math.random() * data.dope_strains[strain_type].length)]; e.replyAction(`${action[0]} a ${consume_type} of the finest ${strain_type} "${strain}" ${action[1]} [b]${args[0]}[/b]`); } diff --git a/src/inc/trigger/kaffee.js b/src/inc/trigger/kaffee.js deleted file mode 100644 index 5ff6a0a..0000000 --- a/src/inc/trigger/kaffee.js +++ /dev/null @@ -1,19 +0,0 @@ -const texte = [ - `einen frisch gebrühten Kaffee aus aromatisch hochwertigen und laktosefreien Kaffeebohnen, die nach dem Vorbild der kolonisierten Ausbeutung herangewachsen und importiert worden sind`, - `einen frisch gebrühten Kaffee aus aromatisch minderwertigen Kaffeebohnen, die zu einem überhöhten Preis und nach dem Prinzip des Fairtrade® herangewachsen und importiert worden sind` -]; - -module.exports = bot => { - bot._trigger.set("kaffee", { - call: /^(.|\/)kaffee/i, - level: 0, - active: true, - clients: ["irc", "tg"], - f: e => { - let args = e.message.trim().split(" "); - args.shift(); - args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; - e.replyAction(`serviert [b]${args.join(" ")}[/b] ${texte[~~(Math.random() * texte.length)]}; Prost!`); - } - }); -}; diff --git a/src/inc/trigger/lachs.js b/src/inc/trigger/lachs.js deleted file mode 100644 index 44b92bb..0000000 --- a/src/inc/trigger/lachs.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = bot => { - bot._trigger.set("lachs", { - call: /^(.|\/)lachs/i, - level: 0, - active: true, - clients: ["irc", "tg"], - f: e => { - e.reply("öhöhöhöhöhöhö"); - } - }); -}; \ No newline at end of file diff --git a/src/inc/trigger/notschlachten.js b/src/inc/trigger/notschlachten.js deleted file mode 100644 index b2532c3..0000000 --- a/src/inc/trigger/notschlachten.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = bot => { - bot._trigger.set("notschlachten", { - call: /^(.|\/)notschlachten/i, - level: 0, - active: true, - clients: ["irc", "tg"], - f: e => { - let args = e.message.trim().split(" "); - args.shift(); - args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; - e.replyAction(`notschlachtet [b]${args[0]}[/b] und entsorgt die Leiche im Biomüll`); - } - }); -}; \ No newline at end of file diff --git a/src/inc/trigger/useless.js b/src/inc/trigger/useless.js new file mode 100644 index 0000000..155e9bc --- /dev/null +++ b/src/inc/trigger/useless.js @@ -0,0 +1,148 @@ +import sql from "../sql.js"; + +const data = { + yiff: [], + kill_templates: [], + kill_parts: {}, + abschieben: [], + kaffee: [] +}; + +Object.keys(data).forEach(cur => { + sql.exec(`select \`data\` from \`useless\` where \`trigger\` = '${cur}' limit 1`, (err, row) => { + data[cur] = JSON.parse(row[0].data); + }); +}); + +module.exports = bot => { + bot._trigger.set("kiss", { + call: /^(.|\/)kiss/i, + level: 0, + active: true, + clients: ["irc", "tg"], + f: e => { + let args = e.message.trim().split(" "); + args.shift(); + args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; + e.reply(`[b](づ。◕‿‿◕。)づ" 。。・゜゜・。。・゜❤ ${args.join(" ").trim()} ❤[/b]`); + } + }); + + bot._trigger.set("hug", { + call: /^(.|\/)hug/i, + level: 0, + active: true, + clients: ["irc", "tg"], + f: e => { + let args = e.message.trim().split(" "); + args.shift(); + args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; + e.reply(`[b]♥♡❤♡♥ ${args.join(" ").trim()} ♥♡❤♡♥[/b]`); + } + }); + + bot._trigger.set("kill", { + call: /^(.|\/)kill/i, + level: 0, + active: true, + clients: ["irc", "tg"], + f: e => { + let args = e.message.trim().split(" "); + args.shift(); + args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; + + e.replyAction(data.kill_templates[~~(Math.random() * data.kill_templates.length)] + .replace("{user}", `[b]${args[0]}[/b]`) + .replace("{limbs}", data.kill_parts.limbs[~~(Math.random() * data.kill_parts.limbs.length)]) + .replace("{gun}", data.kill_parts.gun[~~(Math.random() * data.kill_parts.gun.length)]) + .replace("{weapon_stab}", data.kill_parts.weapon_stab[~~(Math.random() * data.kill_parts.weapon_stab.length)]) + .replace("{weapon_slice}", data.kill_parts.weapon_slice[~~(Math.random() * data.kill_parts.weapon_slice.length)]) + .replace("{weapon_crush}", data.kill_parts.weapon_crush[~~(Math.random() * data.kill_parts.weapon_crush.length)]) + .replace("{weapon_explosive}", data.kill_parts.weapon_explosive[~~(Math.random() * data.kill_parts.weapon_explosive.length)]) + .replace("{tall_thing}", data.kill_parts.tall_thing[~~(Math.random() * data.kill_parts.tall_thing.length)]) + .replace("{spiked_thing}", data.kill_parts.spiked_thing[~~(Math.random() * data.kill_parts.spiked_thing.length)]) + .replace("{bomb}", data.kill_parts.bomb[~~(Math.random() * data.kill_parts.bomb.length)]) + ); + } + }); + + bot._trigger.set("yiff", { + call: /^(.|\/)yiff/i, + level: 0, + active: true, + clients: ["irc", "tg"], + f: e => { + let args = e.message.trim().split(" "); + args.shift(); + args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; + + e.replyAction(data.yiff[~~(Math.random() * data.yiff.length)] + .replace("{user}", `[b]${args[0]}[/b]`) + ); + } + }); + + bot._trigger.set("abschieben", { + call: /^(.|\/)abschieben/i, + level: 0, + active: true, + clients: ["irc", "tg"], + f: e => { + let args = e.message.trim().split(" "); + args.shift(); + args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; + e.replyAction(`schiebt [b]${args[0]}[/b] ${data.abschieben[~~(Math.random() * data.abschieben.length)]} ab.`); + } + }); + + bot._trigger.set("butterkaese", { + call: /^(.|\/)butterkäse/i, + level: 0, + active: true, + clients: ["irc", "tg"], + f: e => { + let args = e.message.trim().split(" "); + args.shift(); + args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; + e.replyAction(`drischt mit einem großen Stück Butterkäse auf [b]${args[0]}[/b] ein.`); + } + }); + + bot._trigger.set("notschlachten", { + call: /^(.|\/)notschlachten/i, + level: 0, + active: true, + clients: ["irc", "tg"], + f: e => { + let args = e.message.trim().split(" "); + args.shift(); + args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; + e.replyAction(`notschlachtet [b]${args[0]}[/b] und entsorgt die Leiche im Biomüll`); + } + }); + + bot._trigger.set("lachs", { + call: /^(.|\/)lachs/i, + level: 0, + active: true, + clients: ["irc", "tg"], + f: e => { + e.reply("öhöhöhöhöhöhö"); + } + }); + + bot._trigger.set("kaffee", { + call: /^(.|\/)kaffee/i, + level: 0, + active: true, + clients: ["irc", "tg"], + f: e => { + let args = e.message.trim().split(" "); + args.shift(); + args[0] = (args[0] == String.empty || typeof args[0] === "undefined" || args[0] == "") ? e.user.nick : args[0]; + e.replyAction(data.kaffee[~~(Math.random() * data.kaffee.length)] + .replace("{user}", `[b]${args[0]}[/b]`) + ); + } + }); +}; \ No newline at end of file