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.

Help me please irco.voicecontrol.tcl

Support & discussion of released scripts, and announcements of new releases.
Post Reply
c
calippo
Voice
Posts: 13
Joined: Mon Jan 19, 2009 3:53 pm

Help me please irco.voicecontrol.tcl

Post by calippo »

I need a help . This does not apply tcl voice kick and ban the nick brackets {} [] () and other symbols, how can I do? Thanks and see you soon marco

# voice control v1.0 (14 April 2001) By irco <irco@mail.com> EFnet #Q8Help
# the voice control can make voice groub to control your channel
# the can do to kick ban unban mode on/off and change to topic
# Notes: I wrote this on eggdrop 1.3.x, don't complain if you load it up
# on your prehistoric 1.1.5 and it blows up the computer.

bind mode - *+v* voicenotice
bind pub - !kick voicekick
bind pub - !ban voiceban
bind pub - !unban voiceunban
bind pub - !mode voicemode
bind pub - !topic voicetopic

set voicechans "#channel"

# set the Voice notice msg

set voicemsg "welcome to the control #lamerchan you can use !ban, !kick, !unban, !topic, !mode on/off"

# Don't edit anything below unless you know what you're doing

set ver "v1.0"

proc voicenotice {nick uhost hand chan mode victim} { if {[lsearch -exact $::voicechans $chan] == -1} { return 0 }
global voicemsg
putserv "notice $victim :$voicemsg"
return 0
}
proc voicekick {nick uhost hand chan arg} { if {[lsearch -exact $::voicechans $chan] == -1} { return 0 }
global botnick
if {[isvoice $nick $chan]} {
set who [lindex $arg 0]
set why [lrange $arg 1 end]
if {$who == ""} {
putserv "notice $nick :Usage: !kick <nick> <reason>"
return 0
}
if {![validuser [nick2hand $who $chan]]} {
if {![onchan $who $chan]} {
putserv "notice $nick :$who is not on the channel"
return 0
}
putserv "kick $chan $who :$why kick by $nick"
}
}
}
proc voiceban {nick uhost hand chan arg} {
global botnick
if {[isvoice $nick $chan]} {
set who [lindex $arg 0]
set why [lrange $arg 1 end]
if {$who == ""} {
putserv "notice $nick :Usage: !ban <nick> <reason>"
return 0
}
if {![validuser [nick2hand $who $chan]]} {
if {![onchan $who $chan]} {
putserv "notice $nick :$who is not on the channel"
return 0
}
if {![onchan $who $chan]} {
putserv "notice $nick :$who is not on the channel"
return 0
}
set host "*!*@[lindex [split [getchanhost $who $chan] "@"] end]"
putserv "MODE $chan -o+b $who $host"
putserv "KICK $chan $who :$why Ban By $nick"
return
}
}
}
proc voiceunban {nick uhost handle chan text} { if {[lsearch -exact $::voicechans $chan] == -1} { return 0 }
global botnick
if {$text == ""} {
putserv "notice $nick :Usage: !unban host"
return 0
}
if {([isvoice $nick $chan]) && ([isop $botnick $chan])} {
putserv "MODE $chan -b [lindex $text 0] :[lrange $text 1 end]"
return 0
}
}
proc voicemode {nick uhost handle chan text} { if {[lsearch -exact $::voicechans $chan] == -1} { return 0 }
global botnick
if {([isvoice $nick $chan]) && ([isop $botnick $chan])} {
if {$text == ""} {
putserv "notice $nick :Usage: !mode On/Off"
return 0
}
if {[lindex $text 0] == "on"} {
putserv "MODE $chan +mi"
} elseif {[lindex $text 0] == "off"} {
putserv "MODE $chan -mi"
}
}
}
proc voicetopic {nick uhost handle chan text} { if {[lsearch -exact $::voicechans $chan] == -1} { return 0 }
global botnick
if {[isvoice $nick $chan]} {
if {[isop $botnick $chan] == "1"} {
if {$text == ""} {
putserv "notice $nick :Usage: !topic <reason>"
return 0
}
putserv "TOPIC $chan :$text topic By $nick"
}
}
}
putlog "Voice control $ver By irco loaded ..."
User avatar
incith
Master
Posts: 275
Joined: Sat Apr 23, 2005 2:16 am
Location: Canada

Post by incith »

Try {} instead of "", e.g.

Code: Select all

putserv "kick $chan $who :$why kick by $nick"
..becomes..

Code: Select all

putserv {kick $chan $who :$why kick by $nick}
If that doesn't work I guess some escaping will have to be done on the nick.
c
calippo
Voice
Posts: 13
Joined: Mon Jan 19, 2009 3:53 pm

Post by calippo »

incith wrote:Try {} instead of "", e.g.

Code: Select all

putserv "kick $chan $who :$why kick by $nick"
..becomes..

Code: Select all

putserv {kick $chan $who :$why kick by $nick}
If that doesn't work I guess some escaping will have to be done on the nick.
nothing it dosen't work this is the error message is "not on the channel"
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

Code: Select all

set who [lindex $arg 0]
set why [lrange $arg 1 end] 
here you are using a list command on a string. try making the $arg into a list first using split.

Code: Select all

set who [lindex [split $arg] 0]
set why [lrange [split $arg] 1 end]
and eggdrop comes with its own kick command, you could try using that
putkick <channel> <nick,nick,...> [reason]
Description: sends kicks to the server and tries to put as many nicks
into one kick command as possible.
Returns: nothing
Module: irc
Elen sila lúmenn' omentielvo
User avatar
incith
Master
Posts: 275
Joined: Sat Apr 23, 2005 2:16 am
Location: Canada

Post by incith »

That'll teach me to post a few seconds after waking up. :D
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

You fail to convert properly between lists and strings in several places, which, as per Papillon's post, gives rise to the errors you have already encountered.

The following URL serves as a good tutorial on the subject

http://www.peterre.info/characters.html


I have taken the trouble to correct the script and to rewrite into a more elegant code structure. I have tested the script on Eggdrop 1.6.19 compiled with Tcl8.4 and seems to work fine including with nicks that contain special characters (heh, I must have had nothing to do for a while there).

Code: Select all

# set here the space delimited string of channel(s) that the script is active in
set vVoiceChans "#eggTCL"

# set here the notice to send to users that are voiced in the above preconfigured channel(s)
set vVoiceMessage "welcome to voice control script - you can use !ban, !kick, !unban, !topic, !mode on/off"

bind mode - *+v* pVoiceNotice
bind pub - !kick pVoiceKick
bind pub - !ban pVoiceBan
bind pub - !unban pVoiceUnban
bind pub - !mode pVoiceMode
bind pub - !topic pVoiceTopic

set vVoiceVersion "v1.0"

proc pVoiceNotice {nick uhost hand chan mc target} {
    global vVoiceChans vVoiceMessage
    if {[lsearch -exact [split [string tolower $vVoiceChans]] [string tolower $chan]] != -1} {
        putserv "NOTICE $target :$vVoiceMessage"
    }
    return 0
}

proc pVoiceKick {nick uhost hand chan text} {
    global vVoiceChans
    if {[lsearch -exact [split [string tolower $vVoiceChans]] [string tolower $chan]] != -1} {
        set txt [split [string trim $text]]
        if {[llength $txt] >= 2} {
            set target [lindex $txt 0]
            set reason [join [lrange $txt 1 end]]
            if {([isvoice $nick $chan]) || ([isop $nick $chan])} {
                if {[onchan $target $chan]} {
                    if {![validuser [nick2hand $target $chan]]} {
                        if {[botisop $chan]} {
                            putserv "KICK $chan $target :$reason (requested by $nick)"
                        } else {putserv "NOTICE $nick :-error- I need to be op'd in $chan to do that"}
                    } else {putserv "NOTICE $nick :-error- $target has a valid bot user record for $chan"}
                } else {putserv "NOTICE $nick :-error- $target is not on $chan"}
            } else {putserv "NOTICE $nick :-error- you need to be at least a channel voice in $chan to kick users via this script"}
        } else {putserv "NOTICE $nick :-error- correct syntax is !kick <nick> <reason>"}
    }
    return 0
}

proc pVoiceBan {nick uhost hand chan text} {
    global vVoiceChans
    if {[lsearch -exact [split [string tolower $vVoiceChans]] [string tolower $chan]] != -1} {
        set txt [split [string trim $text]]
        if {[llength $txt] >= 2} {
            set target [lindex $txt 0]
            set reason [join [lrange $txt 1 end]]
            if {([isvoice $nick $chan]) || ([isop $nick $chan])} {
                if {[onchan $target $chan]} {
                    if {![validuser [nick2hand $target $chan]]} {
                        if {[botisop $chan]} {
                            scan [getchanhost $target $chan] {%[^@]@%s} user host
                            putserv "MODE $chan -o+b $target $host"
                            putserv "KICK $chan $target :$reason (requested by $nick)"
                        } else {putserv "NOTICE $nick :-error- I need to be op'd in $chan to do that"}
                    } else {putserv "NOTICE $nick :-error- $target has a valid bot user record for $chan"}
                } else {putserv "NOTICE $nick :-error- $target is not on $chan"}
            } else {putserv "NOTICE $nick :-error- you need to be at least a channel voice in $chan to ban users via this script"}
        } else {putserv "NOTICE $nick :-error- correct syntax is !ban <nick> <reason>"}
    }
    return 0
}

proc pVoiceUnban {nick uhost handle chan text} {
    global vVoiceChans
    if {[lsearch -exact [split [string tolower $vVoiceChans]] [string tolower $chan]] != -1} {
        set txt [split [string trim $text]]
        if {[llength $txt] == 1} {
            if {([isvoice $nick $chan]) || ([isop $nick $chan])} {
                if {[botisop $chan]} {
                    putserv "MODE $chan -b [join $txt]"
                } else {putserv "NOTICE $nick :-error- I need to be op'd in $chan to do that"}
            } else {putserv "NOTICE $nick :-error- you need to be at least a channel voice in $chan to unban hosts via this script"}
        } else {putserv "NOTICE $nick :-error- correct syntax is !unban <host>"}
    }
    return 0
}

proc pVoiceMode {nick uhost handle chan text} {
    global vVoiceChans
    if {[lsearch -exact [split [string tolower $vVoiceChans]] [string tolower $chan]] != -1} {
        set txt [split [string trim $text]]
        if {[llength $txt] == 1} {
            if {([isvoice $nick $chan]) || ([isop $nick $chan])} {
                if {[botisop $chan]} {
                    switch -- [string tolower [join $txt]] {
                        on {putserv "MODE $chan +mi"}
                        off {putserv "MODE $chan -mi"}
                        default {putserv "NOTICE $nick :-error- single text argument can only be on or off"}
                    }
                } else {putserv "NOTICE $nick :-error- I need to be op'd in $chan to do that"}
            } else {putserv "NOTICE $nick :-error- you need to be at least a channel voice in $chan to set modes via this script"}
        } else {putserv "NOTICE $nick :-error- correct syntax is !mode <on||off>"}
    }
    return 0
}

proc pVoiceTopic {nick uhost handle chan text} {
    global vVoiceChans
    if {[lsearch -exact [split [string tolower $vVoiceChans]] [string tolower $chan]] != -1} {
        set txt [split [string trim $text]]
        if {[llength $txt] >= 1} {
            if {([isvoice $nick $chan]) || ([isop $nick $chan])} {
                if {[botisop $chan]} {
                    putserv "TOPIC $chan :[join $text] (requested by $nick)"
                } else {putserv "NOTICE $nick :-error- I need to be op'd in $chan to do that"}
            } else {putserv "NOTICE $nick :-error- you need to be at least a channel voice in $chan to set a topic via this script"}
        } else {putserv "NOTICE $nick :-error- correct syntax is !topic <topic>"}
    }
    return 0
}

# eof
[/url]
c
calippo
Voice
Posts: 13
Joined: Mon Jan 19, 2009 3:53 pm

Post by calippo »

arfer wrote:You fail to convert properly between lists and strings in several places, which, as per Papillon's post, gives rise to the errors you have already encountered.

The following URL serves as a good tutorial on the subject

http://www.peterre.info/characters.html


I have taken the trouble to correct the script and to rewrite into a more elegant code structure. I have tested the script on Eggdrop 1.6.19 compiled with Tcl8.4 and seems to work fine including with nicks that contain special characters (heh, I must have had nothing to do for a while there).

Code: Select all

# set here the space delimited string of channel(s) that the script is active in
set vVoiceChans "#eggTCL"

# set here the notice to send to users that are voiced in the above preconfigured channel(s)
set vVoiceMessage "welcome to voice control script - you can use !ban, !kick, !unban, !topic, !mode on/off"

bind mode - *+v* pVoiceNotice
bind pub - !kick pVoiceKick
bind pub - !ban pVoiceBan
bind pub - !unban pVoiceUnban
bind pub - !mode pVoiceMode
bind pub - !topic pVoiceTopic

set vVoiceVersion "v1.0"

proc pVoiceNotice {nick uhost hand chan mc target} {
    global vVoiceChans vVoiceMessage
    if {[lsearch -exact [split [string tolower $vVoiceChans]] [string tolower $chan]] != -1} {
        putserv "NOTICE $target :$vVoiceMessage"
    }
    return 0
}

proc pVoiceKick {nick uhost hand chan text} {
    global vVoiceChans
    if {[lsearch -exact [split [string tolower $vVoiceChans]] [string tolower $chan]] != -1} {
        set txt [split [string trim $text]]
        if {[llength $txt] >= 2} {
            set target [lindex $txt 0]
            set reason [join [lrange $txt 1 end]]
            if {([isvoice $nick $chan]) || ([isop $nick $chan])} {
                if {[onchan $target $chan]} {
                    if {![validuser [nick2hand $target $chan]]} {
                        if {[botisop $chan]} {
                            putserv "KICK $chan $target :$reason (requested by $nick)"
                        } else {putserv "NOTICE $nick :-error- I need to be op'd in $chan to do that"}
                    } else {putserv "NOTICE $nick :-error- $target has a valid bot user record for $chan"}
                } else {putserv "NOTICE $nick :-error- $target is not on $chan"}
            } else {putserv "NOTICE $nick :-error- you need to be at least a channel voice in $chan to kick users via this script"}
        } else {putserv "NOTICE $nick :-error- correct syntax is !kick <nick> <reason>"}
    }
    return 0
}

proc pVoiceBan {nick uhost hand chan text} {
    global vVoiceChans
    if {[lsearch -exact [split [string tolower $vVoiceChans]] [string tolower $chan]] != -1} {
        set txt [split [string trim $text]]
        if {[llength $txt] >= 2} {
            set target [lindex $txt 0]
            set reason [join [lrange $txt 1 end]]
            if {([isvoice $nick $chan]) || ([isop $nick $chan])} {
                if {[onchan $target $chan]} {
                    if {![validuser [nick2hand $target $chan]]} {
                        if {[botisop $chan]} {
                            scan [getchanhost $target $chan] {%[^@]@%s} user host
                            putserv "MODE $chan -o+b $target $host"
                            putserv "KICK $chan $target :$reason (requested by $nick)"
                        } else {putserv "NOTICE $nick :-error- I need to be op'd in $chan to do that"}
                    } else {putserv "NOTICE $nick :-error- $target has a valid bot user record for $chan"}
                } else {putserv "NOTICE $nick :-error- $target is not on $chan"}
            } else {putserv "NOTICE $nick :-error- you need to be at least a channel voice in $chan to ban users via this script"}
        } else {putserv "NOTICE $nick :-error- correct syntax is !ban <nick> <reason>"}
    }
    return 0
}

proc pVoiceUnban {nick uhost handle chan text} {
    global vVoiceChans
    if {[lsearch -exact [split [string tolower $vVoiceChans]] [string tolower $chan]] != -1} {
        set txt [split [string trim $text]]
        if {[llength $txt] == 1} {
            if {([isvoice $nick $chan]) || ([isop $nick $chan])} {
                if {[botisop $chan]} {
                    putserv "MODE $chan -b [join $txt]"
                } else {putserv "NOTICE $nick :-error- I need to be op'd in $chan to do that"}
            } else {putserv "NOTICE $nick :-error- you need to be at least a channel voice in $chan to unban hosts via this script"}
        } else {putserv "NOTICE $nick :-error- correct syntax is !unban <host>"}
    }
    return 0
}

proc pVoiceMode {nick uhost handle chan text} {
    global vVoiceChans
    if {[lsearch -exact [split [string tolower $vVoiceChans]] [string tolower $chan]] != -1} {
        set txt [split [string trim $text]]
        if {[llength $txt] == 1} {
            if {([isvoice $nick $chan]) || ([isop $nick $chan])} {
                if {[botisop $chan]} {
                    switch -- [string tolower [join $txt]] {
                        on {putserv "MODE $chan +mi"}
                        off {putserv "MODE $chan -mi"}
                        default {putserv "NOTICE $nick :-error- single text argument can only be on or off"}
                    }
                } else {putserv "NOTICE $nick :-error- I need to be op'd in $chan to do that"}
            } else {putserv "NOTICE $nick :-error- you need to be at least a channel voice in $chan to set modes via this script"}
        } else {putserv "NOTICE $nick :-error- correct syntax is !mode <on||off>"}
    }
    return 0
}

proc pVoiceTopic {nick uhost handle chan text} {
    global vVoiceChans
    if {[lsearch -exact [split [string tolower $vVoiceChans]] [string tolower $chan]] != -1} {
        set txt [split [string trim $text]]
        if {[llength $txt] >= 1} {
            if {([isvoice $nick $chan]) || ([isop $nick $chan])} {
                if {[botisop $chan]} {
                    putserv "TOPIC $chan :[join $text] (requested by $nick)"
                } else {putserv "NOTICE $nick :-error- I need to be op'd in $chan to do that"}
            } else {putserv "NOTICE $nick :-error- you need to be at least a channel voice in $chan to set a topic via this script"}
        } else {putserv "NOTICE $nick :-error- correct syntax is !topic <topic>"}
    }
    return 0
}

# eof
[/url]
thank you for your help but this scritp doesn't work with command: for exemple
!voice {nick} or !voice {nick] and i can't devoice with it
and if i want to kick or ban without reasons it doesn't work
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

There wasn't any voice/devoice command in your original post and neither was it clear from the coding style if you wished to permit kick/ban without a reason.

Nonetheless, here is a revised script which will do what you ask. The !voice <target> command is a toggle. If the taget is already voiced they will be devoiced, conversely if they are not already voiced they will be voiced.

I'm beginning to think this is never ending.

Code: Select all

# set here the space delimited string of channel(s) that the script is active in
set vVoiceChans "#eggTCL"

# set here the notice to send to users that are voiced in the above preconfigured channel(s)
set vVoiceMessage "welcome to voice control script - you can use !ban, !kick, !unban, !topic, !mode, !voice"

bind mode - *+v* pVoiceNotice
bind pub - !kick pVoiceKick
bind pub - !ban pVoiceBan
bind pub - !unban pVoiceUnban
bind pub - !mode pVoiceMode
bind pub - !topic pVoiceTopic
bind pub - !voice pVoiceVoice

set vVoiceVersion v2.0

proc pVoiceNotice {nick uhost hand chan mc target} {
    global vVoiceChans vVoiceMessage
    if {[lsearch -exact [split [string tolower $vVoiceChans]] [string tolower $chan]] != -1} {
        putserv "NOTICE $target :$vVoiceMessage"
    }
    return 0
}

proc pVoiceKick {nick uhost hand chan text} {
    global vVoiceChans
    if {[lsearch -exact [split [string tolower $vVoiceChans]] [string tolower $chan]] != -1} {
        set txt [split [string trim $text]]
        switch -- [llength $txt] {
            0 {
                putserv "NOTICE $nick :-error- correct syntax is !kick <nick> ?reason?"
                return 0
            }
            1 {set target [lindex $txt 0]}
            default {
                set target [lindex $txt 0]
                set reason [join [lrange $txt 1 end]]
            }
        }
        if {([isvoice $nick $chan]) || ([isop $nick $chan])} {
            if {[onchan $target $chan]} {
                if {![validuser [nick2hand $target $chan]]} {
                    if {[botisop $chan]} {
                        if {[info exists reason]} {
                            putserv "KICK $chan $target :$reason *- requested by $nick -*)"
                        } else {putserv "KICK $chan $target :*- requested by $nick -*"}
                    } else {putserv "NOTICE $nick :-error- I need to be op'd in $chan to do that"}
                } else {putserv "NOTICE $nick :-error- $target has a valid bot user record for $chan"}
            } else {putserv "NOTICE $nick :-error- $target is not on $chan"}
        } else {putserv "NOTICE $nick :-error- you need to be at least a channel voice in $chan to kick users via this script"}
    }
    return 0
}

proc pVoiceBan {nick uhost hand chan text} {
    global vVoiceChans
    if {[lsearch -exact [split [string tolower $vVoiceChans]] [string tolower $chan]] != -1} {
        set txt [split [string trim $text]]
        switch -- [llength $txt] {
            0 {
                putserv "NOTICE $nick :-error- correct syntax is !ban <nick> ?reason?"
                return 0
            }
            1 {
                set target [lindex $txt 0]
            }
            default {
                set target [lindex $txt 0]
                set reason [join [lrange $txt 1 end]]
            }
        }
        if {([isvoice $nick $chan]) || ([isop $nick $chan])} {
            if {[onchan $target $chan]} {
                if {![validuser [nick2hand $target $chan]]} {
                    if {[botisop $chan]} {
                        scan [getchanhost $target $chan] {%[^@]@%s} user host
                        putserv "MODE $chan -o+b $target $host"
                        if {[info exists reason]} {
                            putserv "KICK $chan $target :$reason *- requested by $nick -*"
                        } else {putserv "KICK $chan $target :*- requested by $nick -*"}
                    } else {putserv "NOTICE $nick :-error- I need to be op'd in $chan to do that"}
                } else {putserv "NOTICE $nick :-error- $target has a valid bot user record for $chan"}
            } else {putserv "NOTICE $nick :-error- $target is not on $chan"}
        } else {putserv "NOTICE $nick :-error- you need to be at least a channel voice in $chan to ban users via this script"}
    }
    return 0
}

proc pVoiceUnban {nick uhost handle chan text} {
    global vVoiceChans
    if {[lsearch -exact [split [string tolower $vVoiceChans]] [string tolower $chan]] != -1} {
        set txt [split [string trim $text]]
        if {[llength $txt] == 1} {
            set host [lindex $txt 0]
            if {([isvoice $nick $chan]) || ([isop $nick $chan])} {
                if {[botisop $chan]} {
                    putserv "MODE $chan -b $host"
                } else {putserv "NOTICE $nick :-error- I need to be op'd in $chan to do that"}
            } else {putserv "NOTICE $nick :-error- you need to be at least a channel voice in $chan to unban hosts via this script"}
        } else {putserv "NOTICE $nick :-error- correct syntax is !unban <host>"}
    }
    return 0
}

proc pVoiceMode {nick uhost handle chan text} {
    global vVoiceChans
    if {[lsearch -exact [split [string tolower $vVoiceChans]] [string tolower $chan]] != -1} {
        set txt [split [string trim $text]]
        if {[llength $txt] == 1} {
            set mode [lindex $txt 0]
            if {([isvoice $nick $chan]) || ([isop $nick $chan])} {
                if {[botisop $chan]} {
                    switch -- [string tolower $mode] {
                        on {putserv "MODE $chan +mi"}
                        off {putserv "MODE $chan -mi"}
                        default {putserv "NOTICE $nick :-error- single text argument can only be on or off"}
                    }
                } else {putserv "NOTICE $nick :-error- I need to be op'd in $chan to do that"}
            } else {putserv "NOTICE $nick :-error- you need to be at least a channel voice in $chan to set modes via this script"}
        } else {putserv "NOTICE $nick :-error- correct syntax is !mode <on||off>"}
    }
    return 0
}

proc pVoiceTopic {nick uhost handle chan text} {
    global vVoiceChans
    if {[lsearch -exact [split [string tolower $vVoiceChans]] [string tolower $chan]] != -1} {
        set txt [split [string trim $text]]
        if {[llength $txt] >= 1} {
            set topic [join [lrange $txt 0 end]]
            if {([isvoice $nick $chan]) || ([isop $nick $chan])} {
                if {[botisop $chan]} {
                    putserv "TOPIC $chan :$topic *- requested by $nick -*"
                } else {putserv "NOTICE $nick :-error- I need to be op'd in $chan to do that"}
            } else {putserv "NOTICE $nick :-error- you need to be at least a channel voice in $chan to set a topic via this script"}
        } else {putserv "NOTICE $nick :-error- correct syntax is !topic <topic>"}
    }
    return 0
}

proc pVoiceVoice {nick uhost handle chan text} {
    global vVoiceChans
    if {[lsearch -exact [split [string tolower $vVoiceChans]] [string tolower $chan]] != -1} {
        set txt [split [string trim $text]]
        if {[llength $txt] == 1} {
            set target [lindex $txt 0]
            if {([isvoice $nick $chan]) || ([isop $nick $chan])} {
                if {[onchan $target $chan]} {
                    if {[botisop $chan]} {
                        switch -- [isvoice $target $chan] {
                            0 {putserv "MODE $chan +v $target"}
                            1 {putserv "MODE $chan -v $target"}
                        }
                    } else {putserv "NOTICE $nick :-error- I need to be op'd in $chan to do that"}
                } else {putserv "NOTICE $nick :-error- $target is not on $chan"}
            } else {putserv "NOTICE $nick :-error- you need to be at least a channel voice in $chan to voice/devoice users via this script"}
        } else {putserv "NOTICE $nick :-error- correct syntax is !voice <nick>"}
    }
    return 0
}

# eof
[/code]
c
calippo
Voice
Posts: 13
Joined: Mon Jan 19, 2009 3:53 pm

Post by calippo »

arfer wrote:There wasn't any voice/devoice command in your original post and neither was it clear from the coding style if you wished to permit kick/ban without a reason.

Nonetheless, here is a revised script which will do what you ask. The !voice <target> command is a toggle. If the taget is already voiced they will be devoiced, conversely if they are not already voiced they will be voiced.

I'm beginning to think this is never ending.

Code: Select all

# set here the space delimited string of channel(s) that the script is active in
set vVoiceChans "#eggTCL"

# set here the notice to send to users that are voiced in the above preconfigured channel(s)
set vVoiceMessage "welcome to voice control script - you can use !ban, !kick, !unban, !topic, !mode, !voice"

bind mode - *+v* pVoiceNotice
bind pub - !kick pVoiceKick
bind pub - !ban pVoiceBan
bind pub - !unban pVoiceUnban
bind pub - !mode pVoiceMode
bind pub - !topic pVoiceTopic
bind pub - !voice pVoiceVoice

set vVoiceVersion v2.0

proc pVoiceNotice {nick uhost hand chan mc target} {
    global vVoiceChans vVoiceMessage
    if {[lsearch -exact [split [string tolower $vVoiceChans]] [string tolower $chan]] != -1} {
        putserv "NOTICE $target :$vVoiceMessage"
    }
    return 0
}

proc pVoiceKick {nick uhost hand chan text} {
    global vVoiceChans
    if {[lsearch -exact [split [string tolower $vVoiceChans]] [string tolower $chan]] != -1} {
        set txt [split [string trim $text]]
        switch -- [llength $txt] {
            0 {
                putserv "NOTICE $nick :-error- correct syntax is !kick <nick> ?reason?"
                return 0
            }
            1 {set target [lindex $txt 0]}
            default {
                set target [lindex $txt 0]
                set reason [join [lrange $txt 1 end]]
            }
        }
        if {([isvoice $nick $chan]) || ([isop $nick $chan])} {
            if {[onchan $target $chan]} {
                if {![validuser [nick2hand $target $chan]]} {
                    if {[botisop $chan]} {
                        if {[info exists reason]} {
                            putserv "KICK $chan $target :$reason *- requested by $nick -*)"
                        } else {putserv "KICK $chan $target :*- requested by $nick -*"}
                    } else {putserv "NOTICE $nick :-error- I need to be op'd in $chan to do that"}
                } else {putserv "NOTICE $nick :-error- $target has a valid bot user record for $chan"}
            } else {putserv "NOTICE $nick :-error- $target is not on $chan"}
        } else {putserv "NOTICE $nick :-error- you need to be at least a channel voice in $chan to kick users via this script"}
    }
    return 0
}

proc pVoiceBan {nick uhost hand chan text} {
    global vVoiceChans
    if {[lsearch -exact [split [string tolower $vVoiceChans]] [string tolower $chan]] != -1} {
        set txt [split [string trim $text]]
        switch -- [llength $txt] {
            0 {
                putserv "NOTICE $nick :-error- correct syntax is !ban <nick> ?reason?"
                return 0
            }
            1 {
                set target [lindex $txt 0]
            }
            default {
                set target [lindex $txt 0]
                set reason [join [lrange $txt 1 end]]
            }
        }
        if {([isvoice $nick $chan]) || ([isop $nick $chan])} {
            if {[onchan $target $chan]} {
                if {![validuser [nick2hand $target $chan]]} {
                    if {[botisop $chan]} {
                        scan [getchanhost $target $chan] {%[^@]@%s} user host
                        putserv "MODE $chan -o+b $target $host"
                        if {[info exists reason]} {
                            putserv "KICK $chan $target :$reason *- requested by $nick -*"
                        } else {putserv "KICK $chan $target :*- requested by $nick -*"}
                    } else {putserv "NOTICE $nick :-error- I need to be op'd in $chan to do that"}
                } else {putserv "NOTICE $nick :-error- $target has a valid bot user record for $chan"}
            } else {putserv "NOTICE $nick :-error- $target is not on $chan"}
        } else {putserv "NOTICE $nick :-error- you need to be at least a channel voice in $chan to ban users via this script"}
    }
    return 0
}

proc pVoiceUnban {nick uhost handle chan text} {
    global vVoiceChans
    if {[lsearch -exact [split [string tolower $vVoiceChans]] [string tolower $chan]] != -1} {
        set txt [split [string trim $text]]
        if {[llength $txt] == 1} {
            set host [lindex $txt 0]
            if {([isvoice $nick $chan]) || ([isop $nick $chan])} {
                if {[botisop $chan]} {
                    putserv "MODE $chan -b $host"
                } else {putserv "NOTICE $nick :-error- I need to be op'd in $chan to do that"}
            } else {putserv "NOTICE $nick :-error- you need to be at least a channel voice in $chan to unban hosts via this script"}
        } else {putserv "NOTICE $nick :-error- correct syntax is !unban <host>"}
    }
    return 0
}

proc pVoiceMode {nick uhost handle chan text} {
    global vVoiceChans
    if {[lsearch -exact [split [string tolower $vVoiceChans]] [string tolower $chan]] != -1} {
        set txt [split [string trim $text]]
        if {[llength $txt] == 1} {
            set mode [lindex $txt 0]
            if {([isvoice $nick $chan]) || ([isop $nick $chan])} {
                if {[botisop $chan]} {
                    switch -- [string tolower $mode] {
                        on {putserv "MODE $chan +mi"}
                        off {putserv "MODE $chan -mi"}
                        default {putserv "NOTICE $nick :-error- single text argument can only be on or off"}
                    }
                } else {putserv "NOTICE $nick :-error- I need to be op'd in $chan to do that"}
            } else {putserv "NOTICE $nick :-error- you need to be at least a channel voice in $chan to set modes via this script"}
        } else {putserv "NOTICE $nick :-error- correct syntax is !mode <on||off>"}
    }
    return 0
}

proc pVoiceTopic {nick uhost handle chan text} {
    global vVoiceChans
    if {[lsearch -exact [split [string tolower $vVoiceChans]] [string tolower $chan]] != -1} {
        set txt [split [string trim $text]]
        if {[llength $txt] >= 1} {
            set topic [join [lrange $txt 0 end]]
            if {([isvoice $nick $chan]) || ([isop $nick $chan])} {
                if {[botisop $chan]} {
                    putserv "TOPIC $chan :$topic *- requested by $nick -*"
                } else {putserv "NOTICE $nick :-error- I need to be op'd in $chan to do that"}
            } else {putserv "NOTICE $nick :-error- you need to be at least a channel voice in $chan to set a topic via this script"}
        } else {putserv "NOTICE $nick :-error- correct syntax is !topic <topic>"}
    }
    return 0
}

proc pVoiceVoice {nick uhost handle chan text} {
    global vVoiceChans
    if {[lsearch -exact [split [string tolower $vVoiceChans]] [string tolower $chan]] != -1} {
        set txt [split [string trim $text]]
        if {[llength $txt] == 1} {
            set target [lindex $txt 0]
            if {([isvoice $nick $chan]) || ([isop $nick $chan])} {
                if {[onchan $target $chan]} {
                    if {[botisop $chan]} {
                        switch -- [isvoice $target $chan] {
                            0 {putserv "MODE $chan +v $target"}
                            1 {putserv "MODE $chan -v $target"}
                        }
                    } else {putserv "NOTICE $nick :-error- I need to be op'd in $chan to do that"}
                } else {putserv "NOTICE $nick :-error- $target is not on $chan"}
            } else {putserv "NOTICE $nick :-error- you need to be at least a channel voice in $chan to voice/devoice users via this script"}
        } else {putserv "NOTICE $nick :-error- correct syntax is !voice <nick>"}
    }
    return 0
}

# eof
[/code]
thanks for having solved my problem, I thank you so much. I found an error with the !voice when repeating the same command on the nick voice running the opposite then I set out as follows:
[/code]

# set here the space delimited string of channel(s) that the script is active in
set vVoiceChans "#chan"


bind pub - !voice pVoiceVoice
bind pub - !devoice pdeVoiceVoice
bind pub - !kick pVoiceKick
bind pub - !ban pVoiceBan

set vVoiceVersion v2.0

proc pVoiceKick {nick uhost hand chan text} {
global vVoiceChans
if {[lsearch -exact [split [string tolower $vVoiceChans]] [string tolower $chan]] != -1} {
set txt [split [string trim $text]]
switch -- [llength $txt] {
0 {
putserv "NOTICE $nick :-error- correct syntax is !kick <nick> ?reason?"
return 0
}
1 {set target [lindex $txt 0]}
default {
set target [lindex $txt 0]
set reason [join [lrange $txt 1 end]]
}
}
if {([isvoice $nick $chan]) || ([isop $nick $chan])} {
if {[onchan $target $chan]} {
if {![validuser [nick2hand $target $chan]]} {
if {[botisop $chan]} {
if {[info exists reason]} {
putserv "KICK $chan $target :$reason *- requested by $nick -*)"
} else {putserv "KICK $chan $target :*- requested by $nick -*"}
} else {putserv "NOTICE $nick :-error- I need to be op'd in $chan to do that"}
} else {putserv "NOTICE $nick :-error- $target has a valid bot user record for $chan"}
} else {putserv "NOTICE $nick :-error- $target is not on $chan"}
} else {putserv "NOTICE $nick :-error- you need to be at least a channel voice in $chan to kick users via this script"}
}
return 0
}

proc pVoiceBan {nick uhost hand chan text} {
global vVoiceChans
if {[lsearch -exact [split [string tolower $vVoiceChans]] [string tolower $chan]] != -1} {
set txt [split [string trim $text]]
switch -- [llength $txt] {
0 {
putserv "NOTICE $nick :-error- correct syntax is !ban <nick> ?reason?"
return 0
}
1 {
set target [lindex $txt 0]
}
default {
set target [lindex $txt 0]
set reason [join [lrange $txt 1 end]]
}
}
if {([isvoice $nick $chan]) || ([isop $nick $chan])} {
if {[onchan $target $chan]} {
if {![validuser [nick2hand $target $chan]]} {
if {[botisop $chan]} {
scan [getchanhost $target $chan] {%[^@]@%s} user host
putserv "MODE $chan -o+b $target $host"
if {[info exists reason]} {
putserv "KICK $chan $target :$reason *- requested by $nick -*"
} else {putserv "KICK $chan $target :*- requested by $nick -*"}
} else {putserv "NOTICE $nick :-error- I need to be op'd in $chan to do that"}
} else {putserv "NOTICE $nick :-error- $target has a valid bot user record for $chan"}
} else {putserv "NOTICE $nick :-error- $target is not on $chan"}
} else {putserv "NOTICE $nick :-error- you need to be at least a channel voice in $chan to ban users via this script"}
}
return 0
}

proc pVoiceVoice {nick uhost handle chan text} {
global vVoiceChans
if {[lsearch -exact [split [string tolower $vVoiceChans]] [string tolower $chan]] != -1} {
set txt [split [string trim $text]]
if {[llength $txt] == 1} {
set target [lindex $txt 0]
if {([isvoice $nick $chan]) || ([isop $nick $chan])} {
if {[onchan $target $chan]} {
if {[botisop $chan]} {
switch -- [isvoice $target $chan] {
0 {putserv "MODE $chan +v $target"}
}
} else {putserv "NOTICE $nick :-error- I need to be op'd in $chan to do that"}
} else {putserv "NOTICE $nick :-error- $target is not on $chan"}
} else {putserv "NOTICE $nick :-error- you need to be at least a channel voice in $chan to voice/devoice users via this script"}
} else {putserv "NOTICE $nick :-error- correct syntax is !voice <nick>"}
}
return 0
}

proc pdeVoiceVoice {nick uhost handle chan text} {
global vVoiceChans
if {[lsearch -exact [split [string tolower $vVoiceChans]] [string tolower $chan]] != -1} {
set txt [split [string trim $text]]
if {[llength $txt] == 1} {
set target [lindex $txt 0]
if {([isvoice $nick $chan]) || ([isop $nick $chan])} {
if {[onchan $target $chan]} {
if {[botisop $chan]} {
switch -- [isvoice $target $chan] {
1 {putserv "MODE $chan -v $target"}
}
} else {putserv "NOTICE $nick :-error- I need to be op'd in $chan to do that"}
} else {putserv "NOTICE $nick :-error- $target is not on $chan"}
} else {putserv "NOTICE $nick :-error- you need to be at least a channel voice in $chan to voice/devoice users via this script"}
} else {putserv "NOTICE $nick :-error- correct syntax is !devoice <nick>"}
}
return 0
}

# eof

I also happen the same conquest Autovoice list script like 'does not add the nick with characters such as [Nick] or {nick} the script is this:

Code: Select all

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #                                                                         # #
#                 avl (autovoicelist) - Script v1.0 by stylus740              # 
# #                                                                         # #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #


###############################################################################
# History:                                                                    #
# 1.0		Erstes Release                                                    #
###############################################################################

##
# verwaltet eine Liste von Nicks, die im Channel autovoice erhalten
##

# In welchen Channels soll das Script aktiv sein? 
# Die Definition erfolgt durch Setzen von +avl in der Partyline im Bot
#
# .chanset #channel +avl

# Definition des Datenfiles für berechtigte User

set avl_ni(datafile) "scripts/avl.dat"

###############################################################################
# Mögliche Befehle in der Partyline:							#
#													#
# .chanset #chan +avl		Aktivierung des scripts in Channel #chan		#
# .chanset #chan -avl		Deaktivierung des scripts in Channel #chan	#
# .avlhelp				Hilfen zur Bedienung					#
# .addvoice nick			User zur Liste hinzufügen				#
# .delvoice nick			User von Liste löschen					#
# .listvoice			Einträge anzeigen						#
###############################################################################

### Ab hier nur editieren, wenn man genau weiß, was man tut. Beginn des Codes ###

setudef flag avl								;# Zur Aktivierung der userdefined flags
set avl_ni(version) v1.0						;# Variable für Version setzten

bind dcc n|n addvoice add_users					;# User hinzufügen
bind dcc n|n delvoice del_users					;# User hinzufügen
bind dcc n|n listvoice list_users					;# User anzeigen
bind dcc n|n avlhelp help_users					;# Hilfe anzeigen
bind msg n|n addvoice m_add_users					;# User hinzufügen
bind msg n|n delvoice m_del_users					;# User hinzufügen
bind msg n|n listvoice m_list_users					;# User anzeigen
bind msg n|n avlhelp m_help_users					;# Hilfe anzeigen
bind join - * join:avl_check
bind nick - * nick:avl_check

proc help_users {handle idx args} {
putlog "avl ermöglicht es Usern, die von einer berechtigten Person in einer Liste gespeichert sind"
putlog "auto-voice durch den Bot erteilen zu lassen. (Nützlich in Support Channels, wo oft User nicht"
putlog "registriert sind."
putlog "Die Steuerung von avl erfolgt über die Partyline mit den folgenden Befehlen:"
putlog " "
putlog ".addvoice <nick> <chan>        Nick mit Channel hinzufügen oder ändern"
putlog ".delvoice <nick> <chan>        Den angegebenen Nick löschen"
putlog ".listvoice		         Sämtliche berechtigten User-Einträge anzeigen"
putlog ".avlhelp      	               Diese Hilfemeldung anzeigen"
}

proc m_help_users {nick host hand args} {
puthelp "PRIVMSG $nick :avl ermöglicht es Usern, die von einer berechtigten Person in einer Liste gespeichert sind"
puthelp "PRIVMSG $nick :auto-voice durch den Bot erteilen zu lassen. (Nützlich in Support Channels, wo oft User nicht"
puthelp "PRIVMSG $nick :registriert sind."
puthelp "PRIVMSG $nick :Die Steuerung von avl erfolgt über ein Query mit dem Bot mit den folgenden Befehlen:"
puthelp "PRIVMSG $nick : "
puthelp "PRIVMSG $nick :/msg <bot> addvoice <nick> <chan>        Nick mit Channel hinzufügen oder ändern"
puthelp "PRIVMSG $nick :/msg <bot> delvoice <nick> <chan>        Den angegebenen Nick löschen"
puthelp "PRIVMSG $nick :/msg <bot> listvoice		           Sämtliche berechtigten User-Einträge anzeigen"
puthelp "PRIVMSG $nick :/msg <bot> avlhelp      	           Diese Hilfemeldung anzeigen"
}

proc init_users {} {
global avl_nick avl_ni					   		;# Datenstrukturen public definieren
if {[file exists $avl_ni(datafile)]} {		   		;# Falls File vorhanden
  putlog "Laden Userdaten aus $avl_ni(datafile)"   		;# Lademeldung
  set in [open $avl_ni(datafile) r]			   		;# Datenfile im read modus öffnen
  while {![eof $in]} {					   		;# solange kein EOF
    set vline [gets $in]                           		;# Zeile holen
    if {[eof $in]} {break}  				   		;# Falls EOF, Ende von while
    set inick [lindex $vline 0]			   		;# Nick extrahieren
    set ichan [lrange $vline 1 end]			   		;# Channel extrahieren
    set ientry "$inick&$ichan"			   		;# Kombination Nick&Chan bauen
    set avl_nick($ientry) $ientry                  		;# Array Datenfeld belegen
    }								   		;# End while
  close $in							   		;# Datei schließen
  }								   		;# End If (dataexist)
}								   		;# End Procedure
init_users

proc list_users {handle idx args} {
global avl_nick avl_ni					   		;# Datenstrukturen public definieren
if {[info exists avl_nick]} {				   		;# Falls Felder definiert sind
  putlog "Eingetragene Nick für avl:"		   		;# Überschrift anzeigen
  foreach search [array names avl_nick] {          		;# Für jeden Eintrag
   if {$search != 0} {					   		;# wenn kein leerer Eintrag
     set acmd [split $search "&"]			   		;# Eintrag bei "&" aufsplitten
     set inick [lindex $acmd 0]			   		;# erstes Argument ist Nick
     set inick [form $inick]				   		;# Nick formatieren
     set ichan [lrange $acmd 1 end]			   		;# Der gesamte Rest ist der Channel
     set ichan [form $ichan]				   		;# Chan formatieren
     putlog "$inick       $ichan"	 	  	   		;# Zeile anzeigen
     }							   		;# End if (search)
    }								   		;# End foreach
  } else {							   		;# Falls keine Struktur vorhanden
    putlog "Keine Daten gespeichert"		   		;# Fehler anzeigen
  }								   		;# End if
}								   		;# End Procedure

proc add_users {handle idx args} {
 global avl_nick avl_ni					   		;# Datenstrukturen public definieren
 set acmd [lindex $args 0]				   		;# Befehlszeile extrahieren
 set inick [lindex $acmd 0]				   		;# erstes Argument ist Nick
 set inick [form $inick]				   		;# Nick formatieren
 set ichan [lrange $acmd 1 end]			   		;# Der gesamte Rest ist der Channel
 set ichan [form $ichan]				   		;# Chan formatieren
 set ientry "$inick&$ichan"				   		;# Kombination Nick&Chan bauen
 set avl_nick($ientry) $ientry                     		;# Array Datenfeld (neu) belegen
 writefile							   		;# Datei schreiben
 putlog "User $inick mit Chan $ichan in $avl_ni(datafile) hinzugefügt"
 if {[onchan $inick $ichan]} {
   pushmode $ichan +v $inick 						;# direkt +v setzen
 }
}								   		;# End Procedure

proc del_users {handle idx args} {
 global avl_nick avl_ni					   		;# Datenstrukturen public definieren
 set acmd [lindex $args 0]				   		;# Befehlszeile extrahieren
 set inick [lindex $acmd 0]				  		;# erstes Argument ist Nick
 set inick [form $inick]				  		;# Nick formatieren
 set ichan [lrange $acmd 1 end]			  		;# Der gesamte Rest ist der Channel
 set ichan [form $ichan]				   		;# Chan formatieren
 set ientry "$inick&$ichan"				   		;# Eintrag nick&chan montieren
 if {([info exists avl_nick($ientry)])} {          		;# wenn der Eintrag existiert 
   unset avl_nick($ientry)				 		;# Array Datenfeld freigeben
   writefile
   putlog "Eintrag $ientry aus $avl_ni(datafile) gelöscht"  ;# Löschmeldung
   } else {							 		;# Falls Nick nicht vorhanden
   putlog "Eintrag $ientry ist nicht gespeichert!"		;# Infomeldung
   }										;# End if (info)
 if {[onchan $inick $ichan]} {
   pushmode $ichan -v $inick 						;# direkt -v setzen
 }
}										;# End Procedure

proc m_list_users {nick host hand args} {
global avl_nick avl_ni					   		;# Datenstrukturen public definieren
if {[info exists avl_nick]} {				   		;# Falls Felder definiert sind
  puthelp "PRIVMSG $nick :Eingetragene Nick für avl:"		;# Überschrift anzeigen
  foreach search [array names avl_nick] {          		;# Für jeden Eintrag
   if {$search != 0} {					   		;# wenn kein leerer Eintrag
     set acmd [split $search "&"]			   		;# Eintrag bei "&" aufsplitten
     set inick [lindex $acmd 0]			  		;# erstes Argument ist Nick
     set inick [form $inick]				   		;# Nick formatieren
     set ichan [lrange $acmd 1 end]			   		;# Der gesamte Rest ist der Channel
     set ichan [form $ichan]				   		;# Chan formatieren
     puthelp "PRIVMSG $nick :$inick       $ichan"	 	;# Zeile anzeigen
     }							   		;# End if (search)
    }								   		;# End foreach
  } else {							   		;# Falls keine Struktur vorhanden
    puthelp "PRIVMSG $nick :Keine Daten gespeichert"		;# Fehler anzeigen
  }								   		;# End if
}								   		;# End Procedure

proc m_add_users {nick host hand args} {
 global avl_nick avl_ni					   		;# Datenstrukturen public definieren
 set acmd [lindex $args 0]				   		;# Befehlszeile extrahieren
 set inick [lindex $acmd 0]				   		;# erstes Argument ist Nick
 set inick [form $inick]				   		;# Nick formatieren
 set ichan [lrange $acmd 1 end]			   		;# Der gesamte Rest ist der Channel
 set ichan [form $ichan]				   		;# Chan formatieren
 set ientry "$inick&$ichan"				   		;# Kombination Nick&Chan bauen
 set avl_nick($ientry) $ientry                     		;# Array Datenfeld (neu) belegen
 writefile							   		;# Datei schreiben
 puthelp "PRIVMSG $nick :User $inick mit Chan $ichan in $avl_ni(datafile) hinzugefügt"
 if {[onchan $inick $ichan]} {
   pushmode $ichan +v $inick 						;# direkt +v setzen
 }
}								   		;# End Procedure

proc m_del_users {nick host hand args} {
 global avl_nick avl_ni					   		;# Datenstrukturen public definieren
 set acmd [lindex $args 0]				   		;# Befehlszeile extrahieren
 set inick [lindex $acmd 0]				  		;# erstes Argument ist Nick
 set inick [form $inick]				  		;# Nick formatieren
 set ichan [lrange $acmd 1 end]			  		;# Der gesamte Rest ist der Channel
 set ichan [form $ichan]				   		;# Chan formatieren
 set ientry "$inick&$ichan"				   		;# Eintrag nick&chan montieren
 if {([info exists avl_nick($ientry)])} {          		;# wenn der Eintrag existiert 
   unset avl_nick($ientry)				 		;# Array Datenfeld freigeben
   writefile
   puthelp "PRIVMSG $nick :Eintrag $ientry aus $avl_ni(datafile) gelöscht"  ;# Löschmeldung
   } else {							 		;# Falls Nick nicht vorhanden
   puthelp "PRIVMSG $nick :Eintrag $ientry ist nicht gespeichert!"		;# Infomeldung
   }										;# End if (info)
 if {[onchan $inick $ichan]} {
   pushmode $ichan +v $inick 						;# direkt -v setzen
 }
}										;# End Procedure

### Bei einem Join wird dann Voice gegeben, wenn der Nick im Datenfile steht

proc join:avl_check {nick uhost handle chan} {
  global botnick avl_nick
  if {![avl:active $chan]} { return 0 } 				;# falscher Channel: nix machen
  set chan [string tolower $chan]					;# Channel in Kleinschreibung
  if ([isop $botnick $chan]) {					;# Wenn Bot im Channel Op hat
    foreach search [array names avl_nick] {		   	;# Liste aller Einträge durchlaufen
      if {$search != 0} {					 	;# wenn kein leerer Eintrag
        set ientry [string tolower $avl_nick($search)]   	;# Eintrag (nick&#chan) extrahieren
        set parts [split $ientry "&"]
        set inick [lindex $parts 0]		   	   		;# Nick extrahieren
        set ichan [lindex $parts 1]		   	   		;# Chan extrahieren
        if {($nick == $inick) && ($chan == $ichan)} {
          pushmode $chan +v $nick 					;# +v setzen
	}  
      }									;# end if search
    } 									;# end for eache
  } else {									;# bot hat gar kein op
    putlog "Habe kein op op und hole es mir neu" 		;# Meldung "kein op"
    putserv "chanserv op $chan $botnick"
  }								   		;# end if (botisop)
}										;# end procedure

proc nick:avl_check {nick uhost handle chan newnick} {
  global botnick avl_nick
  if {![avl:active $chan]} { return 0 } 				;# falscher Channel: nix machen
  set chan [string tolower $chan]					;# Channel in Kleinschreibung
  if ([isop $botnick $chan]) {					;# Wenn Bot im Channel Op hat
    foreach search [array names avl_nick] {		   	;# Liste aller Einträge durchlaufen
      if {$search != 0} {					 	;# wenn kein leerer Eintrag
        set ientry [string tolower $avl_nick($search)]   	;# Eintrag (nick&#chan) extrahieren
        set parts [split $ientry "&"]
        set inick [lindex $parts 0]		   	   		;# Nick extrahieren
        set ichan [lindex $parts 1]		   	   		;# Chan extrahieren
        if {($nick == $inick) && ($chan == $ichan)} {
          pushmode $chan +v $newnick 				;# +v setzen
	}   
      }									;# end if search
    }										;# end foreach
  } else {									;# bot hat gar kein op
    putlog "Habe kein op op und hole es mir neu" 		;# Meldung "kein op"
    putserv "chanserv op $chan $botnick"
  }								   		;# end if (botisop)
}										;# end procedure

proc form {formtext} {							;# Formatierung String
  set t [string trimleft $formtext]					;# führende Leerzeichen entfernen
  set t [string trimright $t]						;# folgende Leerzeichen entfernen
  return $t									;# formatierten String zurückliefern
}

proc writefile {} {
  global avl_nick avl_ni
  set out [open $avl_ni(datafile) w]		  	 	;# Datenfile im w modus öffnen (überschreiben)
  foreach search [array names avl_nick] {			   	;# durchlaufen der Daten arrays
    if {$search != 0} {						   	;# wenn keine leere Zeile
      set parts [split $search "&"]				   	;# Eintrag bei "&" aufsplitten
      set inick [lindex $parts 0]				   	;# Nick extrahieren
      set ichan [lindex $parts 1]				   	;# Channel extrahieren
      set output "$inick $ichan"				   	;# Output montieren
      puts $out $output						   	;# Zeile schreiben
     }							         	;# End if (search)
   }										;# End Foreach
   close $out								;# Datei schließen
}										;# End procedure

proc avl:active {chan} {
  foreach setting [channel info $chan] {				;# "channel info" ist ein TCL Befehl!
    if {[regexp -- {^[\+-]} $setting]} {
      if {$setting == "+avl"} { return 1 }
    }
  }
  return 0
}

putlog "avl (autovoicelist) von stylus740 geladen. (Stand 12.02.05)"
putlog "Eingabe von \.avlhelp bzw. \/msg $botnick avlhelp zeigt Bedienungshinweise an"
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

As I already explained, !voice <target> is a toggle command

If <target> is already voiced, then the command will devoice <target>
If <target> is not already voiced, then the command will voice <target>

Toggle in this context means something that is figuratively switched on/off. Hence, it is not a fault. It is intentional.
c
calippo
Voice
Posts: 13
Joined: Mon Jan 19, 2009 3:53 pm

Post by calippo »

arfer wrote:As I already explained, !voice <target> is a toggle command

If <target> is already voiced, then the command will devoice <target>
If <target> is not already voiced, then the command will voice <target>

Toggle in this context means something that is figuratively switched on/off. Hence, it is not a fault. It is intentional.
tnx for your help :)
Post Reply