D Paste by Chris Miller
Description: IRC client example; dirclib + splat
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | import irclib.all, irclib.splatclient, splat; import std.random, std.string, std.stdio; class IrcBot: SplatIrcClient { this(char[] server, ushort port = 6667) { super(server, port); } protected override void onLoggedIn() { writefln("Logged in"); sendLine("JOIN #dbot"); } protected override void onChannelMessageReceived(IrcChannelMessage imsg) { writefln("<%s> %s", imsg.fromNick, imsg.message); } protected override void onChannelActionReceived(IrcChannelMessage imsg) { writefln("* %s %s", imsg.fromNick, imsg.message); } } void main() { auto ircbot = new IrcBot("irc.freenode.net", 6667); ircbot.nick = "splatbot" ~ std.string.toString(std.random.rand() % 1000); ircbot.connect(); splat.run(); } |
(some replies deleted)