xecho -b Noteserv script loaded! xecho -b Written by gircobain 05/11/2001 xecho -b Type /noteserv on to activate Noteserv @notesfile = [~/notes] @NOTESERV_ON = 0 @notify_timer = 900 @save_timer = 120 alias read_notes { @delarray(notes) @delarray(hotlist) @:fd = open($notesfile r) while (!eof($fd)) { @:note = read($fd) if (!eof($fd)) { @setitem(notes $numitems(notes) $note) if (matchitem(hotlist $word(0 $note)) < 0) @setitem(hotlist $numitems(hotlist) $word(0 $note) 0) hotlist $word(0 $note) } } @close($fd) } alias save_notes { @unlink($notesfile) @:fd = open($notesfile w) for (@:count = 0,count < numitems(notes),@count++) { @write($fd $getitem(notes $count)) } @close($fd) } on ^msg "% note % *" if ([$0] != [$N] && NOTESERV_ON) { if ([$2] != [$N]) { @setitem(notes $numitems(notes) $2 $findpos($2) $0 $time() $encode($3-)) if (matchitem(hotlist $2 *) < 0) { @setitem(hotlist $numitems(hotlist) $2 0) hotlist $2 }{ if (getitem(hotlist $matchitem(hotlist $2 *)) == [$2 1]) { ^raw 205 $2 You have $findnotes($2) note(s) waiting for you ^raw 205 $2 /msg $N read } } ^raw 205 $0 Note to $2 has succesfully been sent. }{ ^raw 205 $0 Please do not send me notes. } } on ^hotlist "% % on" if (NOTESERV_ON) { @setitem(hotlist $matchitem(hotlist $0 *) $0 1) ^raw 205 $0 You have $findnotes($0) note(s) waiting for you ^raw 205 $0 /msg $N read timer -ref $word(1 $getitem(notes $matchitem(notes $0 *))) -rep -1 $notify_timer { ^raw 205 $0 You have $findnotes($0) note(s) waiting for you ^raw 205 $0 /msg $N read } } on ^hotlist "% off" if (NOTESERV_ON) { @setitem(hotlist $matchitem(hotlist $0 *) $0 0) timer -del $word(1 $getitem(notes $matchitem(notes $0 *))) } on ^msg "% read" if ([$0] != [$N] && NOTESERV_ON) { @:flag = 0 for (@:count = 0,count < numitems(notes),@count++) { @:note = getitem(notes $count) if (word(0 $note) == [$0]) { @flag = 1 ^raw 205 $0 From : $word(2 $note) ^raw 205 $0 Date : $strftime($word(3 $note) %x %X) ^raw 205 $0 Message: $decode($restw(4 $note)) } } if (!flag) ^raw 205 $0 You currently have no messages. } on ^msg "% erase" if ([$0] != [$N] && NOTESERV_ON) { @:count = 0 @:pos = 0 if (matchitem(notes $0 *) > -1) timer -del $word(1 $getitem(notes $matchitem(notes $0 *))) while ((pos = matchitem(notes $0 *)) > -1) { @count++ @delitem(notes $pos) } if (count) { ^raw 205 $0 You have deleted $count message(s). hotlist -$0 @delitem(hotlist $matchitem(hotlist $0 *)) }{ ^raw 205 $0 You currently have no messages. } } on ^msg "% help note" if ([$0] != [$N] && NOTESERV_ON) { ^raw 205 $0 Available Noteserv commands: ^raw 205 $0 note - sends message to user ^raw 205 $0 read - reads all messages ^raw 205 $0 erase - erases all messages ^raw 205 $0 Noteserv script by gircobain } alias findpos (nick) { @:count = 0 if (matchitem(notes $nick *) > -1) { return $word(1 $getitem(notes $matchitem(notes $nick *))) }{ while (matchitem(notes % $count *) > -1) @count++ return $count } } alias findnotes (nick,void) { @:notes = 0 for (@:count = 0,count < numitems(notes),@count++) { if (word(0 $getitem(notes $count)) == nick) @notes++ } return $notes } alias noteserv (toggle) { switch ($toggle) { (on) { if (!NOTESERV_ON) { @NOTESERV_ON = 1 xecho -b Noteserv is now on read_notes timer -ref SAVENOTES -rep -1 $save_timer { save_notes } }{ xecho -b Noteserv is already on } } (off) { if (NOTESERV_ON) { @NOTESERV_ON = 0 xecho -b Noteserv is now off for (@:count = 0,count < numitems(notes),@count++) { hotlist -$word(0 $getitem(notes $count)) timer -del $word(1 $getitem(notes $count)) @delarray(notes) @delarray(hotlist) } save_notes timer -del SAVENOTES }{ xecho -b Noteserv is already off } } (*) { xecho -b Noteserv is currently ${NOTESERV_ON ? [on] : [off]} xecho -b Usage: /noteserv [on | off] } } }