diff --git a/.gitignore b/.gitignore index 412783e..5231cf9 100644 --- a/.gitignore +++ b/.gitignore @@ -129,4 +129,5 @@ dist .yarn/install-state.gz .pnp.* -.env \ No newline at end of file +.env +config/config.json \ No newline at end of file diff --git a/README.md b/README.md index 05bac48..6313b67 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,8 @@ cold hard bot for cold hard chats ## Deployment -1. Install Docker (required) and Docker Compose (optional, but strongly recommended) -2. Modify the info in the config block in `bot.js` to your taste. +1. Install Docker (required) and Docker Compose (optional, but strongly recommended, following instructions assume its usage) +2. Copy `config/example.config.json` to `config/config.json` and modify the contents to your preference. 3. Run `docker compose up` to begin. Append `-d` to start in the background and `--build` if you make any changes to any files ## Support @@ -40,7 +40,7 @@ If you need assistance with installation or usage, join #5000 on `irc.supernets. ISC License -Copyright (c) 2023 hogwart7 +Copyright (c) 2023 hgw7 Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above diff --git a/bot.js b/bot.js index 2fc470b..d6d72ed 100644 --- a/bot.js +++ b/bot.js @@ -1,3 +1,4 @@ +var config = require('./config/config.json') var irc = require("irc"); var fs = require("fs"); var readline = require('readline'); @@ -6,27 +7,20 @@ var randomext = require('./lib/randomnum'); const { Worker } = require('worker_threads'); //var randomWords = require('better-random-words'); -var config = { //edit your shit here - server: "irc.supernets.org", - port: 6697, - SSL: true, - channels: ['#dev', '#superbowl', '#scroll', '#fascinus'], - botName: "fascinus", - userName: "fascinus", - realName: "Sneed" -}; - -var bot = new irc.Client(config.server, config.botName, { - channels: config.channels, - secure: config.SSL, - port: config.port, - autoRejoin: true, - userName: config.userName, - realName: config.realName, - floodProtection: false, - floodProtectionDelay: 0 +var bot = new irc.Client(config.irc.server, config.irc.nickname, { + channels: config.irc.channels, + secure: config.irc.ssl, + port: config.irc.port, + autoRejoin: config.irc.autorejoin, + userName: config.irc.username, + realName: config.irc.realname, + floodProtection: config.floodprotect.flood_protection, + floodProtectionDelay: config.floodprotect.flood_protection_delay }); +const msgTimeout = new Set(); +const msgTimeoutMsg = new Set(); + const timer = ms => new Promise(res => setTimeout(res, ms)) const generateRandomString = (amt) => { @@ -202,6 +196,49 @@ bot.addListener('message', function(nick, to, text, from) { } }); +bot.addListener('message', function(nick, to, text, from) { + if (text.startsWith(config.irc.prefix)) { + if (msgTimeout.has(to)) { + if (msgTimeoutMsg.has("yes")) { + return; + } else { + bot.say(to, errorMsg+" You are sending commands too quickly") + msgTimeoutMsg.add("yes"); + setTimeout(() => { + msgTimeoutMsg.delete("yes"); + }, config.floodprotect.command_listen_timeout) + } + } else { + var args = text.split(' '); + var command = args[0].toLowerCase() + if (args[0] === '$help') { + help(to); + } else if (command === config.irc.prefix+'flood') { + flood(to, args) + } else if (command === config.irc.prefix+'sneed') { + sneed(to); + } else if (command === config.irc.prefix+'ctcpflood') { + ctcp(args[1], args[2], args[3]); + } else if (command === config.irc.prefix+'rspam') { + rspam(to, args[1]) + } else if (command === config.irc.prefix+'uspam') { + uspam(to, args[1]); + } else if (command === config.irc.prefix+'art') { + art(to, args[1]); + } else if (command === config.irc.prefix+'fart') { + art(to, args[1]); + } else if (command === config.irc.prefix+'godwords') { + godwords(to, args[1]); + } + msgTimeout.add(to); + setTimeout(() => { + msgTimeout.delete(to); + }, config.floodprotect.command_listen_timeout) + } + } +}) + + bot.addListener('error', function(message) { console.log('error: ', message); }); diff --git a/config/example.config.json b/config/example.config.json new file mode 100644 index 0000000..aea2d4a --- /dev/null +++ b/config/example.config.json @@ -0,0 +1,20 @@ +{ + "irc": { + "server": "irc.supernets.org", + "port": 6697, + "ssl": "true", + "channels": [ + "#5000" + ], + "nickname": "fascinus", + "username": "fascinus", + "realname": "git.supernets.org/hgw/fascinus", + "autorejoin": "true", + "prefix": "$" + }, + "floodprotect": { + "flood_protection": "false", + "flood_protection_delay": "0", + "command_listen_timeout": "2500" + } +} \ No newline at end of file diff --git a/lib/randomword.js b/lib/randomword.js index 3d6e252..d2961f1 100644 --- a/lib/randomword.js +++ b/lib/randomword.js @@ -261,7 +261,7 @@ var wordList = [ "vacuole", "vacuome", "vacuous", "vacuums", "vadose", "vaguest", "vaivode", "valance", "valence", "valency", "valerin", "valeric", "valeted", "valgoid", "valines", "valises", "valkyrs", "valonia", "valours", "valse", "valuers", "valuing", "valvate", "vamosed", "vamoses", "vampers", "vamping", "vampish", "vanadic", "vanadyl", "vandal", "vandals", "vandyke", "vanessa", "vanillas", "vanille", "vanillo", "vanitas", "vanning", "vanpool", "vantages", "vapidly", "vapored", "vapours", "vapulae", "varactor", "variant", "variate", "varices", "varioli", "variola", "various", "varlets", "varnish", "varsity", "varying", "vascula", "vasculum", "vastier", "vastity", "vatfuls", "vaudois", "vaulted", "vaulter", "vaulting", "vaunted", "vaulter", "vealier", "vectors", "vedalias", "vedette", "vegan", "vegans", "vegetal", "vegete", "vegetes", "vehicle", "veiling", "veinier", "veining", "veinlet", "veinule", "velaric", "velaria", "veliger", "vellums", "velours", "velured", "velures", "velvet", "velvets", "venally", "vendees", "venders", "vending", "vendors", "veneers", "venial", "venines", "venires", "venomed", "venomer", "venoming", "ventage", "ventail", "venters", "venting", "ventral", "venture", "ventures", "venue", "venues", "verdant", "verdict", "vergers", "verging", "verglas", "veridic", "verisms", "verists", "verites", "vermeil", "vermian", "vermuth", "vernier", "vernity", "versals", "versant", "versers", "versify", "versine", "versing", "version", "verstes", "vertigo", "vervets", "vesical", "vesicle", "vesper", "vespers", "vespire", "vestal", "vestals", "vestees", "vesting", "vestral", "vestry", "vetoers", "vexedly", "vexilla", "vexings", "viaduct", "viatica", "vibrant", "vibrate", "vicarly", "viceroy", "vicious", "victims", "victors", "victual", "videlicet", "videx", "videxes", "vieques", "viewers", "wabbers", "wabbles", "wabblers", "waddled", "waddler", "waddles", "wadiats", "wadmaal", "wadmals", "wadmels", "wadmoll", "wadmols", "wadsets", "waeness", "waftage", "wafture", "waggers", "wagging", "wagling", "wahines", "wailing", "wainage", "wainful", "waining", "wainscot", "waisted", "waister", "waiting", "waiving", "wakened", "wakener", "wakikis", "wallets", "wallies", "wallops", "wallows", "walnuts", "wamble", "wambled", "wambles", "wambly", "wamefou", "wameful", "wampums", "wandero", "wandle", "wangled", "wangler", "wangles", "wanigan", "wanking", "wannest", "wannish", "wanting", "wapitis", "wapiti", "warble", "warbled", "warbler", "warbles", "wardens", "warders", "warding", "warehou", "wareing", "warfare", "warhead", "warison", "warless", "warlike", "warling", "warlock", "warlord", "warmed", "warmers", "warmest", "warming", "warmish", "warmth", "warmths", "warners", "warning", "warpage", "warper", "warping", "warrant", "warrant", "warrant", "warranted", "warranted", "warranted", "warrens", "warring", "warrior", "warstle", "warthog", "wartier", "wartime", "wasabit", "wasatch", "washday", "washers", "washier", "washing", "washrag", "washtub", "wasps", "wasting", "wastrel", "wastril", "watchdog", "watcher", "watchfu", "watching", "waterlo", "watery", "wattage", "watters", "wattest", "wattles", "wauchle", "waucht", "waught", "wauling", "wauping", "wauring", "wausau", "wavelet", "waveoff", "wavered", "waverer", "wavering", "waxbill", "waxiest", "waxlike", "waxwing", "waxwork", "waxworm", "waybill", "wayfare", "waygate", "waylaid", "waylayer", "wayless", "wayside", "waywode", "weakens", "weakest", "weakish", "wealful", "wealthy", "weaners", "weanling", "weapone", "wearers", "xanthic", "xanthin", "xanthoma", "xanthone", "xanthein", "xanthene", "xanthenes", "xanthine", "xanthines", "xanthins", "xanthoma", "xanthomas", "xanthones", "xebecs", "xenials", "xenogamy", "xenogeny", "xenolith", "xenomai", "xenon", "xenons", "xenopus", "xenure", "xenures", "xerarch", "xeroses", "xerosis", "xiphias", "xiphiid", "xiphiids", "xiphoids", "xylenes", "xylidin", "xylidins", "xylitol", "xylitols", "xylocarp", "xyloid", "xyloids", "xyloma", "xylomata", "xylose", "xyloses", "xylyl", "xylyls", "xystoi", "xystos", "xysts", "yabbers", "yacking", "yaffing", "yagers", "yagging", "yakitori", "yakking", "yakimes", "yakking", "yaksha", "yakshas", "yakutat", "yamalka", "yammer", "yammered", "yammerer", "yammering", "yammers", "yanking", "yanquis", "yantra", "yantras", "yapocks", "yapok", "yapons", "yapping", "yarayan", "yardage", "yardang", "yarding", "yardman", "yardmen", "yardwand", "yarely", "yarest", "yarners", "yarning", "yarrow", "yarrows", "yatagan", "yatagan", "yataghan", "yataghans", "yatagans", "yatter", "yattered", "yattering", "yatters", "yauds", "yauping", "yaupon", "yaupons", "yautia", "yautias", "yawings", "yawled", "yawling", "yawners", "yawning", "yawpers", "yawping", "yawpings", "yeaning", "yearnful", "yearning", "yeasting", "yeelins", "yelling", "yellowed", "yellowest", "yellowing", "yellowish", "yellowy", "yelping", "yenned", "yenning", "yeoman", "yeomanly", "yeomanry", "yeomen", "yessing", "yestreen", "yetlins", "yeuking", "yielden", "yielding", "yielding", "yirring", "yobbish", "yocking", "yodeled", "yodeler", "yodeling", -"03orb", "06xipu", "06croacre", "09maub", "raping" +"03orb", "06xipu", "06croacre", "09maub", "raping" ]; function words(options) {