Or if you are making a tcl script, the code to set a channel +enforcebans is.chanset #channel +enforcebans
Code: Select all
channel set #channel +enforcebans
Code: Select all
bind raw - MODE lameness
proc lameness {by args} {
if {[matchattr [finduser $by] n]} {
putserv [join $args]
}
}
user: you write the code of modes is correct , i know it's just for fun modes but i want work in my bot like a human lol thanks for the code user. and how about enforce ban code? hehe *wink*, i'm sorry if i make a problem for asking help.user wrote:you'll need a raw mode bind for the modes to be output the right way (because the modes are split before the command of a mode bind is called and pushmode doesn't do stupid things like setting redundant modes )(not tested - because i'm not on a lame ircd that allows redundant mode changes)Code: Select all
bind raw - MODE lameness proc lameness {by args} { if {[matchattr [finduser $by] n]} { putserv [join $args] } }
The binds triggering the ban enforcement (on join/nick change/mode +b) don't call procs. They call internal commands provided by the channels module that do everything related to joining/nick changes/channel mode changes. If you want to customized enforcement, disable the built in thing and make your own from scratchqwek wrote:and also enforce ban, i already know how to set in partyline and conf. but i wish i can see the real bind/proc for enforce ban.
Code: Select all
setudef flag enforce
bind mode - "% +b" ban:enforce
proc ban:enforce { nick host hand chan mode mask } {
global botnick
if {![channel get $chan enforce]} {
return
}
foreach user [chanlist $chan] {
if {[string match -nocase $mask $user![getchanhost $user]]} {
if {$user == "$botnick"} {
putquick "PRIVMSG $chan :Do not ban me."
} else {
putquick "KICK $chan $user :You are BANNED from this channel."
}
}
}
}
putkick would be better as not all ircds support multiple nicks/kick.awyeah wrote:putserv "KICK $chan awyeah,metroid,elite,god,jesus,hotchick :Banned - lamer detected"
You need to escape the chars that have a special meaning in tcl's glob matching, but are treated like normal characters by the ircd (\[])MeTroiD wrote:Code: Select all
[string match -nocase $mask $user![getchanhost $user]]
Code: Select all
proc my_proc {nick uhost hand chan mode target} {
..........................
................................
.....................................
foreach user [chanlist $chan]
if {([string match -nocase *[lindex [split [getchanhost $user $chan] "@"] 1]* $target])} {
...........................................
....................................
}
}
.........................
}
Code: Select all
set nick [join [split $nick]]
wrong...use the ban as a mask and match against the entire name (nick!user@host) like in MeTroiD's example. That split+join of yours does nothing (apart from wasting some cpu).awyeah wrote:You would have to match each and every *!*@host like:
To escape the chars, you can either use string map, regsub or do a simple split and join on the variable:Code: Select all
proc my_proc {nick uhost hand chan mode target} { .......................... ................................ ..................................... foreach user [chanlist $chan] if {([string match -nocase *[lindex [split [getchanhost $user $chan] "@"] 1]* $target])} { ........................................... .................................... } } ......................... }
Code: Select all
set nick [join [split $nick]]
Code: Select all
proc irc2lower str {
if {${::rfc-compliant}} {
string tolower [string map {[ \{ ] \} \\ |} $str]
} else {
string tolower $str
}
}
Code: Select all
set escaped [join [split [split $string ""]] ""]
Code: Select all
proc banvictims {ban chan} {
set nicks {}
if {${::rfc-compliant}} {
set ban [string tolower [string map {[ \{ ] \} \\ |} $ban]]
foreach nick [chanlist $chan] {
set name [string tolower [string map {[ \{ ] \} \\ |} $nick![getchanhost $nick $chan]]]
if {[string match $ban $name]} {lappend nicks $nick}
}
} else {
set ban [string tolower [string map {[ \\[ ] \\] \\ \\\\} $ban]]
foreach nick [chanlist $chan] {
set name [string tolower $nick![getchanhost $nick $chan]]
if {[string match $ban $name]} {lappend nicks $nick}
}
}
set nicks
}