\\ ADD - Adds (or updates) a friend. SHOW - Displays a friend.
// DEL - Deletes a friend.
\\
// Where <friend> must be one of the following:
\\
// [NICK] - This can only be used if [NICK] is on irc at the time!
\\ - If this is used, DWaRFx will try and automatically use
// - wildcards when it thinks it's nessecary. If this doesn't seem
\\ - to work, or it greets the wrong person, try the next option!
//
\\ [NICK!NAME@HOSTNAME] - The whole address of the friend to add. You
// - can use '*' wildcards, and this is exactly
\\ - how DWaRFx will store it, so please make
// - sure you understand how these work! If in doubt,
\\ - Use the [NICK] option :).
//
\\ Where [settings] can be none, one or more of the following:
//
\\ RATING <00-99> - Sets the status level of the friend (default is 00).
// OP - Sets Auto Op for this friend.
\\ MESSAGE <[X][Y]> <[message]> - Greeting for this friend.
// IF MESSAGE IS USED, MESSAGE MUST ALWAYS BE THE LAST [settings] OPTION!
\\ [X] must be either C or P, for Channel or Private greeting.
// [Y] must be either M, A or N, for Message, Action or Notice greeting.
\\ The following '/'s commands are used by DWaRFx to make your messages
// better, as they allow you to make 'clever' messages (See Docs for
\\ More Info).
// Here is a quick list of the '/' options:
\\
// If you require a / in the output text, you must use //
\\ /p will be replaced with the nick of the person who CTCP'd you
// /n will be replaced with your current irc nickname
\\ /s (<soundname>) will do a ctcp sound at their end
// /b /i /u turns Bold, Inverse and Underlined text On and Off
\\ /t will be replaced with the current date and local time
// /v will be replaced with the DWaRFx version string
\\ /w will be replaced with the DWaRFx Web Page address
// /l will be replaced with the DWaRFx logo
\\ /c will be replaced by the current channel name
// /e will end the current line and start a new one
\\ /d will be replaced with the DWaRFx Idle time string
//
\\ So the command line 'ADD COolWAve RATING 50 OP MESSAGE CN Hello Dave!'
// Will add the current host using the nickname 'COolWAve' with a
\\ RATING of 50, Auto Op on, and set the greeting to 'Hello Dave!'.
*/
/* Compressed with CompressRexx v2.1, (C) 1993-96 Robert Hofmann */
If Upper(Left(Address(),6))~="AMIRC." Then Address "AMIRC.1";Options Results;Parse Arg opt friend sets;dfxlogo=d2c(27)'x«DFxFriends»';quote="'";message="";rating='00';op="";Parse Source . . drawer .;tmp=Pos('/',drawer);If tmp=0 Then tmp=Pos(':',drawer);Else tmp=Lastpos('/',drawer);drawer=Left(drawer,tmp);Do While sets~="";Parse Value sets With tmp sets;tmp=Upper(tmp);Select;When tmp="RATING" Then Do;Parse Value sets With rating sets;End;When tmp="OP" Then op="O";When tmp="MESSAGE" THEN Do;op=op||"M";message=Strip(sets);sets="";mtmp=Upper(Left(Word(message,1),1));If mtmp~='P' & mtmp~='C' Then message="PN "message;End;Otherwise Call ERR(1);End;sets=Strip(sets);End;opt=Upper(opt);Select;When opt="ADD" Then Call ADD_FRIEND;When opt="DEL" Then Call DEL_FRIEND;When opt="SHOW" Then Call SHOW_FRIEND;Otherwise Call ERR(5);End;Exit;DEL_FRIEND:;Call GET_HOST();Call MATCH_HOST();If hostnum>1 Then Do;'Echo P='dfxlogo' 'd2c(2)'DEL:'d2c(2)' More than one host matched with 'd2c(2)||host||d2c(2)'!'
'Echo P='dfxlogo' 'd2c(2)'DEL:'d2c(2)' You must be more specific for the correct friend to be deleted!';End;Else Do;If hostnum=0 Then 'Echo P='dfxlogo' 'd2c(2)'DEL:'d2c(2)' No friend match with the host 'd2c(2)||host||d2c(2)'!';Else Do;'Echo P='dfxlogo' 'd2c(2)'DEL:'d2c(2)' Deleting old friend 'd2c(2)||Word(hosts.1,1)||d2c(2)'!';Call ALTER_CONF(1);'GetMyNick';'RAW PRIVMSG 'result' :%RELOAD QUIET';End;End;Return;ADD_FRIEND:;Call GET_HOST();Call MATCH_HOST();If hostnum>1 Then Do;'Echo P='dfxlogo' 'd2c(2)'ADD:'d2c(2)' More than one host matched with 'd2c(2)||host||d2c(2)'!';'Echo P='dfxlogo' 'd2c(2)'ADD:'d2c(2)' You must be more specific for the correct friend to be added or updated!';End;Else Do;If hostnum=0 Then Do;'Echo P='dfxlogo' 'd2c(2)'ADD:'d2c(2)' Adding new friend 'd2c(2)||host||d2c(2)'!';Call ALTER_CONF(3);'GetMyNick';'RAW PRIVMSG 'result' :%RELOAD QUIET';End;Else Do;'Echo P='dfxlogo' 'd2c(2)'ADD:'d2c(2)' Updating old friend 'd2c(2)||Word(hosts.1,1)||d2c(2)'!'
Call ALTER_CONF(2);'GetMyNick';'RAW PRIVMSG 'result' :%RELOAD QUIET';End;End;Return;SHOW_FRIEND:;Call GET_HOST();Call MATCH_HOST();If hostnum>0 Then Do;If hostnum=1 Then tmp='friend';Else tmp='friends';'Echo P='dfxlogo' 'd2c(2)'SHOW:'d2c(2)' 'hostnum' 'tmp' matched with the host 'd2c(2)||host||d2c(2)'.';End;Else 'Echo P='dfxlogo' 'd2c(2)'SHOW:'d2c(2)' No friend matched with the host 'd2c(2)||host||d2c(2)'!';Return;ERR:;Parse Arg errno;dfxerr='P='dfxlogo' 'd2c(2)'ERROR:'d2c(2);Select;When errno=1 Then 'Echo 'dfxerr' incorrect settings!';When errno=2 Then 'Echo 'dfxerr' no friend specified!';When errno=3 Then 'Echo 'dfxerr' 'friend' isn'quote't currently on IRC!';When errno=4 Then 'Echo 'dfxerr' DWaRFx config file (DWaRFCoNFiG.DaT) not found!';When errno=5 Then 'Echo 'dfxerr' no command found, you must use ADD or SHOW or DEL!';Otherwise;End;Exit;Return;GET_HOST:;If friend="" Then Call ERR(2);If Pos('@',friend)=0 Then Do;'RAW WHOIS 'friend;host="";Do while host="";GetLine;If line="" Then
Leave
If line.command="311" Then Do;If Upper(Word(line.rest,1))=Upper(friend) Then host=Word(line.rest,1)'!'Word(line.rest,2)'@'Word(line.rest,3);End;If line.command="318" Then Leave;End;If host="" Then Call ERR(3);Parse Value host With junk'!'name'@'ip;If Datatype(Compress(ip,'.'))='NUM' Then host='*!'name'@'ip;Else host='*!'name'@'Space(Translate(ip,' ','1234567890'),1,'*');End;Else host=friend;Return;MATCH_HOST:;If ~Open('file1',drawer||'DWaRFCoNFiG.DaT') Then Call ERR(4);scan=0;done="";hosts.1="";hostnum=0;Do While ~Eof('file1') & scan~=2;ln=Readln('file1');If scan=0 Then Do;If Upper(Word(ln,1))="!FRIENDS:" Then scan=1;End;Else Do;If Left(Word(ln,1),1)="!" Then scan=2;tmp=Upper(Word(ln,1))'.';nhost=Upper(host)'.';If ln~="" Then Do;tmp1=Translate(nhost,' ','*');tmp2=1;Do loop1=1 To Words(tmp1);tmp2=Pos(Word(tmp1,loop1),tmp,tmp2);If tmp2=0 Then Leave;End;If tmp2=0 Then Do;tmp1=Translate(tmp,' ','*');tmp2=1;Do loop1=1 To Words(tmp1);tmp2=Pos(Word(tmp1,loop1),nhost,tmp2);If tmp2=0
Then Leave;End;End
If tmp2~=0 Then Do;tmp=Upper(Word(ln,3));If Left(tmp,1)="O" Then tmp1=" "d2c(2)"OP"d2c(2);Else tmp1="";If Right(tmp,1)="M" Then tmp2=" "d2c(2)"MESSAGE:"d2c(2)" ("d2c(2)||Upper(Word(ln,4))||d2c(2)") "Subword(ln,5);Else tmp2="";'Echo P='dfxlogo' 'd2c(2)||opt':'d2c(2)' 'Word(ln,1)' 'd2c(2)'RATING:'d2c(2)' 'Word(ln,2)||tmp1||tmp2;hostnum=hostnum+1;hosts.hostnum=ln;End;End;End;End;Call Close('file1');Return;ALTER_CONF:;Parse Arg altnum;tmph=Upper(Word(hosts.1,1));If ~Open('file1',drawer||'DWaRFCoNFiG.DaT') Then Call ERR(4);lines=1;line.1="";fr=0;Do While ~Eof('file1');line.lines=Readln('file1');If Upper(Word(line.lines,1))="!FRIENDS:" Then fr=1;If fr=1 Then Do;Select;When altnum=1 Then Call DEL_LINE();When altnum=2 Then Call CHG_LINE();When altnum=3 Then Call ADD_LINE();End;End;lines=lines+1;End;Call Close('file1');If ~Open('file1',drawer||'DWaRFCoNFiG.DaT','W') Then Call ERR(4);loop=1;lines=lines-1;Do While loop<lines;Call Writeln('file1',line.loop);loop=loop+1;End;Call Close('file1');Ret
urn;ADD_LINE:
lines=lines+1;line.lines=host' 'rating' 'op' 'message;fr=0;Return;DEL_LINE:;If Upper(Word(line.lines,1))=tmph Then Do;lines=lines-1;fr=0;End;Return;CHG_LINE:;If Upper(Word(line.lines,1))=tmph Then Do;line.lines=host' 'rating' 'op' 'message;fr=0;End;Return