package TkChat; use warnings; use strict; use Milkbone; use Milkbone::Chat; register_hook("protocol_chat_invited", sub { if(hook("tk_getmain")->messageBox(-title => "Join Chat?", -message => "$ARGS{-user} has invited you to join a chat. Would you like to accept?", -type => 'YesNo', -icon => 'question', -default => 'no') =~ m/yes/i) { hook("protocol_chat_accept", -url => $ARGS{-url}); } else { hook("protocol_chat_decline", -url => $ARGS{-url}); } }); register_hook("protocol_chat_joined", sub { my $chat = hook("tk_getmain")->MBChat; $chat->init($ARGS{-name}); register_hook("protocol_chat_buddy_in_$ARGS{-url}", sub { $ARGS{-self}->on_buddy_in($ARGS{-user}); }, {-self => $chat}); register_hook("protocol_chat_buddy_out_$ARGS{-url}", sub { $ARGS{-self}->on_buddy_out($ARGS{-user}); }, {-self => $chat}); register_hook("protocol_chat_msg_in_$ARGS{-url}", sub { $ARGS{-self}->on_msg_in($ARGS{-user}); }, {-self => $chat}); register_hook("protocol_chat_closed_$ARGS{-url}", sub { $ARGS{-self}->destroy; }, {-self => $chat}); }); 1;