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 

Modify Join/Part TCL

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


Joined: 27 Jan 2022
Posts: 22

PostPosted: Thu Aug 11, 2022 3:59 am    Post subject: Modify Join/Part TCL Reply with quote

Hi folks,

I am using below code for join/part (revolving door). It is working fine, but when multiple nicks join/part, the script also sets the channel mode command multiple times.
Appreciate if anyone can help modify the code in a loop or may be any possible check, so the channel modelock happens only once? May be check the existing channel modes before running a modelock again? Or check existing channel modes every time before running a modelock? Or any other solution that doesn't involve too much lag on the bot. (I still want the bans for each of the join/part nicks)

Thanks in advance.

Code:


set jp(part) 3
set jp(lock_modes) "R"


setudef flag joinpart
bind part - * ban:jp

proc ban:jp {nick uhost hand chan arg} {
  global jp botnick jpchan kickcount logo
  if {[isbotnick $nick] || ![botisop $chan] || ![channel get $chan joinpart]} {
    return
  }
  if {![info exists jpchan($chan)]} {
    set jpchan($chan) 0
  }
  if {($chan == $botnick) || [matchattr $hand b] || [matchattr $hand fom|fom $chan]} {
    return
  }
  if {[getchanjoin $nick $chan] >= [expr {[clock seconds]-$jp(part)}]} {
    if {$jp(style) == "1"} {
   set banmask [jp:banmask $uhost $nick]
      putquick "MODE $chan +$jp(lock_modes)b $banmask"
      putserv "KICK $chan $nick :$jp(reason) $kickcount $logo"
      putlog "JoinPart: Flood Attempt on $chan ($banmask) banned on the channel"
      timer $jp(unlock) [list putquick "MODE $chan -$jp(lock_modes)"]
    }
    if {$jp(style) == "2"} {
   set banmask [jp:banmask $uhost $nick]
      putquick "MODE $chan +$jp(lock_modes)b $banmask"
      putserv "KICK $chan $nick :$jp(reason) $kickcount $logo"
      putlog "JoinPart: Flood Attempt on $chan ($banmask) added in the channel banlist"
      newchanban "$chan" "$banmask" "JoinPart" "$jp(reason)" "$jp(btime)"
      timer $jp(unlock) [list putquick "MODE $chan -$jp(lock_modes)"]
    }
    if {$jp(style) == "3"} {
    set banmask [jp:banmask $uhost $nick]
      putquick "MODE $chan +$jp(lock_modes)b $banmask"
      putserv "KICK $chan $nick :$jp(reason) $kickcount $logo"
      putlog "JoinPart: Flood Attempt on $chan ($banmask) added in the global banlist"
      newban "$banmask" "JoinPart" "$jp(reason)" "$jp(btime)"
      timer $jp(unlock) [list putquick "MODE $chan -$jp(lock_modes)"]
    }
  }
}

proc jp:banmask {uhost nick} {
 global jpban_type
  switch -- $jpban_type {
   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
  }
}
Back to top
View user's profile Send private message
mvp1
Voice


Joined: 27 Jan 2022
Posts: 22

PostPosted: Thu Aug 11, 2022 10:14 pm    Post subject: Reply with quote

I have made below changes to above to check for +R modelock check, but the mode check check seems to be too slow when 2-3 nicks do revolving/join-part at the same time and the bot still does the modelocks multiple times.
Any solutions, suggestions please?


Modified Code:

Code:

  if {[getchanjoin $nick $chan] >= [expr {[clock seconds]-$jp(part)}]} {
    if {$jp(style) == "1"} {
   set banmask [jp:banmask $uhost $nick]
   if {![string match *R* [lindex [getchanmode $chan] 0]]} {
   putquick "MODE $chan +$jp(lock_modes)b $banmask"
   timer $jp(unlock) [list putquick "MODE $chan -$jp(lock_modes)"]
   }
      putquick "MODE $chan +b $banmask"
      putserv "KICK $chan $nick :$jp(reason) $kickcount $logo"
      putlog "JoinPart: Flood Attempt on $chan ($banmask) banned on the channel"
#      timer $jp(unlock) [list putquick "MODE $chan -$jp(lock_modes)"]
    }


Below is the example even after above modified code.

Code:


→ NOONECANSTOPME_}_ joined (~ipr@4ea-8986-f438-9e7b-dce3.83.170.ip)
5:04 AM ← NOooo_}_ left (~ipr@4ea-8986-f438-9e7b-dce3.83.170.ip)
5:04 AM → NOONooo_ joined (~ipr@4ea-8986-f438-9e7b-dce3.83.170.ip)
5:04 AM → noooodsdooo joined (~ybcb@a5e3-836e-d488-e7b3-1c66.111.192.ip)
5:04 AM ← nooooasdjdsad left (~ybcb@a5e3-836e-d488-e7b3-1c66.111.192.ip)
5:04 AM → asdsadsadsa joined (~ybcb@a5e3-836e-d488-e7b3-1c66.111.192.ip)
5:04 AM ← dasdsadsadsa left (~ybcb@a5e3-836e-d488-e7b3-1c66.111.192.ip)
5:04 AM •Bot banned *!*@4ea-8986-f438-9e7b-dce3.83.170.ip (+b)
5:04 AM Channel mode set to +R by •Bot
5:04 AM •Bot banned *!*@a5e3-836e-d488-e7b3-1c66.111.192.ip (+b)
5:04 AM Channel mode set to +R by •Bot
5:04 AM ← Nooonasdndsadn_ left (~ipr@4ea-8986-f438-9e7b-dce3.83.170.ip)


Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 980

PostPosted: Fri Aug 12, 2022 4:59 pm    Post subject: Reply with quote

try this :

Code:

set jp(part) 3
set jp(lock_modes) "R"


setudef flag joinpart
bind part - * ban:jp

proc ban:jp {nick uhost hand chan arg} {
  global jp botnick jpchan kickcount logo
  if {[isbotnick $nick] || ![botisop $chan] || ![channel get $chan joinpart]} {
    return
  }
  if {![info exists jpchan($chan)]} {
    set jpchan($chan) 0
  }
  if {[matchattr $hand b] || [matchattr $hand fom|fom $chan]} {
    return
  }
  if {[getchanjoin $nick $chan] >= [expr {[clock seconds]-$jp(part)}]} {
    if {$jp(style) == "1"} {
   set banmask [jp:banmask $uhost $nick]
         jp:lockchan $chan
       pushmode $chan +b $banmask
      putserv "KICK $chan $nick :$jp(reason) $kickcount $logo"
      putlog "JoinPart: Flood Attempt on $chan ($banmask) banned on the channel"
    }
    if {$jp(style) == "2"} {
   set banmask [jp:banmask $uhost $nick]
         jp:lockchan $chan
      pushmode $chan +b $banmask    
      putserv "KICK $chan $nick :$jp(reason) $kickcount $logo"
      putlog "JoinPart: Flood Attempt on $chan ($banmask) added in the channel banlist"
      newchanban "$chan" "$banmask" "JoinPart" "$jp(reason)" "$jp(btime)"
    }
    if {$jp(style) == "3"} {
    set banmask [jp:banmask $uhost $nick]
      jp:lockchan $chan
      pushmode $chan +b $banmask
      putserv "KICK $chan $nick :$jp(reason) $kickcount $logo"
      putlog "JoinPart: Flood Attempt on $chan ($banmask) added in the global banlist"
      newban "$banmask" "JoinPart" "$jp(reason)" "$jp(btime)"
    }
    flushmode $chan
  }
}

proc jp:banmask {uhost nick} {
 global jpban_type
  switch -- $jpban_type {
   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
  }
}




proc jp:lockchan {chan} {
  global lock_channel jp
  if {![info exists lock_channel($chan)]} {
     putnow "mode $chan +$jp(lock_modes)" 
    timer $jp(unlock) [list putquick "MODE $chan -$jp(lock_modes)"]
    set lock_channel($chan) 1
    utimer 10 [list unset -nocomplain ::lock_channel($chan)]
  }
}



Last edited by simo on Mon Aug 15, 2022 9:33 pm; edited 1 time in total
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 980

PostPosted: Fri Aug 12, 2022 5:12 pm    Post subject: Reply with quote

on wich network / ircd version are u running this ?
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 980

PostPosted: Fri Aug 12, 2022 5:36 pm    Post subject: Reply with quote

you might want to set channel mode like +j 2:2 that helps as well

Last edited by simo on Thu Sep 01, 2022 6:45 am; edited 4 times in total
Back to top
View user's profile Send private message
mvp1
Voice


Joined: 27 Jan 2022
Posts: 22

PostPosted: Sat Aug 13, 2022 4:51 am    Post subject: Reply with quote

Hi Simo,

On DALnet mate, eggdrop 1.8.3

simo wrote:
on wich network / ircd version are u running this ?
Back to top
View user's profile Send private message
mvp1
Voice


Joined: 27 Jan 2022
Posts: 22

PostPosted: Sat Aug 13, 2022 4:53 am    Post subject: Reply with quote

Thanks Simo, I'm testing this. Seems to be working in principle, but will have to see how quick it reacts during flood and does the job.

Thanks again mate Smile
Back to top
View user's profile Send private message
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