This script will record the previous nicknames a user has used when he or she makes a nickname change.
The self-trigger is:
/previous NickHere
The on text trigger is:
!previous NickHere
Please note that the script will not respond if a nickname hasn't changed his or her nickname.
raw 315:*: halt
on *:join:#: who #
on *:quit: psave $address($nick,2)
on *:part:#: psave $address($nick,2)
alias -l psave hadd -m pnick $1 $ial($1).mark
on *:exit: if ($hget(pnick)) hsave pnick pnick
alias previous {
if ($ial($1).mark) $iif($isid,return,echo -aegt) $1 was previously known as: $&
$replace($ial($1).mark,$chr(32),$+($chr(44),$chr(32))) | halt
}
on *:text:$($iif(!previous* iswm $strip($1),$1)):*:{
.msg $iif(#,#,$nick) $iif(!$strip($2),$nick $+ $chr(44) Syntax: $&
!previous <nick>,$previous($strip($2)))
}
on *:nick: .ialmark $newnick $addtok($ial($newnick).mark,$nick,32)
on *:start:{
if (!$hget(pnick)) && ($file(pnick).shortfn) hmake pnick 100 | hload pnick pnick
}
raw 352:*:{
if ($hfind(pnick,$+(*!*@,$4),1,n)) .ialmark $ial($v1).nick $hget(pnick,$v1) | halt
}
Doesn't the use of "ialmark" here conflict with your realname script ?
I use ialmark a lot in my personal scripts and I've found it much easier to manage storing items in their own field using a delimiter. ie. realname=fred | access=friend | nicknames=fred joe ted bill | etc.
Here is a basic alias that checks for an item= and edits or creates it using =value. This uses ascii 01 as a delimiter, but this is just an example.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;Usage /ialmark_ nickname item value(s) go here.
;Or $ialmark_(nickname, item) <--Will return the value of item if it exists.
alias ialmark_ {
var %item $2
if ($isid) {
if ($regex($ial($1).mark,/ $+ %item $+ =([^\x01]*)/i)) return $regml(1)
}
else {
var %value $3-
if (!$regex($ial($1).mark,/ $+ %item $+ =[^\x01]*/i)) {
.ialmark $1 $addtok($ial($1).mark,$+(%item,=,%value),1)
}
else {
.ialmark $1 $regsubex($ial($1).mark,/( $+ %item $+ =[^\x01]*)/i,$+(%item,=,%value))
}
}
}
I find it much easier to manage this way. I'm sure there are many other ways to manage ialmark so it can be used by multiple scripts.
-you don't need to halt in the previous alias, why are you halting there?Without the halt command, it will generate an error if someone checks a fictional nickname. The halt actually helps it.> -on :join:#: who # < if a netsplit occurs, everyone using your code will be disconnected if used on some big channels, you should /who when $nick == $me only, and otherwise store the information:P I was actually using on me::join:#:{ but changed it to the regular join event, because the $ial().mark becomes empty when a user hops. Perhaps I have thought wrong in the process of making the script.
Thanks for your suggestion. I'll surely take it under consideration and make the snippet better later.
Some way to improve this:
-you should use $wildsite inside events instead of $address($nick,2)
-you shouldn't halt the raws everytime, i don't want your script to disable any message.
-$hfind is slow, here $hfind(pnick,$+(!@,$4),1,n) is simply $hget(pnick,$+(!@,$4)) but i would remove that condition and add to the table every information from the /who, because actually it's not really storing every possible information (you are not using on text either to store information about the nick talking), i think you should
-the on start event has a problem, it /hload everytime, whatever if the table exists and whatever if the file exists
-you don't need to halt in the previous alias, why are you halting there?
-on *:join:#: who # < if a netsplit occurs, everyone using your code will be disconnected if used on some big channels, you should /who when $nick == $me only, and otherwise store the information