Saturday, 12 September 2015

Dart POW - ( Package Of The Week) #10 : irc

Who is ready for another - Dart POW? A weekly look at an interesting Package on pub.dartlang.org

The irc package is a 'one-stop shop for all your irc needs in Dart'. IRC (Internet Relay Chat) has been around a long time and is still a great way to connect. There are a number of IRC packages on pub so be sure to check them all out.

This example is taken straight from the irc docs:

import "package:irc/client.dart";

// This stores our configuration for this client
var config = new Configuration(host: "irc.esper.net", port: 6667, nickname: "DartBot", username: "DartBot");
// "Primary" IRC class
var client = new Client(config);

main() {
  // Register an onReady event handler
  client.onReady.listen((event) {
    // Join a channel
    event.join("#directcode");
  });

  // Register an onMessage event handler    
  client.onMessage.listen((event) {
    // Log any message events to the console
    print("<${event.target.name}><${event.from.name}> ${event.message}");
  });

  // Connect to the server
  client.connect();
}

Feel free to leave a comment with suggestions for the next Dart POW post! Don't be too shy to suggest your own package :-)