[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug



again, but with the right diff options -- patch now generates Bug.pl
itself.
diff -N -u --exclude=CVS -b -r infobot/files/infobot.config /home/mstevens/src/perl/infobot/files/infobot.config
--- infobot/files/infobot.config	Wed Feb  9 12:50:22 2000
+++ /home/mstevens/src/perl/infobot/files/infobot.config	Mon Feb 21 14:17:01 2000
@@ -215,3 +215,5 @@
 # exchange rates (exchange 233 DEM to USD)
 exchange true
 
+bug yes
+bugAdmin michael@etla.org
diff -N -u --exclude=CVS -b -r infobot/src/Bug.pl /home/mstevens/src/perl/infobot/src/Bug.pl
--- infobot/src/Bug.pl	Thu Jan  1 01:00:00 1970
+++ /home/mstevens/src/perl/infobot/src/Bug.pl	Mon Feb 21 13:57:49 2000
@@ -0,0 +1,72 @@
+# Bug reporting extension
+
+use strict;
+
+my $no_bug;
+my $no_wrap;
+
+BEGIN {
+  # eval your modules here
+  eval "use Mail::Mailer;";
+  $no_bug++ if ($@);
+  eval "use Text::Wrap;";
+  $no_wrap++ if ($@);
+}
+
+sub bug {
+  # do stuff, return something
+  my ($who, $bug) = @_;
+  return 'NOREPLY' if $no_bug;
+  return 'NOREPLY' unless getparam('bugAdmin');
+
+  my $mailer = new Mail::Mailer;
+  $mailer->open({
+		 'To' => getparam('bugAdmin'),
+		 'Subject' => 'Infobot Bug Report',
+		 });
+
+  $bug =~ s/^bug\s*//;
+
+  if (!$no_wrap) {
+    $bug = Text::Wrap::wrap('','',$bug);
+  }
+  print $mailer <<ENDIT;
+The following infobot bug was reported by irc user $who:
+
+$bug
+ENDIT
+
+  $mailer->close;
+  return "Bug recorded, $who";
+
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Bug.pl - Bug reporting module
+
+=head1 PREREQUISITES
+
+  Mail::Mailer
+  Text::Wrap
+
+=head1 PARAMETERS
+
+bug
+
+=head1 PUBLIC INTERFACE
+
+    bug <bug text here>
+
+=head1 DESCRIPTION
+
+    Allows users to report infobot bugs, by causing an email to be
+sent to a defined bug admin.
+
+=head1 AUTHORS
+
+<michael@etla.org>
diff -N -u --exclude=CVS -b -r infobot/src/Extras.pl /home/mstevens/src/perl/infobot/src/Extras.pl
--- infobot/src/Extras.pl	Wed Feb  9 12:50:22 2000
+++ /home/mstevens/src/perl/infobot/src/Extras.pl	Mon Feb 21 13:57:47 2000
@@ -798,9 +798,31 @@
 	return 'NOREPLY';
     }				# end excuse
 
+    if (getparam('bug') and ($message =~ /^\s*bug(.*)$/i) and (!$no_bug)) {
+      if ($1 !~ /^\s*$/) { 
+        my $ret = &bug($who, $message);
+        if ($msgType eq 'public') {
+          &say($ret);
+        } else {
+          &msg($who, $ret);
+        }
+      } else {
+        if ($msgType eq 'public') {
+	  &say("No bug!");
+        } else {
+	  &msg($who, "No bug!");
+	}
+      } 
+      return 'NOREPLY';
+    }
     return undef;
 }
 
 
 1;
 
+
+
+
+
+