mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Sep 2015
Posts: 26
Z
zigress Offline OP
Ameglian cow
OP Offline
Ameglian cow
Z
Joined: Sep 2015
Posts: 26
I have a list.txt file that records names of users that type !join in twitch chat.
Instead of going to the direct file to remove a specific name, I wanted to find a way to remove a user's name from the list through a command on twitch chat.
This is what I have so far. This only works if there's one person on the list.

on *:text:!remove *:#: {
if ($nick isop #) {
if (!$read(list.txt,nw,$2)) { msg $chan $2- is not in the list. | return }
else { msg $chan /me removed $2 from the list.
write -dl list.txt , $2
}
}
}

Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
That's not how -d works.
For -d to work, you need the -l as well.
For -l to work, you need to specify the number behind it.
-dl5 would remove line 5 from the textfile. To know which line you want to delete, you search for it using $read(list.txt,nw,$2) and use $readn. $readn will return the number of the line that the last $read match was found.

The correct way to use it afterwards is to /write -dl $+ $readn list.txt


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Sep 2015
Posts: 26
Z
zigress Offline OP
Ameglian cow
OP Offline
Ameglian cow
Z
Joined: Sep 2015
Posts: 26
Here's the updated code. This works, however I have one last question. If I want to include text before the user's name (i.e. A: user), how can I do that?

on *:text:!remove *:#: {
if ($nick isop #) {
if (!$read(list.txt,nw,$2)) { msg $chan $2 is not in the list. | return }
elseif ($read(list.txt,nw,$2)) { msg $chan $2 has been removed from the list.
write -dl $+ $readn list.txt }
}
}

Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
You simply /write it to the file.
I imagine you're using a on text event and writing $2 to the file. Just use $2- instead and write after $2 with it. This would be consistent throughout the file, using the NICK first and then the added text after. Consistency is key when it comes to scripts like that.

You might want to look into changing the delete feature for this though to make sure the first token "if ($gettok($read(file,nw,$2),1,32) == $2)" of the $read line is the match you're looking for.
This may or may not require you to use wildcard indicators though since your lines will have more than just $2 in it.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net

Link Copied to Clipboard