so.. we got the join, sign and part procedures changed without a problem, but the nick change we're struggling.
Essentially.. if a person is using their USERNAME nick or their IRCNAME nick (thats the field names in the SQL database) , and changes their nick to something other than USERNAME, or IRCNAME, it says they are offline.
If they change their nick to USERNAME, it marks them online. If they change their nick to their IRCNAME, it marks them online.
Below is the procedure for the nick change. I know the binding works, because before we implemented the alternate nick with IRCNAME, it worked fine.
Right now,
If I change my nick in irc, i get this error: (regardless what my current nick is or going to be). I can't figure out what is creating this error!
Tcl error [nick_main]: wrong # args: should be "set varName ?newValue?"
Code: Select all
proc nick_main {nick uhost handle channel newnick} {
global db_handle botnick
if {$nick==$botnick} {return 0}
# first section is the check if your existing nick (before change) now matches username or IRC name, or no longer matches irc name or user name.
set sql "UPDATE CC_users SET onirc = 'no' WHERE username = '$nick'" // check if existing nick (before change) matches username then make it NO!
putlog "Step 1: $sql"
putloglev d * "ircstats: executing $sql"
putlog "Step 2: $result"
set result [mysqlexec $db_handle $sql]
if {$result != 1} { // existing nick doesn't exist in the database so this triggers If statement...
set sql2 "UPDATE CC_users SET onirc = 'no' WHERE ircname = '$nick'" // check if existing nick (before change) matches ircname then make it No!
putlog "SQL2: $sql2"
putloglev d * "ircstats: executing $sql2"
set result2 [mysqlexec $db_handle $sql2]
putlog "result2: $result2"
if {$result2 != 1} { // existing nick doesn't match ircname either... So.. lets check if the newnick matches username
set sql3 "UPDATE CC_users SET onirc = 'yes' WHERE username = '$newnick'" //check newnick if it matches username
putlog "SQL3: $sql3"
putloglev d * "ircstats: executing $sql3"
set result3 [mysqlexec $db_handle $sql3]
putlog "result3: $result3"
if {$result3 != 1} { // new nick doesn't match username, so.. lets check if the newnick matches ircname
set sql4 "UPDATE CC_users SET onirc = 'yes' WHERE ircname = '$newnick'" //check if newnick matches ircname
putlog "SQL4: $sql4"
putloglev d * "ircstats: executing $sql4"
set result4 [mysqlexec $db_handle $sql4]
putlog "result4: $result4"
if {$result4 != 1} { // new nick doesn't match ircname either
putlog "SQL - Error" // sucks to be you.. no idle bonus for you!
} else { // but WAIT newnick matched ircname!! give him his bonus!
set id [mysqlinsertid $db_handle]
puthelp "PRIVMSG $channel :User Online: \002$newnick\002 - IRC bonus enabled."
pushmode $channel +v $newnick
}
} else { // // but WAIT newnick matched username!! give him his bonus!
set id [mysqlinsertid $db_handle]
puthelp "PRIVMSG $channel :User Online: \002$newnick\002 - IRC bonus enabled."
pushmode $channel +v $newnick
}
} else { // // but WAIT original nick matched ircname!! so disable his bonus since he just changed from it
set id [mysqlinsertid $db_handle]
puthelp "PRIVMSG $channel :User Offline: \002$nick\002 - IRC bonus disabled."
pushmode $channel -v $newnick
}
} else { // // but WAIT original nick matched username!! Does New Nick Match ircname?
set sqlirc "UPDATE CC_users SET onirc = 'yes' WHERE ircname = '$newnick'"
putlog "SQLirc: $sqlirc"
putloglev d * "ircstats: executing $sqlirc"
set resultirc [mysqlexec $db_handle $sqlirc]
putlog "resultirc: $resultirc"
if {$resultirc != 1} {
set id [mysqlinsertid $db_handle]
puthelp "PRIVMSG $channel :User Offline: \002$nick\002 - IRC bonus disabled."
pushmode $channel -v $newnick
}
}
}