Skip to content

Instantly share code, notes, and snippets.

@ticklemynausea
Created February 9, 2017 12:09
Show Gist options
  • Select an option

  • Save ticklemynausea/04ae7876520fab02476084ab5ce05251 to your computer and use it in GitHub Desktop.

Select an option

Save ticklemynausea/04ae7876520fab02476084ab5ce05251 to your computer and use it in GitHub Desktop.
'use strict';
const util = require('util');
const _ = require('lodash');
module.exports = (bot) => ({
id: 'irc',
description: 'loads of irc commands',
commands: [
{
id: 'send',
description: [
'Send a raw irc message to the server.',
'Syntax: !send <message> | .s <message>'
],
triggers: [/^!send (#.+)$/, /^\.s (#.+)$/],
level: 90,
callback: (data) => {
let message = data.match[1];
bot.client.send(message);
}
},
{
id: 'join',
description: [
'Join a channel on command.',
'Syntax: !join <#channel>'
],
triggers: /^!join (#.+)$/,
level: 50,
callback: (data) => {
let channel = data.match[1];
bot.client.join(channel, (nick, message) => {
bot.client.say(data.reply, `I joined ${channel}.`);
});
}
},
{
id: 'part',
description: [
'Leave a joined channel on command.',
'Syntax: !part <#channel>'
],
triggers: /^!part (#.+)$/,
level: 50,
callback: (data) => {
let channel = data.match[1];
bot.client.part(channel, (nick, message) => {
bot.client.say(data.reply, `I left ${channel}.`);
});
}
},
{
id: 'say',
description: [
'Send a message to the specified target.',
'Syntax: !say <target> <message>'
],
triggers: /^!say (\S+) (.+)$/,
level: 50,
callback: (data) => {
//console.log(data.match)
let target = data.match[1];
let message = data.match[2];
bot.client.say(target, message);
}
},
{
id: 'ctcp',
description: [
'Send a CTCP message to the specified target.',
'Syntax: !ctcp <target> <type> <message>'
],
triggers: /^!ctcp (\S+) (\S)+ (.+)$/,
level: 90,
callback: (data) => {
let target = data.match[1];
let type = data.match[2];
let message = data.match[3];
bot.client.ctcp(target, type, message);
}
},
{
id: 'action',
description: [
'Send an action message to the specified target.',
'Syntax: !action <target> <message>'
],
triggers: /^!action (\S+) (.+)$/,
level: 50,
callback: (data) => {
let target = data.match[1];
let message = data.match[2];
bot.client.action(target, message);
}
},
{
id: 'notice',
description: [
'Send a notice message to the specified target.',
'Syntax: !notice <target> <message>'
],
triggers: /^!notice (\S+) (.*)$/,
level: 50,
callback: (data) => {
let target = data.match[1];
let message = data.match[2];
bot.client.notice(target, message);
}
},
{
id: 'whois',
description: [
'Make a whois request to the server',
'Syntax: !whois <target>'
],
triggers: /^!whois (.*)$/,
level: 80,
callback: (data) => {
let nick = data.match[1];
bot.client.whois(nick, (info) => {
bot.client.say(data.reply, JSON.stringify(info));
});
}
},
{
id: 'nick',
description: [
'Changes the bot\'s nickname',
'Syntax: !nick <newnick>'
],
triggers: /^!nick (\S+)$/,
level: 90,
callback: (data) => {
let nick = data.match[1];
bot.client.send('NICK', nick);
}
},
{
id: 'quit',
description: [
'Makes the bot quit from IRC',
'Syntax: !quit [message]'
],
triggers: [/^!quit$/, /!quit (\S+)/],
level: 90,
callback: (data) => {
let message = data.match[1];
bot.client.send('QUIT', message);
}
}
]
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment