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.

tcl recognizes with temporary access for nicks

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

tcl recognizes with temporary access for nicks

Post by Arnold_X-P »

this tcl recognizes with temporary access to the one who gives him a password..

the error it gives in partyline

Code: Select all

[16:01:44] Tcl error [pRecogniseCommand]: invalid command name "addhost"
Some friend who can help me.

Code: Select all

# recognise.tcl  for arfer DALnet channel #atlantis
  
# ------------------------------------------------------------------------------------------------------------------- #
# -------------------- syntax --------------------------------------------------------------------------------------- #
 
# syntax assuming default command 'recognise'
# /msg <botnick> recognise <password>
 
# ------------------------------------------------------------------------------------------------------------------- #
# -------------------- configuration -------------------------------------------------------------------------------- #
 
# set here the \msg command to use
set vRecogniseCommand "access"
 
# set here the password, only a - z, A - Z, 0 - 9 (6 characters minimum)
set vRecognisePassword "PaSSord27"
 
# set here how long in minutes the bot should recognise you 180 min. = 3 hours
set vRecogniseTime 180
 
# ------------------------------------------------------------------------------------------------------------------- #
# -------------------- code ----------------------------------------------------------------------------------------- #
 
set vRecogniseVersion 1.0
 
bind MSG - $vRecogniseCommand pRecogniseCommand
 
proc pRecogniseCommand {nick uhost hand text} {
    global vRecognisePassword
    if {[regexp -nocase -- {^[a-z0-9]{6,}$} $vRecognisePassword]} {
        set arguments [regsub -all -- {\s{2,}} [stripcodes bcruag [string trim $text]] { }]
        if {[llength [split $arguments]] == 1} {
            if {[string equal $arguments $vRecognisePassword]} {
                if {[onchan $nick]} {
                    pRecognisePromote $nick $uhost
                } else {pRecogniseOutput 001 $nick $hand 0}
            } else {pRecogniseOutput 002 $nick $hand $arguments}
        } else {pRecogniseOutput 003 $nick $hand 0}
    } else {pRecogniseOutput 004 $nick $hand 0}
    return 0
}
 
proc pRecogniseOutput {number nick hand xtra1} {
    global vRecogniseCommand vRecogniseTime
    switch -- $number {
        001 {set output "-error- you must be on a bot channel to use this command"}
        002 {set output "-error- password $xtra1 not recognised"}
        003 {set output "-error- correct usage /msg <botnick> $vRecogniseCommand <password>"}
        004 {set output "-error- incorrectly configured password in script"}
        005 {set output "a new userfile record has been temporarily created giving you +n (global owner status). it will be deleted $vRecogniseTime minutes from now"}
        006 {set output "the flag +n (global owner status) has been temporarily granted in your userfile record. it will be rescinded $vRecogniseTime minutes from now"}
        007 {set output "you are already recognised by the handle $hand as having +n (global owner status)"}
        008 {set output "a temporary host $xtra1 has been added to your userfile record giving you +n (global owner status). it will be removed $vRecogniseTime minutes from now"}
        default {}
    }
    putserv "NOTICE $nick :$output"
    return 0
}
 
proc pRecognisePromote {nick uhost} {
    global vRecogniseTime
    scan $uhost {%[^@]@%s} user host
    set user [string trimleft $user ~]
    set mask *!*$user@[pRecogniseMaskhost $host]
    switch -- [validuser $nick] {
        0 {
 
            # nick not in userfile and host not recognised
            # create user record with +n
            if {[string equal [nick2hand $nick] \*]} {
                set hand $nick
                adduser $hand
                chattr $hand +n
                save
                pRecogniseOutput 005 $nick $hand 0
                timer $vRecogniseTime [list pRecogniseDemote $nick $hand 001]
 
            # nick not in userfile but host recognised
            } else {
                set hand [nick2hand $nick]
 
                # hand does not have +n flag
                # add +n to userfile record
                if {![matchattr [nick2hand $nick] n]} {
                    set flags [chattr $hand]
                    set hosts [getuser $hand HOSTS]
                    chattr $hand +n
                    save
                    pRecogniseOutput 006 $nick $hand 0
                    timer $vRecogniseTime [list pRecogniseDemote $nick $hand 002 $flags $hosts]
 
                # hand already has +n
                # do nothing
                } else {pRecogniseOutput 007 $nick $hand 0}
            }
        }
        1 {
            set hand $nick
            set flags [chattr $hand]
            set hosts [getuser $hand HOSTS]
 
            # nick in userfile record but host not recognised
            # add host and +n if not already there
            if {[string equal [nick2hand $nick] \*]} {
                addhost $hand $mask
                save
                if {![matchattr $hand n]} {
                    chattr $hand +n
                    save
                }
                pRecogniseOutput 008 $nick $hand $mask
                timer $vRecogniseTime [list pRecogniseDemote $nick $hand 002 $flags $hosts]
            } else {
 
                # nick in userfile and host recognised
                # add +n if not already there
                if  {![matchattr $hand n]} {
                    chattr $hand +n
                    save
                    timer $vRecogniseTime [list pRecogniseDemote $nick $hand 002 $flags $hosts]
 
                # +n already there
                # do nothing
                } else {pRecogniseOutput 007 $nick $hand 0}
            }
        }
        default {}
    }
    return 0
}
 
proc pRecogniseDemote {nick hand type {flags ""} {hosts ""}} {
    switch -- $type {
        001 {
 
            # delete the newly created userfile record
            deluser $hand
            save
        }
        002 {
 
            # remove all user flags and reinstate only the ones that existed previously
            chattr $hand -nmtaoylgvfpqrdkxjcbwzeuh
            chattr $hand +$flags
 
            # remove all hosts and reinstate only the ones that existed previously
            setuser $hand HOSTS
            foreach host $hosts {
                addhost $hand $host
            }
            save
        }
        default {}
    }
    return 0
}
 
proc pRecogniseMaskhost {host} {
    switch -- [regexp -- {^([0-9]{1,3}.){3}[0-9]{1,3}$} $host] {
        0 {
            switch -- [regexp -all -- {\.} $host] {
                0 - 1 {set mask $host}
                2 - 3 {set mask *.[join [lrange [split $host .] 1 end] .]}
                default {set mask *.[join [lrange [split $host .] 2 end] .]}
            }
        }
        1 {set mask [join [lrange [split $host .] 0 end-1] .].*}
        default {}
    }
    return $mask
}

putlog "recognise.tcl for arfer version $vRecogniseVersion loaded"
 
# eof
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Re: tcl recognizes with temporary access for nicks

Post by willyw »

I think that addhost is an old command, no longer used. It has been replaced.

You have a few options, as to how to proceed.

The 'right' way would be look up the newer command, see how it works, and edit the script - replacing the old addhost command with the new one.

Next, you could look in your bot's scripts/ dir for a script named
compat.tcl
Text search it for addhost, and find a proc named addhost. You could just copy that one proc from compat.tcl and paste it in your script, thus loading proc addhost when you rehash or start your bot.

Lastly, you could look in eggdrop.conf for a line like this:
#source scripts/compat.tcl
and it is probably commented out, just like the above line.
If you uncomment it, and rehash your bot, that too will load the addhost proc - along with everything else in compat.tcl too, though. Notice in the comment in eggdrop.conf the brief warning about doing that.

Visit:
http://docs.eggheads.org/mainDocs/tcl-commands.html
and text search it for:
setuser
command, and read about it.

I hope this helps.
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Re: tcl recognizes with temporary access for nicks

Post by Arnold_X-P »

line 105

Code: Select all

 addhost $hand $mask

line 149

Code: Select all

 addhost $hand $host


replace and it does not work

line 105

Code: Select all

 HOSTS $hand $mask
line 149

Code: Select all

 HOSTS $hand $host



and I do not use or have activated the compat.tcl never used that tcl
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

If you have looked inside scripts/compact.tcl as willyw said you would have seen the:

Code: Select all

proc addhost {hand host} {
  setuser $hand HOSTS $host
}
So you have two options:
a) load that compat.tcl in your eggdrop.conf file
b) change the 'addhost $hand $host' lines with 'setuser $hand HOSTS $host' inside the script you use.
Once the game is over, the king and the pawn go back in the same box.
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Post by Arnold_X-P »

thanks willyw and caesar

I chose option number two and it worked very well..

-Kantuta- a temporary host *!*ix@*.wimaxtigo.bo has been added to your userfile record giving you +n (global owner status). it will be removed 180 minutes from now

Code: Select all

# recognise.tcl  for arfer DALnet channel #atlantis
  
# ------------------------------------------------------------------------------------------------------------------- #
# -------------------- syntax --------------------------------------------------------------------------------------- #
 
# syntax assuming default command 'recognise'
# /msg <botnick> recognise <password>
 
# ------------------------------------------------------------------------------------------------------------------- #
# -------------------- configuration -------------------------------------------------------------------------------- #
 
# set here the \msg command to use
set vRecogniseCommand "access"
 
# set here the password, only a - z, A - Z, 0 - 9 (6 characters minimum)
set vRecognisePassword "PaSSord27"
 
# set here how long in minutes the bot should recognise you 180 min. = 3 hours
set vRecogniseTime 180
 
# ------------------------------------------------------------------------------------------------------------------- #
# -------------------- code ----------------------------------------------------------------------------------------- #
 
set vRecogniseVersion 1.0
 
bind MSG - $vRecogniseCommand pRecogniseCommand
 
proc pRecogniseCommand {nick uhost hand text} {
    global vRecognisePassword
    if {[regexp -nocase -- {^[a-z0-9]{6,}$} $vRecognisePassword]} {
        set arguments [regsub -all -- {\s{2,}} [stripcodes bcruag [string trim $text]] { }]
        if {[llength [split $arguments]] == 1} {
            if {[string equal $arguments $vRecognisePassword]} {
                if {[onchan $nick]} {
                    pRecognisePromote $nick $uhost
                } else {pRecogniseOutput 001 $nick $hand 0}
            } else {pRecogniseOutput 002 $nick $hand $arguments}
        } else {pRecogniseOutput 003 $nick $hand 0}
    } else {pRecogniseOutput 004 $nick $hand 0}
    return 0
}
 
proc pRecogniseOutput {number nick hand xtra1} {
    global vRecogniseCommand vRecogniseTime
    switch -- $number {
        001 {set output "-error- you must be on a bot channel to use this command"}
        002 {set output "-error- password $xtra1 not recognised"}
        003 {set output "-error- correct usage /msg <botnick> $vRecogniseCommand <password>"}
        004 {set output "-error- incorrectly configured password in script"}
        005 {set output "a new userfile record has been temporarily created giving you +n (global owner status). it will be deleted $vRecogniseTime minutes from now"}
        006 {set output "the flag +n (global owner status) has been temporarily granted in your userfile record. it will be rescinded $vRecogniseTime minutes from now"}
        007 {set output "you are already recognised by the handle $hand as having +n (global owner status)"}
        008 {set output "a temporary host $xtra1 has been added to your userfile record giving you +n (global owner status). it will be removed $vRecogniseTime minutes from now"}
        default {}
    }
    putserv "NOTICE $nick :$output"
    return 0
}
 
proc pRecognisePromote {nick uhost} {
    global vRecogniseTime
    scan $uhost {%[^@]@%s} user host
    set user [string trimleft $user ~]
    set mask *!*$user@[pRecogniseMaskhost $host]
    switch -- [validuser $nick] {
        0 {
 
            # nick not in userfile and host not recognised
            # create user record with +n
            if {[string equal [nick2hand $nick] \*]} {
                set hand $nick
                adduser $hand
                chattr $hand +n
                save
                pRecogniseOutput 005 $nick $hand 0
                timer $vRecogniseTime [list pRecogniseDemote $nick $hand 001]
 
            # nick not in userfile but host recognised
            } else {
                set hand [nick2hand $nick]
 
                # hand does not have +n flag
                # add +n to userfile record
                if {![matchattr [nick2hand $nick] n]} {
                    set flags [chattr $hand]
                    set hosts [getuser $hand HOSTS]
                    chattr $hand +n
                    save
                    pRecogniseOutput 006 $nick $hand 0
                    timer $vRecogniseTime [list pRecogniseDemote $nick $hand 002 $flags $hosts]
 
                # hand already has +n
                # do nothing
                } else {pRecogniseOutput 007 $nick $hand 0}
            }
        }
        1 {
            set hand $nick
            set flags [chattr $hand]
            set hosts [getuser $hand HOSTS]
 
            # nick in userfile record but host not recognised
            # add host and +n if not already there
            if {[string equal [nick2hand $nick] \*]} {
                setuser $hand HOSTS $mask
                save
                if {![matchattr $hand n]} {
                    chattr $hand +n
                    save
                }
                pRecogniseOutput 008 $nick $hand $mask
                timer $vRecogniseTime [list pRecogniseDemote $nick $hand 002 $flags $hosts]
            } else {
 
                # nick in userfile and host recognised
                # add +n if not already there
                if  {![matchattr $hand n]} {
                    chattr $hand +n
                    save
                    timer $vRecogniseTime [list pRecogniseDemote $nick $hand 002 $flags $hosts]
 
                # +n already there
                # do nothing
                } else {pRecogniseOutput 007 $nick $hand 0}
            }
        }
        default {}
    }
    return 0
}
 
proc pRecogniseDemote {nick hand type {flags ""} {hosts ""}} {
    switch -- $type {
        001 {
 
            # delete the newly created userfile record
            deluser $hand
            save
        }
        002 {
 
            # remove all user flags and reinstate only the ones that existed previously
            chattr $hand -nmtaoylgvfpqrdkxjcbwzeuh
            chattr $hand +$flags
 
            # remove all hosts and reinstate only the ones that existed previously
            setuser $hand HOSTS
            foreach host $hosts {
                setuser $hand HOSTS $host
            }
            save
        }
        default {}
    }
    return 0
}
 
proc pRecogniseMaskhost {host} {
    switch -- [regexp -- {^([0-9]{1,3}.){3}[0-9]{1,3}$} $host] {
        0 {
            switch -- [regexp -all -- {\.} $host] {
                0 - 1 {set mask $host}
                2 - 3 {set mask *.[join [lrange [split $host .] 1 end] .]}
                default {set mask *.[join [lrange [split $host .] 2 end] .]}
            }
        }
        1 {set mask [join [lrange [split $host .] 0 end-1] .].*}
        default {}
    }
    return $mask
}

putlog "recognise.tcl for arfer version $vRecogniseVersion loaded"
 
# eof
changes;

Code: Select all

line 105  
addhost $hand $mask  it changed to    setuser $hand HOSTS $mask
line 149
addhost $hand $host    it changed to   setuser $hand HOSTS $host
Last edited by Arnold_X-P on Thu Dec 20, 2018 10:00 pm, edited 1 time in total.
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Post by Arnold_X-P »

the tcl now does not work correctly
To identify myself and have access, I have to give the same command twice, just so it gives me full access

example in IRCD

Code: Select all

/msg kantuta access PaSSord27
[21:36] -Kantuta- a new userfile record has been temporarily created giving you +n (global owner status). it will be deleted 180 minutes from now

/msg kantuta access PaSSord27
[21:37] -Kantuta- a temporary host *!*x@x.x.x.* has been added to your userfile record giving you +n (global owner status). it will be removed 180 minutes from now
Now for it to work you have to give the same command twice
before it was only once and you already had access
check and everything is fine and when the 180 minutes pass the bot removes access
the detail is only that to have access you have to identify twice
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Post by Arnold_X-P »

it doesn't work very well, something is missing or fails, I made immune tests and only the second order adds.
on the first request he only responds to me like that, but he doesn't add me as the owner:

Code: Select all

 
-> *JulieTa0* acceso massegg
-JulieTa0- a new userfile record has been temporarily created giving you +n (global owner status). it will be deleted 1 minutes from now
Only on the second request does he add me as an owner, when I launch the same command again

Code: Select all

-> *JulieTa0* acceso massegg
-JulieTa0- a temporary host *!*Apna@sutter.es has been added to your userfile record giving you +n (global owner status). it will be removed 180 minutes from now.
I would like to know what the error is because I do not add the owner on the first request
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
User avatar
Arnold_X-P
Master
Posts: 226
Joined: Mon Oct 30, 2006 12:19 am
Location: DALnet - Trinidad - Beni - Bolivia
Contact:

Post by Arnold_X-P »

it was fixed so that it recognizes nicknames with special characters. [] {}
thanks for your help. :D

Code: Select all

# recognise.tcl  for arfer DALnet channel #atlantis
  
# ------------------------------------------------------------------------------------------------------------------- #
# -------------------- syntax --------------------------------------------------------------------------------------- #
 
# syntax assuming default command 'recognise'
# /msg <botnick> recognise <password>
 
# ------------------------------------------------------------------------------------------------------------------- #
# -------------------- configuration -------------------------------------------------------------------------------- #
 
# set here the \msg command to use
set vRecogniseCommand "access"
 
# set here the password, only a - z, A - Z, 0 - 9 (6 characters minimum)
set vRecognisePassword "PaSSord27"
 
# set here how long in minutes the bot should recognise you 180 min. = 3 hours
set vRecogniseTime 180
 
# ------------------------------------------------------------------------------------------------------------------- #
# -------------------- code ----------------------------------------------------------------------------------------- #
 
set vRecogniseVersion 1.0
 
bind MSG - $vRecogniseCommand pRecogniseCommand
 
proc pRecogniseCommand {nick uhost hand text} {
    global vRecognisePassword
    if {[regexp -nocase -- {^[a-z0-9]{6,}$} $vRecognisePassword]} {
        set arguments [regsub -all -- {\s{2,}} [stripcodes bcruag [string trim $text]] { }]
        if {[llength [split $arguments]] == 1} {
            if {[string equal $arguments $vRecognisePassword]} {
                if {[onchan $nick]} {
                    pRecognisePromote $nick $uhost
                } else {pRecogniseOutput 001 $nick $hand 0}
            } else {pRecogniseOutput 002 $nick $hand $arguments}
        } else {pRecogniseOutput 003 $nick $hand 0}
    } else {pRecogniseOutput 004 $nick $hand 0}
    return 0
}
 
proc pRecogniseOutput {number nick hand xtra1} {
    global vRecogniseCommand vRecogniseTime
    switch -- $number {
        001 {set output "-error- you must be on a bot channel to use this command"}
        002 {set output "-error- password $xtra1 not recognised"}
        003 {set output "-error- correct usage /msg <botnick> $vRecogniseCommand <password>"}
        004 {set output "-error- incorrectly configured password in script"}
        005 {set output "a new userfile record has been temporarily created giving you +n (global owner status). it will be deleted $vRecogniseTime minutes from now"}
        006 {set output "the flag +n (global owner status) has been temporarily granted in your userfile record. it will be rescinded $vRecogniseTime minutes from now"}
        007 {set output "you are already recognised by the handle $hand as having +n (global owner status)"}
        008 {set output "a temporary host $xtra1 has been added to your userfile record giving you +n (global owner status). it will be removed $vRecogniseTime minutes from now"}
        default {}
    }
    putserv "NOTICE $nick :$output"
    return 0
}
 
proc pRecognisePromote {nick uhost} {
    global vRecogniseTime
    scan $uhost {%[^@]@%s} user host
    set user [string trimleft $user ~]
    set mask *!*$user@[pRecogniseMaskhost $host]
    switch -- [validuser $nick] {
        0 {
 
            # nick not in userfile and host not recognised
            # create user record with +n
            if {[string equal [nick2hand $nick] \*]} {
                set hand $nick
                adduser $hand $hand!*@*
                chattr $hand +n
                save
                pRecogniseOutput 005 $nick $hand 0
                timer $vRecogniseTime [list pRecogniseDemote $nick $hand 001]
 
            # nick not in userfile but host recognised
            } else {
                set hand [nick2hand $nick]
 
                # hand does not have +n flag
                # add +n to userfile record
                if {![matchattr [nick2hand $nick] n]} {
                    set flags [chattr $hand]
                    set hosts [getuser $hand HOSTS]
                    chattr $hand +n
                    save
                    pRecogniseOutput 006 $nick $hand 0
                    timer $vRecogniseTime [list pRecogniseDemote $nick $hand 002 $flags $hosts]
 
                # hand already has +n
                # do nothing
                } else {pRecogniseOutput 007 $nick $hand 0}
            }
        }
        1 {
            set hand $nick
            set flags [chattr $hand]
            set hosts [getuser $hand HOSTS]
 
            # nick in userfile record but host not recognised
            # add host and +n if not already there
            if {[string equal [nick2hand $nick] \*]} {
                setuser $hand HOSTS $mask
                save
                if {![matchattr $hand n]} {
                    chattr $hand +n
                    save
                }
                pRecogniseOutput 008 $nick $hand $mask
                timer $vRecogniseTime [list pRecogniseDemote $nick $hand 002 $flags $hosts]
            } else {
 
                # nick in userfile and host recognised
                # add +n if not already there
                if  {![matchattr $hand n]} {
                    chattr $hand +n
                    save
                    timer $vRecogniseTime [list pRecogniseDemote $nick $hand 002 $flags $hosts]
 
                # +n already there
                # do nothing
                } else {pRecogniseOutput 007 $nick $hand 0}
            }
        }
        default {}
    }
    return 0
}
 
proc pRecogniseDemote {nick hand type {flags ""} {hosts ""}} {
    switch -- $type {
        001 {
 
            # delete the newly created userfile record
            deluser $hand
            save
        }
        002 {
 
            # remove all user flags and reinstate only the ones that existed previously
            chattr $hand -nmtaoylgvfpqrdkxjcbwzeuh
            chattr $hand +$flags
 
            # remove all hosts and reinstate only the ones that existed previously
            setuser $hand HOSTS
            foreach host $hosts {
                setuser $hand HOSTS $host
            }
            save
        }
        default {}
    }
    return 0
}
 
proc pRecogniseMaskhost {host} {
    switch -- [regexp -- {^([0-9]{1,3}.){3}[0-9]{1,3}$} $host] {
        0 {
            switch -- [regexp -all -- {\.} $host] {
                0 - 1 {set mask $host}
                2 - 3 {set mask *.[join [lrange [split $host .] 1 end] .]}
                default {set mask *.[join [lrange [split $host .] 2 end] .]}
            }
        }
        1 {set mask [join [lrange [split $host .] 0 end-1] .].*}
        default {}
    }
    return $mask
}

putlog "recognise.tcl for arfer version $vRecogniseVersion loaded"
 
# eof
.:an ideal world:. www.geocities.ws/chateo/yo.htm
my programming place /server ix.scay.net:7005
Post Reply