Skip to content
Logan Gorence edited this page Jul 3, 2015 · 13 revisions

Adding the Dependency

Add the following to your pubspec.yaml

dependencies:
  irc: ">=2.1.6 <2.2.0"

After that, run pub install

Import the Library

import 'package:irc/irc.dart';

Use the Library

var config = new Configuration(host: "irc.esper.net", port: 6667, nickname: "DartBot", username: "DartBot");
var bot = new CommandBot(config, prefix: ".");

bot.onEvent(MOTDEvent).listen((event) {
  print(event.message);
});

bot.onReady.listen((event) {
  event.join("#directcode");
});
  
bot.onMessage.listen((event) {
  print("<${event.target}><${event.from}> ${event.message}");
});
  
bot.command("help", (CommandEvent event) {
  event.reply("> ${Color.BLUE}Commands${Color.RESET}: ${bot.commandNames().join(', ')}");
});

bot.onBotJoin.listen((event) {
  print("Joined ${event.channel.name}");
});

bot.onBotPart.listen((event) {
  print("Left ${event.channel.name}");
});

bot.connect();
Clone this wiki locally