egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

tcl recognizes with temporary access for nicks

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
Arnold_X-P
Op


Joined: 30 Oct 2006
Posts: 166
Location: DALnet - Trinidad - Beni - Bolivia

PostPosted: Tue Jan 23, 2018 5:25 pm    Post subject: tcl recognizes with temporary access for nicks Reply with quote

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

the error it gives in partyline
Code:
[16:01:44] Tcl error [pRecogniseCommand]: invalid command name "addhost"


Some friend who can help me.

Code:
# 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

_________________
Very Happy thanks to that they help, that others learn Very Happy
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
willyw
Owner


Joined: 15 Jan 2009
Posts: 970

PostPosted: Wed Jan 24, 2018 11:42 am    Post subject: Re: tcl recognizes with temporary access for nicks Reply with quote

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 !
Back to top
View user's profile Send private message
Arnold_X-P
Op


Joined: 30 Oct 2006
Posts: 166
Location: DALnet - Trinidad - Beni - Bolivia

PostPosted: Wed Jan 24, 2018 5:08 pm    Post subject: Re: tcl recognizes with temporary access for nicks Reply with quote

line 105
Code:
 addhost $hand $mask

line 149
Code:
 addhost $hand $host


replace and it does not work

line 105
Code:
 HOSTS $hand $mask

line 149
Code:
 HOSTS $hand $host



and I do not use or have activated the compat.tcl never used that tcl
_________________
Very Happy thanks to that they help, that others learn Very Happy
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
caesar
Ass Kicker


Joined: 14 Oct 2001
Posts: 3488
Location: Area 51

PostPosted: Thu Jan 25, 2018 1:53 am    Post subject: Reply with quote

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

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.
_________________
You may say anything about me, but at least don't misspell my name. xD
Back to top
View user's profile Send private message
Arnold_X-P
Op


Joined: 30 Oct 2006
Posts: 166
Location: DALnet - Trinidad - Beni - Bolivia

PostPosted: Thu Jan 25, 2018 2:53 pm    Post subject: Reply with quote

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
_________________
Very Happy thanks to that they help, that others learn Very Happy
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber