Skip to content

Instantly share code, notes, and snippets.

@FeepingCreature
Created July 3, 2012 01:49
Show Gist options
  • Save FeepingCreature/3037016 to your computer and use it in GitHub Desktop.
Save FeepingCreature/3037016 to your computer and use it in GitHub Desktop.
string host;
string nick = "neatbot";
string channel;
using new Options {
addLong("host", "h", \(string h) { host = h; }, =>required);
addLong("nick", "n", \(string n) { nick = n; });
addLong("channel", "c", \(string c) { channel = c; }, =>required);
args = process args;
}
auto sock = connect (host, 6667);
auto rng = getPRNG 23;
void sendLine(string s) {
writeln "> $s";
sock.sendAll byte[]:s;
sock.sendAll byte[]:"\r\n";
}
sendLine "NICK $nick";
sendLine "USER $nick $nick $nick $nick $nick";
auto recv = castIter!string readDg &sock.recv #.splitAt "\r\n";
for auto line <- recv {
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment