| View previous topic :: View next topic |
| Author |
Message |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Thu Jun 09, 2016 2:43 am Post subject: enforce bans / kicks on all common channels |
|
|
greetings i was wondering if this enforceban / enforce kick script be modified to set a ban or kick on all common channels the bot is sitting in and the kicked/banned user
| Code: | bind mode - "* +b" enforcebans
proc enforcebans {nick uhost hand chan mc ban} {
foreach n [chanlist $chan] {
if {[string match -nocase $ban $n![getchanhost $n $chan]]} {
if {![botisop $chan]} { return 0 }
if {[isop $n $chan]} { return 0 }
if {[ishalfop $n $chan]} { return 0 }
if {[matchattr [nick2hand $n] fnmo|fnmo $chan]} { return 0 }
if {[isbotnick $n]} { return 0}
putkick $chan $n "Ban $ban matches: $n (You Are Banned ) "
}
}
}
bind kick - "*" my:kick
kick extractor
proc my:kick {n u h c p t} {
set dbname [strftime %Y]
if {$p == $::botnick} {
putquick "CS INVITE $c" -next
putquick "JOIN $c" -next
putquick "PRIVMSG $c :$dbname [strftime "|%d.%m.%Y / %H:%M:%S|"] $p kicked from $c by ${n}: $t" -next
}
return
}
|
|
|
| Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Mon Jun 13, 2016 8:35 am Post subject: |
|
|
i found this small snippet on forum from speechless could this be integrated in the two snippets i posted
| Code: | proc check:common {nick uhost hand chan text} {
if {![string length [set n [lindex [split $text] 0]]]} {
puthelp "Usage: .common <nick> - please supply nickname ;P"
return
}
foreach c [channels] {
if {[onchan $n $c]} { lappend common $c }
}
if {[info exists common]} {
puthelp "privmsg $chan :My common channels with $n are: [join $common ", "]."
} else {
puthelp "privmsg $chan :I share no common channels with $n."
}
} |
|
|
| Back to top |
|
 |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 221 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Mon Jun 13, 2016 3:37 pm Post subject: |
|
|
your question is that you remove the van
and kick in all channels you kicked,,,, _________________
thanks to that they help, that others learn  |
|
| Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Wed Jun 15, 2016 1:34 pm Post subject: |
|
|
for the kick part i tried this but it gave me error
Tcl error [msg_on_kick]: wrong # args: should be "msg_on_kick nick uhost hand chan arg"
| Code: | bind kick - "* *" msg_on_kick
proc msg_on_kick {nick uhost hand chan arg} {
foreach c [channels] {
if {[onchan $n $c]} { lappend common $c }
}
if {[info exists common]} {
putserv "privmsg $target :Hello 05 $target you where kicked out from 02 $chan by 3 ( $nick ) - with reason 06 ( $reason ) "
} else {
puthelp "privmsg $chan :I share no common channels with $n."
}
}
|
|
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Wed Jun 15, 2016 2:06 pm Post subject: |
|
|
| simo wrote: |
...
Tcl error [msg_on_kick]: wrong # args: should be "msg_on_kick nick uhost hand chan arg"
|
Go to:
http://www.eggheads.org/support/egghtml/1.6.21/tcl-commands.html
and find:
bind kick
to see the correct parameters and number of them, for the proc. _________________ 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 |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Wed Jun 15, 2016 3:24 pm Post subject: |
|
|
the default is like this only i dont know how to integrate it
and make bot kick user from all common channels
| Code: | bind kick - "* *" msg_on_kick
proc msg_on_kick {nick uhost handle chan target reason} {
putserv "privmsg $target :Hello 05 $target you where kicked out from 02 $chan by 3 ( $nick ) - with reason 06 ( $reason ) - for more info please join 12 #help "
}
|
|
|
| Back to top |
|
 |
Get_A_Fix Master

Joined: 07 May 2005 Posts: 206 Location: New Zealand
|
Posted: Wed Jun 15, 2016 7:42 pm Post subject: |
|
|
| simo wrote: | the default is like this only i dont know how to integrate it
and make bot kick user from all common channels
| Code: | bind kick - "* *" msg_on_kick
proc msg_on_kick {nick uhost handle chan target reason} {
putserv "privmsg $target :Hello 05 $target you where kicked out from 02 $chan by 3 ( $nick ) - with reason 06 ( $reason ) - for more info please join 12 #help "
}
|
|
You could use something like this, from your enforceban procedure, to mimic your kick proc
| Code: |
bind mode - "* +b" enforcebans
set accessFlags fnmo|fnmo
proc enforcebans {nick uhost hand chan mc ban} {
global accessFlags
foreach n [chanlist $chan] {
foreach c [channels] {
if {[string match -nocase $ban $n![getchanhost $n $c]]} {
if {![botisop $c] || [isbotnick $n] || [isop $n $c] || [ishalfop $n $c] || [matchattr [nick2hand $n] $accessFlags $c]} {return}
putquick "KICK $c $n :Ban $ban matches: $n (You Are Banned)"
}
}
}
}
|
_________________ We explore.. and you call us criminals. We seek after knowledge.. and you call us criminals. We exist without skin color, without nationality, without religious bias.. and you call us criminals.
Last edited by Get_A_Fix on Mon Jun 20, 2016 7:20 am; edited 1 time in total |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Thu Jun 16, 2016 12:52 am Post subject: |
|
|
Instead of {return} should be continue
What's the point to iterate all channels and kick the user matching the ban mask, when the ban was placed just on a single channel? You know the user can return on the channel he/she was kicked but not banned, right?
Also, you know about the enforcebans channel setting that is doing exactly what you wanted (kick people who match channel bans)? _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Thu Jun 16, 2016 10:45 am Post subject: |
|
|
would it possible to also have it set ban on all channels bot is sitting in as well Get_A_Fix ?
| Code: | bind mode - "* +b" enforcebans
set accessFlags fnmo|fnmo
proc enforcebans {nick uhost hand chan mc ban} {
global accessFlags
foreach n [chanlist $chan] {
foreach c [channels] {
if {[string match -nocase $ban $n![getchanhost $n $c]]} {
if {![botisop $c] && [isbotnick $n] && [isop $n $c] && [ishalfop $n $c] && [matchattr [nick2hand $n] $accessFlags $c]} {return}
putquick "KICK $c $n :Ban $ban matches: $n (You Are Banned)"
}
}
}
} |
|
|
| Back to top |
|
 |
Get_A_Fix Master

Joined: 07 May 2005 Posts: 206 Location: New Zealand
|
Posted: Thu Jun 16, 2016 9:38 pm Post subject: |
|
|
Sure. I didn't know that's what you wanted. There are two ways to approach this, adding a server ban (so your @ and non-bot Ops can remove the ban), or an internal ban (which has to be manually removed from the bot).
For the internal ban, read the ~/eggdrop/doc/tcl-commands.doc form on newchanban or newban. For this example, I'll be using the server side ban.
| Code: |
# In your code you can: set banmask [make:banmask $uhost $nick]
# and then use the ...: putquick "MODE $chan +b $banmask"
# BAN Types are given below;
# 1 - *!*@some.domain.com
# 2 - *!*@*.domain.com
# 3 - *!*ident@some.domain.com
# 4 - *!*ident@*.domain.com
# 5 - *!*ident*@some.domain.com
# 6 - *nick*!*@*.domain.com
# 7 - *nick*!*@some.domain.com
# 8 - nick!ident@some.domain.com
# 9 - nick!ident@*.host.com
set bantype 1
# Set the access flags needed to be exempt
set accessFlags fnmo|fnmo
## Code Base ##
bind mode - "* +b" enforcebans
proc enforcebans {nick uhost hand chan mc ban} {
global accessFlags
foreach n [chanlist $chan] {
foreach c [channels] {
if {[string match -nocase $ban $n![getchanhost $n $c]]} {
if {![botisop $c] || [isbotnick $n] || [isop $n $c] || [ishalfop $n $c] || [matchattr [nick2hand $n] $accessFlags $c]} {return}
set banmask [make:banmask $uhost $nick]
putquick "MODE $c +b $banmask"
putquick "KICK $c $n :Ban $ban matches: $n (You Are Banned)"
}
}
}
}
proc make:banmask {uhost nick} {
global bantype
switch -- $bantype {
1 { set banmask "*!*@[lindex [split $uhost @] 1]" }
2 { set banmask "*!*@[lindex [split [maskhost $uhost] "@"] 1]" }
3 { set banmask "*!*$uhost" }
4 { set banmask "*!*[lindex [split [maskhost $uhost] "!"] 1]" }
5 { set banmask "*!*[lindex [split $uhost "@"] 0]*@[lindex [split $uhost "@"] 1]" }
6 { set banmask "*$nick*!*@[lindex [split [maskhost $uhost] "@"] 1]" }
7 { set banmask "*$nick*!*@[lindex [split $uhost "@"] 1]" }
8 { set banmask "$nick![lindex [split $uhost "@"] 0]@[lindex [split $uhost @] 1]" }
9 { set banmask "$nick![lindex [split $uhost "@"] 0]@[lindex [split [maskhost $uhost] "@"] 1]" }
default { set banmask "*!*@[lindex [split $uhost @] 1]" }
return $banmask
}
}
|
Note: Code edited to reflect what caesar explained. _________________ We explore.. and you call us criminals. We seek after knowledge.. and you call us criminals. We exist without skin color, without nationality, without religious bias.. and you call us criminals.
Last edited by Get_A_Fix on Mon Jun 20, 2016 7:24 am; edited 3 times in total |
|
| Back to top |
|
 |
Get_A_Fix Master

Joined: 07 May 2005 Posts: 206 Location: New Zealand
|
Posted: Thu Jun 16, 2016 9:40 pm Post subject: |
|
|
| caesar wrote: | Instead of {return} should be continue
What's the point to iterate all channels and kick the user matching the ban mask, when the ban was placed just on a single channel? You know the user can return on the channel he/she was kicked but not banned, right?
Also, you know about the enforcebans channel setting that is doing exactly what you wanted (kick people who match channel bans)? |
I always use return, just out of habit and the way I code.
As for enforcebans, which a lot of the core is ok, some is not, so for things like this I try to override the core calls. For example, using bind flud to process flood-chan and other specific events (like this script here). Easier to manage and modify as wanted. _________________ We explore.. and you call us criminals. We seek after knowledge.. and you call us criminals. We exist without skin color, without nationality, without religious bias.. and you call us criminals. |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Fri Jun 17, 2016 1:32 am Post subject: |
|
|
| Code: |
% set elements [list 1 2 3 4 5]
1 2 3 4 5
% foreach ele $elements { if {$ele == 3} { return } else { puts $ele } }
1
2
% foreach ele $elements { if {$ele == 3} { continue } else { puts $ele } }
1
2
4
5
|
Notice the difference in using return and continue?
You are aware that the && in:
| Code: |
if {![botisop $c] && [isbotnick $n] && [isop $n $c] && [ishalfop $n $c] && [matchattr [nick2hand $n] $accessFlags $c]} {return}
|
means if bot is channel operator in channel AND bot is the nick AND nick is channel operator AND nick is halfop AND nick's user matches the global|channel flags you said THEN return. You should use || that means OR not && that means AND. For example:
| Code: |
% foreach ele $elements { if {$ele == 3 && $ele == 5} { continue } else { puts $ele } }
1
2
3
4
5
% foreach ele $elements { if {$ele == 3 || $ele == 5} { continue } else { puts $ele } }
1
2
4
|
Notice the difference? he wants to exclude ANY of the matching cases, not the case that would match ALL of the tests.
Here's my take on this. Did some limited testing and works fine. I used putkick as it puts multiple names in the same line thus doesn't flood the server with multiple requests to kick a single member per line.
| Code: |
namespace eval enforceBans {
# How many members can be kicked in the same line
set enforce(max) "6"
# Define the reason. Notice the %ban that will be replaced with the actual mask.
# You can use %nick as well and will also be replaced with the actual name of the user who set the ban.
set enforce(reason) "Ban %ban set in %chan matches your host. You are banned!"
bind mode - "% +b" [namespace current]::enforce
proc enforce {nick uhost hand chan mc ban} {
variable enforce
foreach c [channels] {
if {![botisop $c]} continue
foreach n [lreplace [chanlist $c] 0 0] {
if {![string match -nocase $ban $n![getchanhost $n $c]]} continue
if {[isop $n $c] || [ishalfop $n $c] || [matchattr [nick2hand $n] "fnmo|fnmo" $c]} continue
lappend kickList($c) $n
}
}
foreach c [array names kickList] {
set len [llength $kickList($c)]
if {![string equal -nocase $c $chan]} {
pushmode $c +b $ban
}
while {$len > 0} {
if {$len > $enforce(max)} {
set users [join [lrange $kickList($c) 0 [expr {$enforce(max) - 1}]] ,]
set kickList($c) [lrange $kickList($c) $enforce(max) end]
incr len - $enforce(max)
} else {
set users [join $kickList($c) ,]
set len 0
}
set reason [string map [list "%chan" $chan "%ban" $ban "%nick" $nick] $enforce(reason)]
putkick $c $users $reason
}
}
}
}
|
When setting X bans on the same line the bot will trigger a bind mode - "% +b" proc X times for each ban mask, but will trigger a mode - "% -b" proc only once per 6 bans (or whatever is the max amount of bans per line the server you are connected allows) when removing bans. Honestly I fail to understand the logic behind this difference. _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Fri Jun 17, 2016 9:15 am Post subject: |
|
|
| I tried your version caesar it works fine if user is in common channels as eggbot. Is it possible to set ban anyway on all channels bot sits in even if banned nick isnt there to prevent him from joining and continuing the abuse |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Fri Jun 17, 2016 10:08 am Post subject: |
|
|
So now you want the bot to "copy" all bans on all the channels the bot is a channel operator, and top of that enforce the kicking of any members that would match the new banned mask?
If yes then try this and let me know how things work, cos I haven't tested anything this time.
| Code: |
namespace eval enforceBans {
# How many members can be kicked in the same line
set enforce(max) "6"
# Define the reason. Notice the %ban that will be replaced with the actual mask.
# You can use %who as well and will also be replaced with the actual nick of the user who set the ban.
set enforce(reason) "Ban %ban set in %from matches your host. You are banned!"
bind mode - "% +b" [namespace current]::enforce
proc enforce {nick uhost hand chan mc ban} {
variable enforce
set reason [string map [list "%from" $chan "%ban" $ban "%who" $nick] $enforce(reason)]
foreach c [channels] {
if {![botisop $c]} continue
if {![string equal -nocase $c $chan]} {
set match 0
foreach b [chanbans $c] {
if {![string match -nocase $b $ban]} continue
incr match
break
}
if {!$match} {
pushmode $c +b $ban
}
}
foreach n [lreplace [chanlist $c] 0 0] {
if {![string match -nocase $ban $n![getchanhost $n $c]]} continue
if {[isop $n $c] || [ishalfop $n $c] || [matchattr [nick2hand $n] "fnmo|fnmo" $c]} continue
lappend kickList($c) $n
}
if {[info exists kickList($c)]} {
set len [llength $kickList($c)]
while {$len > 0} {
if {$len > $enforce(max)} {
set users [join [lrange $kickList($c) 0 [expr {$enforce(max) - 1}]] ,]
set kickList($c) [lrange $kickList($c) $enforce(max) end]
incr len -$enforce(max)
} else {
set users [join $kickList($c) ,]
set len 0
}
putkick $c $users $reason
}
}
}
}
}
|
Just remember you had a little issue with banlist (discussion in here) and will adopt a similar solution to SpiKe's if will be the case.
While given the requested change we could use a faster queue than pushmode, I would honestly stick with it cos this function will be called for instance 6 times if 6 bans have been set in one line. This way the chances are it will also push all the 6 modes in a single line in other channels. Worth a test anyway.
Edit: 1st bug fix (link). _________________ Once the game is over, the king and the pawn go back in the same box.
Last edited by caesar on Wed May 26, 2021 2:23 am; edited 1 time in total |
|
| Back to top |
|
 |
simo Owner
Joined: 22 Mar 2015 Posts: 941
|
Posted: Fri Jun 17, 2016 11:10 am Post subject: |
|
|
looks to be working good caesar
is it possible to have it also remove ban on all channels if a ban is removed |
|
| Back to top |
|
 |
|