diff --git a/jsbot b/jsbot index 6723ded..87ede26 160000 --- a/jsbot +++ b/jsbot @@ -1 +1 @@ -Subproject commit 6723ded150692bd157b43ac287a3913abd1d7a99 +Subproject commit 87ede262d4d384878941eb17095e4dc0e1b57962 diff --git a/modules/admin.js b/modules/admin.js index 2a79884..173e270 100644 --- a/modules/admin.js +++ b/modules/admin.js @@ -12,21 +12,34 @@ var admin = function(dbot) { // Join a channel 'join': function(event) { var channel = event.params[1]; - dbot.instance.join(event, channel); - event.reply(dbot.t('join', {'channel': channel})); + if(event.allChannels.hasOwnProperty(channel)) { + event.reply("I'm already in that channel."); + } else { + dbot.instance.join(event, channel); + event.reply(dbot.t('join', {'channel': channel})); + } }, // Leave a channel 'part': function(event) { var channel = event.params[1]; - event.instance.part(event, channel); - event.reply(dbot.t('part', {'channel': channel})); + if(!event.allChannels.hasOwnProperty(channel)) { + event.reply("I'm not in that channel."); + } else { + event.instance.part(event, channel); + event.reply(dbot.t('part', {'channel': channel})); + } }, // Op admin caller in given channel 'opme': function(event) { - event.channel = event.params[1]; - dbot.instance.mode(event, '+o ' + event.user); + var channel = event.params[1]; + + // If given channel isn't valid just op in current one. + if(!event.allChannels.hasOwnProperty(channel)) { + channel = event.channel.name; + } + dbot.instance.mode(event, channel, ' +o ' + event.user); }, // Do a git pull and reload @@ -49,7 +62,7 @@ var admin = function(dbot) { 'say': function(event) { var channel = event.params[1]; if(event.params[1] === "@") { - var channel = event.channel; + var channel = event.channel.name; } var message = event.params.slice(2).join(' '); dbot.say(event.server, channel, message); diff --git a/modules/link.js b/modules/link.js index 8ac07a2..b9c5eaf 100644 --- a/modules/link.js +++ b/modules/link.js @@ -10,7 +10,7 @@ var link = function(dbot) { var commands = { '~title': function(event) { - var link = links[event.channel]; + var link = links[event.channel.name]; if(event.params[1] !== undefined) { var urlMatches = event.params[1].match(urlRegex); if(urlMatches !== null) { @@ -40,7 +40,7 @@ var link = function(dbot) { 'listener': function(event) { var urlMatches = event.message.match(urlRegex); if(urlMatches !== null) { - links[event.channel] = urlMatches[0]; + links[event.channel.name] = urlMatches[0]; } }, 'on': 'PRIVMSG' diff --git a/modules/report.js b/modules/report.js index 063865b..1e6f03d 100644 --- a/modules/report.js +++ b/modules/report.js @@ -5,8 +5,8 @@ var report = function(dbot) { var nick = event.input[2]; var reason = event.input[3]; - if(dbot.instance.connections[event.server].channels.hasOwnProperty(channelName)) { - var channel = dbot.instance.connections[event.server].channels[channelName]; + if(event.allChannels.hasOwnProperty(channelName)) { + var channel = event.allChannels[channelName]; if(channel.nicks.hasOwnProperty(nick)) { var ops = []; for(var possibOps in channel.nicks) { @@ -15,6 +15,11 @@ var report = function(dbot) { } } + // Does the channel have an admin channel? + if(event.allChannels.hasOwnProperty('#' + channelName)) { + ops.push('#' + channelName); + } + for(var i=0;i