-
- foreach (keys %{$dcc{$type}}) {
- &DEBUG("closing DCC $type to $_ (FIXME).");
- $dcc{$type}{$_}->close();
+
+ my $nick;
+ foreach $nick (keys %{ $dcc{$type} }) {
+ next unless (defined $nick);
+ &status("DCC CHAT: closing DCC $type to $nick.");
+ next unless (defined $dcc{$type}{$nick});
+
+ my $ref = $dcc{$type}{$nick};
+ &dccsay($nick, "bye bye, $nick") if ($type =~ /^chat$/i);
+ $dcc{$type}{$nick}->close();
+ delete $dcc{$type}{$nick};
+ &DEBUG("after close for $nick");