--- a/scripts/queryresume.pl
+++ b/scripts/queryresume.pl
@@ -32,13 +32,14 @@
 
 sub sig_window_item_new ($$) {
     my ($win, $witem) = @_;
-    return unless (ref $witem && $witem->{type} eq 'QUERY');
+    #return unless (ref $witem && $witem->{type} eq 'QUERY');
+    return unless (ref $witem);
     my @data;
     my $filename = Irssi::settings_get_str('autolog_path');
     my $servertag = $witem->{server}->{tag};
     my $name = lc $witem->{name};
-    $filename =~ s/(\$tag|\$1)/$servertag/g;
-    $filename =~ s/\$0/$name/g;
+    $filename =~ s/\$tag\b|\$\{tag\}|\$1\b|\$\{1\}/$servertag/g;
+    $filename =~ s/\$0\b|\$\{0\}/$name/g;
     my @lt = localtime(time);
     my $zone;
     $filename = strftime($filename, @lt, $zone);
