Last active
August 29, 2015 14:13
-
-
Save czbaker/f0c8dcaa2c4f46ffeac7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Event Handlers | |
Template.channelAdmin.events({ | |
'click #join': function() { | |
channel = "#" + Meteor.user().username; | |
Meteor.call("joinchannel", channel, function(err, res) { | |
if (err) { | |
throw new Meteor.Error("join-error", "Unable to join channel."); | |
} else { | |
console.log("Join Channel Called? (" + channel + ")") | |
} | |
}); | |
}, | |
'click #part': function() { | |
channel = "#" + Meteor.user().username; | |
Meteor.call("partchannel", channel, function(err, res) { | |
if (err) { | |
throw new Meteor.Error("part-error", "Unable to part channel."); | |
} else { | |
console.log("Part Channel Called? (" + channel + ")") | |
} | |
}); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set client options | |
var chanList = []; | |
var theChannels = IRCChannels.find(); | |
theChannels.forEach(function(doc) { | |
chanList.push(doc.channel); | |
}); | |
var options = { | |
server: 'irc.freenode.net', | |
port: 6667, | |
nick: 'wasdbot', | |
password: false, | |
realname: "WASDBot", | |
username: "WASDBot", | |
debug: false, | |
stripColors: true, | |
channels: chanList | |
}; | |
// Try to connect to the server, attach server instance to Meteor for control. | |
ircClient = new IRC(options); | |
ircClient.connect(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Meteor.methods({ | |
// Join a Channel | |
joinchannel: function(channel) { | |
// Check channel presence | |
inChannel = IRCChannels.find({"channel": channel}, {"_id": 1}).count(); | |
if (inChannel == 0) { | |
ircClient.join(channel); | |
chans = IRCChannels.find().count(); | |
console.log("Current channels: " + chans); | |
} | |
}, | |
partchannel: function(channel) { | |
// Check channel presence | |
var inChannel = IRCChannels.find({"channel": channel}, {"_id": 1}).count(); | |
if (inChannel == 1) { | |
ircClient.part(channel); | |
var chans = IRCChannels.find().count(); | |
console.log("Current channels: " + chans); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment