Skip to content

Instantly share code, notes, and snippets.

@whiskers75
Created February 10, 2014 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whiskers75/8921603 to your computer and use it in GitHub Desktop.
Save whiskers75/8921603 to your computer and use it in GitHub Desktop.
protect plugin for fluxbot
coffee = require 'coffee-script/register'
Command = require '../command.coffee'
Protect = {}
Protect.name = 'protect'
Protect.modify = (g) =>
g.bot.on 'part', (chan, nick) =>
bot.join '#botwar'
g.bot.on 'join', (chan, nick, raw) =>
g.db.smembers 'protected', (err, res) =>
if res.indexOf(nick) != -1
g.bot.send 'REMOVE', chan, nick, 'You are on the fluxbot banlist.'
else
g.db.smembers 'hbans', (err, res) =>
res.forEach (host) =>
if raw.host.indexOf(host) != -1
g.bot.send 'REMOVE', chan, nick, 'You are on the fluxbot banlist.'
g.bot.on '-mode', (chan, user, mode, arg) =>
if arg == g.config.nick && mode == 'o'
g.bot.say 'ChanServ', 'OP ' + chan + ' ' + g.config.nick
g.bot.send 'REMOVE', chan, user, 'Deopping fluxbot is violation of intergalactic law and will not be tolerated!'
Protect.commands = {}
Protect.commands.padd = new Command {args: 1, perm: 'protect'}, (g, m, u, t) =>
if m[0] == 'whiskers75' || m[0] == g.config.nick
return g.bot.send 'REMOVE', t, u, 'pls'
g.bot.send 'REMOVE', t, m[0], 'You have been banned. Do not try to reconnect, it will just cause spam.'
g.db.sadd 'protected', m[0], (err, res) =>
if !err
db.smembers 'protected', (err, res) =>
g.bot.say t, 'Banned users: ' + res.join(' ')
Protect.commands.prem = new Command {args: 1, perm: 'protect'}, (g, m, u, t) =>
g.db.srem 'protected', m[0], (err, res) =>
if !err
db.smembers 'protected', (err, res) =>
g.bot.say t, 'Banned users: ' + res.join(' ')
Protect.commands.plist = new Command {perm: 'protect'}, (g, m, u, t) =>
g.db.smembers 'protected', (err, res) =>
g.bot.say t, 'Banned users: ' + res.join(' ')
Protect.commands.hadd = new Command {args: 1, perm: 'protect'}, (g, m, u, t) =>
g.db.sadd 'hbans', m[0], (err, res) =>
if !err
db.smembers 'protected', (err, res) =>
g.bot.say t, 'Banned hosts: ' + res.join(' ')
Protect.commands.hrem = new Command {args: 1, perm: 'protect'}, (g, m, u, t) =>
g.db.srem 'hbans', m[0], (err, res) =>
if !err
db.smembers 'protected', (err, res) =>
g.bot.say t, 'Banned hosts: ' + res.join(' ')
Protect.commands.hlist = new Command {perm: 'protect'}, (g, m, u, t) =>
g.db.smembers 'hbans', (err, res) =>
g.bot.say t, 'Banned hosts: ' + res.join(' ')
module.exports = Protect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment