Last active
August 29, 2015 14:13
-
-
Save czbaker/09eed5c17bddd3618703 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
### BOT CLASS ### | |
class WASDbot | |
# Bot object constructor | |
constructor: (params) -> | |
@params = params | |
@doc = null | |
@client = new IRC params | |
# Connect to a network | |
connect: -> | |
@client.connect | |
# Say something to a channel | |
say: (msg, chan) -> | |
if typeof chan is "undefined" then chan = @params.channels[0] | |
@client.say chan, msg | |
return | |
### CLIENT INITIATION ### | |
# Variable to hold clients | |
@CLIENTS = [] | |
# Get user list for client gen | |
userList = [] | |
theChannels = IRCChannels.find() | |
theNames = Meteor.users.find({}, {fields: {profile: 1}}) | |
# Generate client objects from list of users at time of startup. | |
theNames.forEach (doc) -> | |
CLIENTS[doc.profile.name] = new WASDbot | |
server: 'irc.twitch.tv' | |
port: 6667 | |
nick: "wasdboss" | |
realname: "wasdboss" | |
username: "wasdboss" | |
password: "PASS GOES HERE" | |
channels: ["#" + doc.profile.name] | |
console.log "Created client for " + doc.profile.name | |
console.log CLIENTS | |
_.each(CLIENTS, (client) -> | |
console.log "Attempting to connect client for " + client.params.channels[0] | |
client.connect() | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment