Hoopy frood
Joined: Oct 2005
Posts: 1,671 |
I was bored, so I made the full script.. and yes, I would still consider this simple..: For the bot:
alias log.chans return #chan1,#chan2,#chan3
;
on *:CONNECT:{
unset %last.*
var %chan, %c = 0, %cc = $numtok($log.chans,44)
while (%c < %cc) {
inc %c
%chan = $gettok($log.chans,%c,44)
if ($exists($+(backlog.,%chan,.txt))) .remove $+(backlog.,%chan,.txt)
join %chan
}
}
on *:TEXT:!backlog:$($log.chans):{
var %bfile = $+(backlog.,$chan,.txt)
if (!$exists(%bfile)) {
msg $nick No log exists for $chan
return
}
if ($($+(%,last.,$nick,.,$chan),2)) {
msg $nick You must wait before requesting another log for $chan
return
}
if (!$window(@backlog)) window -n @backlog
aline -hpi @backlog $+ $color(other) $timestamp Backlog request by $nick in $chan
.msg $nick @ $chan 14 $ctime ### Backlog ###
.play $nick %bfile 100
set -u300 $+(%,last.,$nick,.,$chan) 1
}
;
on *:ACTION:*:$($log.chans):log.write $chan 1 * $nick $1-
on *:JOIN:$($log.chans):log.write $chan 7 * $nick has joined $chan
on *:KICK:$($log.chans):log.write $chan 8 * $knick was kicked by $nick ( $+ $1- $+ )
on *:MODE:$($log.chans):log.write $chan 9 * $nick set mode: $1-
on *:NICK:log.mwrite $newnick 10 * $nick is now known as $newnick
on *:NOTICE:*:$($log.chans):log.write $chan 12 $+(-,$nick,:,$chan,-) $1-
on *:PART:$($log.chans):log.write $chan 16 * $nick has left $chan $iif($1,$chr(40) $+ $1- $+ $chr(41))
on *:QUIT:log.mwrite $nick 17 * $nick has quit IRC ( $+ $1- $+ )
on *:TEXT:*:$($log.chans):log.write $chan 11 < $+ $nick $+ > $1-
on *:TOPIC:$($log.chans):log.write $chan 18 * $nick changes topic to ' $+ $1- $+ '
;
alias log.color return $+ $color($1)
alias log.mwrite {
; 1 = nick, 2- = msg
var %c = 0, %cc = $comchan($1,0)
while (%c < %cc) {
inc %c
log.write $comchan($1,%c) $2-
}
}
alias log.write {
; 1 = chan, 2 = color, 3- = msg
var %bfile = $+(backlog.,$1,.txt)
var %tfile = $+(temp.,$1,.txt)
write %bfile @ $1 $2 $ctime $3-
if ($lines(%bfile) > 25) write -dl1 %bfile
inc $+(%,logbug.,$1)
if (%logbug. [ $+ [ $1 ] ] > 10000) {
copy -o %bfile %tfile
remove %bfile
copy -o %tfile %bfile
unset $+(%,logbug.,$1)
}
}
When the bot connects to the IRC server, it removes all existing log files and then joins the given channels. The events record everything that happens in the channel (except text/actions done by the bot) to individual logfiles for each channel. I don't know much about that /write -d bug, so I tried to prevent it in the /log.write alias. When a user types !backlog in a channel, the bot will /play the logfile for that channel to the user. Each line in the logfiles is formatted like this: @ <#chan> <color> <ctime> <message here> (<color> is a number that matches to a token in the user script) For the user:
on ^*:TEXT:@ *:?:{
if ($nick != [color:red]BOTNICK[/color]) return
var %colors = act,ctcp,high,info,info2,inv,join,kick, $&
mode,nick,nor,notice,notify,oth,own,part,quit,top,wall,whois
echo $color($gettok(%colors,$3,44)) $2 $asctime($4,$timestampfmt) $5-
window -c $nick
halt
}
The user script receives the messages from the bot and echos it to the appropriate channel window. The color finds a token in the list and retrieves the appropriate color using $color. The timestamp is shown using the users current $timestampfmt. The bot's nick must be specified in place of the red text. The default text is halted and the bot's PM window is closed. The messages would look a bit strange if the user doesn't have the script installed. Although, if you think about it, the same would be true if you were reading raw server messages instead of letting the IRC client software interpret them. The message is still quite easily readable, just like a raw PRIVMSG. -genius_at_work
|