0

I'm trying to write a command for an IRC chat bot to check viewers in each day. When someone types !chirp I want the bot to either: 1) add the users name and date they checked in, 2) add just the check in date if they're already on the list, or 3) do nothing if they've already checked in that day. The problem I'm running into is the second if-statement: seems to think it's true and proceeds when it shouldn't. The /echo lines are strictly for debugging.

Text file format is(one value per line):

username
username
date
date
username
date
username
etc.

Here's the code (written as a remote function):

on *:TEXT:!chirp:#: {
    ;INITIALIZE VARIABLES
    set %i 1
    set %lines $lines(chirp.txt)
    set %line NULL
    set %lineafter NULL
    set %date $adate
    set %temp NULL

while ( %i <= %lines ) {
    set %line $read(chirp.txt, n, %i)
    set %lineafter $calc($readn +1)
    set %temp $calc(%i + 1)

    ;/echo -a %i $char(32) %line $char(32) %lineafter $char(32) %temp
    ;/echo -a $read(chirp.txt, n, %temp)

    if ( %line == $nick ) {
        if( $read(chirp.txt, nw, *%temp*) === %date ) {
            msg $chan /w $nick You've already checked in today!
            /halt

        } else {
            /write -il $+ %lineafter chirp.txt $adate
            msg $chan /w $nick Welcome back! Thanks for checking in!
            /halt
        }
    }
/inc %i
}

/write chirp.txt $nick
/write chirp.txt $adate
}
;END OF CODE
Valentin Lorentz
  • 9,556
  • 6
  • 47
  • 69

1 Answers1

0

Like the previous question you asked this question also suffers with couple of the issues.

This is not acceptable in mSL

} else {

Use

}
else {

Missing a space after if

if ( $read(chirp.txt, nw, *%temp*) === %date ) {

Remarks:

  1. / prefix is useless in remote mode, it is used only in command to differentiate between text and a command on user input.
  2. If you want the variables you declare to be clean up after alias or remote is finished, use var %variable-name = value
Orel Eraki
  • 11,940
  • 3
  • 28
  • 36
  • Sorry for the late response, but thank you very much. I'm still very green when it comes to irc coding language. I didn't realize the white-space was so picky. – MrJerkBird Jan 01 '17 at 03:33