package NetDemo;
use Milkbone;
use strict;
use warnings;
register_hook "protocol_signon", sub {
hook("after", -time => 10, -code => sub { hook("signed_in") });
register_hook "protocol_add_buddy", sub { hook("buddy_in", -buddy =>
$ARGS{-buddy}, -group => $ARGS{-group}); };
register_hook "protocol_get_groups", sub { return ["Buddies", "You"] };
register_hook "protocol_get_realname", sub { return lc $ARGS{-user} };
register_hook "protocol_request_info", sub {
hook("after", -time => 1000, -code => sub {
hook("protocol_info_received_$ARGS{-user}",
-profile => 'test', -away => 'test');
});
};
register_hook "protocol_send_im", sub {
hook("after", -time => 500, -code => [sub {
hook("msg_sent_$_[0]", -user => $_[0], -msg => $_[1], -away => 0);
hook("after", -time => 500, sub {
hook("msg_in", -user => $_[0], -msg => $_[1], -away => 0);
hook("msg_in_$_[0]", -user => $_[0], -msg => $_[1], -away => 0);
});
}, $ARGS{-dest}, $ARGS{-msg}]);
};
register_hook "protocol_away_status", sub { 0 };
hook("after", -time => 1000, -code => sub {
hook("buddy_in", -group => 'Buddies', -buddy => 'test_user');
});
hook("after", -time => 1000, -code => sub {
hook("msg_in", -user => 'thatguy', -msg => 'hey');
});
hook("after", -time => 1500, -code => sub {
hook("protocol_send_im", -dest => 'thatguy', -msg => 'hey there');
});
};
1;