This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

registerednick.tcl

Support & discussion of released scripts, and announcements of new releases.
Post Reply
User avatar
aslpls
Halfop
Posts: 52
Joined: Mon May 02, 2016 9:41 am

registerednick.tcl

Post by aslpls »

Hello all, good day. i need help with a small issue from the script.

the issue is, when you do the commands;

PUBCMD: !checkisreg on|off
Tcl error [::RegVoice::public]: can't read "channel": no such variable


MSGCMD: /msg botnick checkisreg #channel on|off
Tcl error [::RegVoice::message]: wrong # args: should be "::RegVoice::message nick uhost hand chan text"


Code: Select all

# SYNTAX (on PartyLine/DCC/CTCP/TELnet): .chanset #channel -/+checkisauth
# ----------
# PUBCMD:
# !checkisreg on|off
# ----------
# MSGCMD:
# /msg botnick checkisreg #channel on|off

namespace eval RegVoice {
    variable verifieduser "*has identified for*"
    setudef flag checkisauth

    bind join - * [namespace current]::joinCheck
    bind raw - 307 [namespace current]::isReg
    bind pub o|o !checkisreg [namespace current]::public
    bind msg o|o checkisreg [namespace current]::message
     
    bind time - * [namespace current]::cleanUp

    proc cleanUp {minute hour day month year} {
       global checkAuth
       if {[info exists checkAuth]} {
          foreach nick $checkAuth {
             if {![onchan $nick]} {
                set pos [lsearch -nocase $nick $checkAuth]
                set checkAuth [lreplace $checkAuth $pos $pos]
             }
          }
       }
    }
     
    proc joinCheck {nick uhost hand chan} {
       global checkAuth
       if {[isbotnick $nick]} return
       if {![channel get $chan checkisauth] || [validuser $hand]} return
       if {[info exists checkAuth]} {
          if {[lsearch -nocase $nick $checkAuth] != -1} return
       }
       lappend checkAuth $nick
       puthelp "WHOIS $nick"
    }

    proc isReg {from keyword text} {
       global checkAuth
       variable verifieduser

       set nick [lindex [split $text] 1]
       if {[info exists checkAuth]} {
          set pos [lsearch -nocase $nick $checkAuth]
          if {$pos != -1} {
             set checkAuth [lreplace $checkAuth $pos $pos]
          }
       }
       if {![string match "*has identified for*" $text]} return
       if {[validuser [nick2hand $nick]]} return
       foreach chan [channels] {
				if {![channel get $chan checkisauth] || ![onchan $nick $chan] || [isop $nick $chan] || [isvoice $nick $chan]} continue
          if {![botisop $chan]} continue
          pushmode $chan +v $nick
       }
    }
     
    proc public {nick uhost hand chan text} {
       if {[scan $text {%s} mode] != 1} {
         puthelp "PRIVMSG $chan :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: !checkisreg on|off"
         return
       }
       doAction $mode $chan $chan
    }

    proc message {nick uhost hand chan text} {
       if {[scan $text {%s%s} mode channel] != 2} {
          puthelp "PRIVMSG $nick :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: checkisreg #channel on|off"
          return
       }
       if {[string first # $channel] != 0} {
          puthelp "PRIVMSG $nick :\037ERROR\037: Provided channel doesn't seem to correct. \037SYNTAX\037: checkisreg #channel on|off"
          return
       }
       doAction $mode $channel $nick
    }

    proc doAction {mode chan dest} {
       if {![validchan $channel] || ![botonchan $channel]} {
          puthelp "PRIVMSG $dest ::\037ERROR\037: Channel $chan doesn't exist in my database or I'm not on it."
          return
       }
       set status [channel get $chan checkisauth]
       switch -- [string tolower $mode] {
          "on" {
             if {$status} {
                puthelp "PRIVMSG $dest :\037ERROR\037: This setting is already enabled."
             } else {
                channel set $chan +checkisauth
                puthelp "PRIVMSG $dest :Enabled Automatic Register Checking for $chan"
             }
          }
          "off" {
             if {!$status} {
                puthelp "PRIVMSG $dest :\037ERROR\037: This setting is already disabled."
             } else {
                channel set $chan -checkisauth
                puthelp "PRIVMSG $dest :Disabled Automatic Register Checking for $chan"
             }
          }
          default {
             if {![string first # $dest]} {
                puthelp "PRIVMSG $dest :\037ERROR\037: $mode is not an accepted parameter. \037SYNTAX\037: !checkisreg on|off"
             } else {
                puthelp "PRIVMSG $dest :\037ERROR\037: $mode is not an accepted parameter. \037SYNTAX\037: checkisreg #channel on|off"
             }
          }
       }
    }
 }
 
 
putlog "registerednick.tcl Loaded"

It was FUNNY!
User avatar
CrazyCat
Revered One
Posts: 1308
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Re: registerednick.tcl

Post by CrazyCat »

For the first error, I think it's in doAction that there is a trouble:
proc doAction {mode chan dest} {
       if {![validchan $channel] || ![botonchan $channel]} {
          puthelp "PRIVMSG $dest ::\037ERROR\037: Channel $chan doesn't exist in my database or I'm not on it."
          return
       }
It get the arg "chan" but your condition uses the $channel variable.

For the second: the message proc is defined as if it was for a public one, the defintion to use is:
proc message {nick uhost hand text} {
User avatar
aslpls
Halfop
Posts: 52
Joined: Mon May 02, 2016 9:41 am

Re: registerednick.tcl

Post by aslpls »

Hello, Crazycat.. thank you for your reply. I understand what is your comments.. but my problem is i do not know on how to correct the code.. :D
It was FUNNY!
User avatar
aslpls
Halfop
Posts: 52
Joined: Mon May 02, 2016 9:41 am

Re: registerednick.tcl

Post by aslpls »

I've tried to change to channel to chan and it seem it is ok now for the first issue

Code: Select all

   proc public {nick uhost hand chan text} {
       if {[scan $text {%s} mode] != 1} {
         puthelp "PRIVMSG $chan :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: !checkisreg on|off"
         return
       }
       doAction $mode $chan $chan
    }

    proc message {nick uhost hand chan text} {
       if {[scan $text {%s%s} mode chan] != 2} {
          puthelp "PRIVMSG $nick :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: checkisreg #channel on|off"
          return
       }
       if {[string first # $chan] != 0} {
          puthelp "PRIVMSG $nick :\037ERROR\037: Provided channel doesn't seem to correct. \037SYNTAX\037: checkisreg #channel on|off"
          return
       }
       doAction $mode $chan $nick
    }

    proc doAction {mode chan dest} {
       if {![validchan $chan] || ![botonchan $chan]} {
          puthelp "PRIVMSG $dest ::\037ERROR\037: Channel $chan doesn't exist in my database or I'm not on it."
          return
       }
       set status [channel get $chan checkisauth]
       switch -- [string tolower $mode] {
          "on" {
             if {$status} {
                puthelp "PRIVMSG $dest :\037ERROR\037: This setting is already enabled."
             } else {
                channel set $chan +checkisauth
                puthelp "PRIVMSG $dest :Enabled Automatic Register Checking for $chan"
             }
          }



<@aslpls> !checkisreg on
<@Botname> ERROR: This setting is already enabled.

so tried again;


<@aslplss> !checkisreg off
<@Botname> Disabled Automatic Register Checking for #test


<@aslpls> !checkisreg on
<@Botname> Enabled Automatic Register Checking for #test
It was FUNNY!
User avatar
aslpls
Halfop
Posts: 52
Joined: Mon May 02, 2016 9:41 am

Re: registerednick.tcl

Post by aslpls »

Thank you Crazycat, i got it, it is now working good. thank you for your answer.
It was FUNNY!
Post Reply