|
Joined: Mar 2005
Posts: 18
Pikka bird
|
OP
Pikka bird
Joined: Mar 2005
Posts: 18 |
hi, i have in my remotes this
on *:text:!members*:?:{ if ( $2 == add ) { write members.txt $3- } if ( $2 == remove ) { write -ds $+ $3 members.txt } }
the variable $3 is the member name.
How can i change this so when a member is added it does not write to the file if that person is already in the list. Also, when a member is removed, if that member is not found in the list it returns a message saying the member was not found.
|
|
|
|
Joined: Dec 2002
Posts: 1,245
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,245 |
you might read This Thread and see if you can't find the answers there
|
|
|
|
Joined: Mar 2005
Posts: 18
Pikka bird
|
OP
Pikka bird
Joined: Mar 2005
Posts: 18 |
I read that topic already, but I don't understand it because I'm not using ini file.
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
on *:text:!members*:?:{
if ( $2 == add ) { write members.txt $3- }
if ( $2 == remove ) {
if $read(members.txt,w,$) { write -ds $+ $3 members.txt }
else .msg $nick Sorry $3 not found
}
}
|
|
|
|
Joined: Dec 2002
Posts: 1,245
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,245 |
//echo $read(info.txt, s, mirc)
Scans the file info.txt for a line beginning with the word mirc and returns [b]the text following the match value.[/b]
alias testread1 {
if ( $1 == add ) {
if ($read(members.txti,s,$2) == $null) { write members.txt $2- }
}
run notepad members.txt
}
use /testread1 add nick whatever
--------------------------------------------------------
//echo $read(help.txt, w, *help*)
Scans the file help.txt for a line matching the wildcard text *help*.
alias testread2 {
if ( $1 == add ) {
if ($read(members.txt,w,$2 $+ *) == $null) { write members.txt $2- }
}
run notepad members.txt
}
use /testread2 add nick whatever
--------------------------------------------------------
/help $read
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
on *:text:!members*:?:{
if ( $2 == add ) { write -w $+ $3 members.txt $3- }
if ( $2 == remove ) {
if $read(members.txt,w,$3) { write -ds $+ $3 members.txt }
else .msg $nick Sorry $3 not found
}
}
Aplogoies on this post. I forgot part of the code in the first post I made and it was too late for me to edit it.
|
|
|
|
Joined: Dec 2002
Posts: 1,245
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,245 |
I tested your post
on *:text:!members*:?:{
if ( $2 == add ) { write -w $+ $3 members.txt $3- }
if ( $2 == remove ) {
if $read(members.txt,w,$3) { write -ds $+ $3 members.txt }
else .msg $nick Sorry $3 not found
}
}
it adds the $3- even if it is in the file already this line if $read(members.txt,w,$3) { write -ds $+ $3 members.txt } didn't work til I added the wildcard if $read(members.txt,w,$3 $+ *) { write -ds $+ $3 members.txt } my test
alias testread {
if ( $2 == add ) { write -w $+ $3 members.txt $3- }
if ( $2 == remove ) {
if $read(members.txt,w,$3[color:red] $+ *[/color]) { write -ds $+ $3 members.txt }
else .msg $nick Sorry $3 not found
}
run notepad members.txt
}
|
|
|
|
Joined: Mar 2005
Posts: 18
Pikka bird
|
OP
Pikka bird
Joined: Mar 2005
Posts: 18 |
There's a problem with the test code
If the member has more than one words in the name (eg !members add john doe), it can still be added over and over. But if its only 1 word then it only writes it once.
It also doesn't msg'd the person saying 'member already in list' if the line exists already.
Can those be fixed?
Last edited by adazh; 22/07/05 07:50 AM.
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
alias testread {
if ($1 == add) {
if ($read(members.txt,w,$2-) != $null) {
echo -a test
.msg $nick $2- is already on the list.
}
else {
echo -a test2
write members.txt $2-
}
}
elseif ($1 == remove) {
if $read(members.txt,w,$2-) {
write -ds $+ $2- members.txt
}
else {
.msg $nick Sorry $2- not found
}
}
else {
.msg $nick Invalid command.
}
}
on *:text:!test *:#chan: {
if ($2 && $3) {
testread $2-
}
else {
.msg $nick Please provide all information.
}
}
Try that. Yes, this is more spread out than the others, but I just prefer easily seeing the structure of it rather than putting everything on as few lines as absolutely possible. Note that this will only work if you are not including any other information following the nicks in that file. If you are, then you'll need to separate the items with something like a comma and then use $gettok within the $read statements. Btw, MikeChat... your alias has the wrong $N's since it's an alias. I think you copy/pasted your on text.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Dec 2002
Posts: 1,245
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,245 |
heh well no I just was being lazy
I should have posted the useage info /testread please add nick *!*@*.test.com
|
|
|
|
Joined: Mar 2005
Posts: 18
Pikka bird
|
OP
Pikka bird
Joined: Mar 2005
Posts: 18 |
Works good enough for what I needed, thanks.
|
|
|
|
|