[7d4fbcd] | 1 | ### The owlconf config file -*- perl -*- |
---|
| 2 | ### $Id$ |
---|
| 3 | ### |
---|
| 4 | ### This file is interpreted by the perl interpreter. |
---|
| 5 | ### If you wish to execute an owl command use the |
---|
| 6 | ### function owl::command(). i.e. |
---|
| 7 | ### |
---|
| 8 | ### owl::command("set zsigproc /mit/kretch/bin/getzsig"); |
---|
| 9 | ### |
---|
| 10 | ### will set the owl variable zsigproc. Subroutines created with |
---|
| 11 | ### the names below will be executed at the specified times: |
---|
| 12 | ### |
---|
| 13 | ### subroutine name properties |
---|
| 14 | ### --------------- ---------- |
---|
| 15 | ### owl::startup() run when owl first starts |
---|
| 16 | ### owl::shutdown() run when owl exits |
---|
| 17 | ### owl::format_msg() run when a new message arrives, the return |
---|
| 18 | ### value is used to display the message on the |
---|
| 19 | ### screen |
---|
| 20 | ### |
---|
| 21 | ### The following variables will be set each time a message is recevied: |
---|
| 22 | ### |
---|
| 23 | ### $owl::class, $owl::instance, $owl::recipient, |
---|
| 24 | ### $owl::sender, $owl::opcode, $owl::zsig, |
---|
| 25 | ### $owl::msg, $owl::time, $owl::host, @owl::fields |
---|
| 26 | ### |
---|
| 27 | |
---|
| 28 | # classes will be appreviated this way |
---|
| 29 | my %class_abbrev = ( |
---|
| 30 | "message" => "", |
---|
| 31 | "spleen" => "sp", |
---|
| 32 | "ccare" => "cc", |
---|
| 33 | "implied-consent" => "ic", |
---|
| 34 | "syseng" => "se", |
---|
| 35 | "install" => "i", |
---|
| 36 | ); |
---|
| 37 | |
---|
| 38 | sub owl::startup { |
---|
| 39 | owl::command("set logging off"); |
---|
| 40 | #owl::command("set zsigproc /home/nygren/bin/owlzsigs"); |
---|
| 41 | owl::command("set startuplogin off"); |
---|
| 42 | owl::command("set shutdownlogout off"); |
---|
| 43 | #owl::command("set personalbell on"); |
---|
| 44 | owl::command("set rxping on"); |
---|
| 45 | owl::command("set typewinsize 5"); |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | sub owl::shutdown { |
---|
| 49 | # system("/mit/kretch/bin/zkill > /dev/null 2> /dev/null"); |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | sub owl::format_msg { |
---|
| 53 | my ($out, $tmp); |
---|
| 54 | |
---|
| 55 | $owl::sender=~s/\@ATHENA\.MIT\.EDU$//; |
---|
| 56 | $owl::sender=~s/\@local-realm$//; |
---|
| 57 | |
---|
| 58 | if (uc($owl::opcode) eq "PING") { |
---|
| 59 | return("\@bold(PING) from \@bold($owl::sender)\n"); |
---|
| 60 | } elsif (uc($owl::class) eq "LOGIN") { |
---|
| 61 | if (uc($owl::opcode) eq "USER_LOGIN") { |
---|
| 62 | $out="\@bold(LOGIN)"; |
---|
| 63 | } elsif (uc($owl::opcode) eq "USER_LOGOUT") { |
---|
| 64 | $out="\@bold(LOGOUT)"; |
---|
| 65 | } else { |
---|
| 66 | $out="\@bold(UNKNOWN)"; |
---|
| 67 | } |
---|
| 68 | $out.=" for \@bold($owl::sender) at $fields[0] on $fields[2]\n"; |
---|
| 69 | return($out); |
---|
| 70 | } elsif (uc($owl::class) eq "MAIL") { |
---|
| 71 | $out = "\@bold(MAIL) "; |
---|
| 72 | if ($owl::msg =~ /^From:\s+(.+)\s*$/m) { $out .= "From $1 "; } |
---|
| 73 | if ($owl::msg =~ /^To:\s+(.+)\s*$/m) { $out .= "To $1 "; } |
---|
| 74 | if ($owl::msg =~ /^Subject:\s+(.+)\s*$/m) { $out .= "Subject $1 "; } |
---|
| 75 | return($out."\n"); |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | my $channel = $owl::class; |
---|
| 79 | if (defined $class_abbrev{lc($owl::class)}) { |
---|
| 80 | $channel = $class_abbrev{lc($owl::class)}; |
---|
| 81 | } |
---|
| 82 | if (lc($owl::class) ne "message" and lc($owl::instance) eq "personal") { |
---|
| 83 | $owl::instance = ""; |
---|
| 84 | } |
---|
| 85 | $channel .= "[".$owl::instance."]"; |
---|
| 86 | $channel = substr($channel,0,13); |
---|
| 87 | |
---|
| 88 | $header = sprintf "%-8s %-13s ", lc($owl::sender), lc($channel); |
---|
| 89 | |
---|
| 90 | if ($owl::msg =~ /=/) { |
---|
| 91 | # indent it |
---|
| 92 | $tmp=$owl::msg; |
---|
| 93 | $tmp=~s/^/ /g; |
---|
| 94 | $tmp=~s/\n/\n /g; |
---|
| 95 | $out.=$header."\n".$tmp; |
---|
| 96 | } else { |
---|
| 97 | # fill it |
---|
| 98 | my $pagewidth = 74; |
---|
| 99 | $out .= $header; |
---|
| 100 | $out .= fill_text($owl::msg, $pagewidth, 22, 1); |
---|
| 101 | } |
---|
| 102 | |
---|
| 103 | # note: no zsig added in this version |
---|
| 104 | |
---|
| 105 | # make personal messages bold |
---|
| 106 | if (uc($owl::class) eq "MESSAGE" && |
---|
| 107 | uc($owl::instance) eq "PERSONAL") { |
---|
| 108 | $out="\@bold{".$out."}\n"; |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | return($out); |
---|
| 112 | } |
---|
| 113 | |
---|
| 114 | |
---|
| 115 | |
---|
| 116 | sub fill_text { |
---|
| 117 | my ($in, $width, $indent, $unindent_first) = @_; |
---|
| 118 | $indent = 0 if (@_ < 3); |
---|
| 119 | my $unindent = $indent if ($unindent_first); |
---|
| 120 | my @words = split " ", $in; |
---|
| 121 | my $out = ""; |
---|
| 122 | my $outline = ""; |
---|
| 123 | if (!$unindent_first) { |
---|
| 124 | my $outline = " "x$indent; |
---|
| 125 | } |
---|
| 126 | for my $w (@words) { |
---|
| 127 | if (($outline ne "") |
---|
| 128 | && (length($outline)+length($w) > $width-$unindent)) { |
---|
| 129 | $out .= $outline."\n"; |
---|
| 130 | $outline = " "x$indent; |
---|
| 131 | $unindent = 0; |
---|
| 132 | } |
---|
| 133 | if ($outline =~ /.*\.$/) { |
---|
| 134 | $outline .= " "; |
---|
| 135 | } elsif ($outline ne "") { |
---|
| 136 | $outline .= " "; |
---|
| 137 | } |
---|
| 138 | $outline .= $w; |
---|
| 139 | } |
---|
| 140 | $out .= $outline . "\n"; |
---|
| 141 | } |
---|