mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Apr 2015
Posts: 4
K
Self-satisified door
OP Offline
Self-satisified door
K
Joined: Apr 2015
Posts: 4
Hey everyone, really sorry as this is probably really simple, however I have just started out working with mIRC and I can't figure out why this script won't work.

I'm working on a script for a Twitch Chat Bot.
Code:
[script]
on $*:TEXT:!mcuser *:#: {
  echo -a keyword detected
  var %user = $2
  echo -a %user
  var %line = $lines(whitelist.txt)
  echo -a %line
  inc %line
  echo -a %line
  write -il%line whitelist.txt %user
  echo -a Added %user to userlist.}


When a user types !mcuser <USERNAME>, the code should read the username inserted (3rd party username, not IRC) and insert it into a new line in whitelist.txt, the problem I'm having is that it isn't returning anything. This is regardless of whether I type !mcuser asdasdasd or just !mcuser on its own.

Last edited by Konomira; 21/04/15 05:54 PM.
Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
Try this:
Code:
on *:TEXT:!mcuser &:#: {
  echo -a keyword detected
  var %user = $2
  echo -a %user
  write whitelist.txt %user
  echo -a Added %user to userlist.
}
There's no need to check for lines and increment that value. /write will write it to the next line by default.


Nillens @ irc.twitch.tv
Nillen @ irc.rizon.net
Joined: Apr 2015
Posts: 4
K
Self-satisified door
OP Offline
Self-satisified door
K
Joined: Apr 2015
Posts: 4
Thanks, it's good to know I can remove a few lines from the code. After further inspection it seems that the code was functional, but when it was being loaded, it was blank. Any idea why this happened?

Joined: Dec 2013
Posts: 779
N
Hoopy frood
Offline
Hoopy frood
N
Joined: Dec 2013
Posts: 779
You had it originally set to set %user to $1 when $1 will always be equal to !mcuser.

Even if you keep it to trigger on '!mcuser *' you can leave $2 $null and it will attempt to write blank to the textfile, that's why I changed it to '!mcuser &' which requires $2 to be filled. You can get the same result by checking if ($2 != $null) { } but that's a bit redundant.

Inspecting your text further, I realize now that your script never even triggered. I believe this is because mIRC is triggering something else prior to this script. Check your remote.ini file for a
Code:
on *:text:*:#:
event which will trigger to any text.

If mIRC triggers on one event it will not trigger on anything that is beneath it in the same file. You can avoid this by either moving the scripts that are below this event or by putting them in a different remote.ini file. You can accomplish this by pressing File > New and paste it there.


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

Link Copied to Clipboard