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.

irccloud banmask

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
s
simo
Revered One
Posts: 1072
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

tested again it seems to work for

SlMO Sets Mode on #Test to: +b *!*uid306017@id-306017.charlton.irccloud.com

@Cappuccino Sets Mode on #Test to: -b+b *!*uid306017@id-306017.charlton.irccloud.com *!*uid306017@*


but not for

SlMO Sets Mode on #Test to: +b *!*@id-306017.charlton.irccloud.com
@Cappuccino Sets Mode on #Test to: -b *!*@id-306017.charlton.irccloud.com


since last one has ident in host as well wich is the same as having it set with ident as well in other words if possible it would help if it would set ident as well when +b *!*@id-306017.charlton.irccloud.com is set to trigger as well since it has unique id of user in it as well

other than that it seems fine

thank you caesar
Last edited by simo on Tue Jul 24, 2018 3:46 am, edited 1 time in total.
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Nothing happens on:

Code: Select all

SlMO Sets Mode on #Test to: +b *!*@id-306017.charlton.irccloud.com
@Cappuccino Sets Mode on #Test to: -b *!*@id-306017.charlton.irccloud.com 
for two reasons:

#1. If you look at this example you gave earlier (1-2 pages back):

Code: Select all

[19:08] * Joins: OnT (uid1420156@id-140156.ealing.irccloud.com)
[19:10] * user1 sets mode: +b *!*@id-140156.ealing.irccloud.com 
you will notice that the number in uid1420156 is not equal with the number taken from id-140156.ealing.irccloud.com, meaning 1420156 is not equal with 140156.

Is this a copy/paste mistake or something?

#2. From the snippet I posted about Identifying users the user can start with uid (for example uid123456) for regular members and sid (for example sid123456) for paid users, so what should you ban in this case?

When placing a ban on *!*@id-306017.charlton.irccloud.com we can lookup what members match this address but what if it matches multiple members? You didn't want that.

I guess we can lookup what members have uid306017 or sid306017 in their user, but what if it also matches more than one member?

To make it trigger on bans like: *!*@id-306017.charlton.irccloud.com or *!*uid306017@id-306017.charlton.irccloud.com try it with replacing:

Code: Select all

if {[regexp {\d+} $u x]} {
	if {[regexp {id-(\d+).(.*?).irccloud.com} $h - y]} {
		if {[string equal $x $y]} {
			pushmode $ch +b "*!$u@*"
		}
	}
}
with:

Code: Select all

if {[regexp {id-(\d+).(.*?).irccloud.com} $h - x]} {
	foreach n [chanlist $ch] {
		if {[isbotnick $n]} continue
		if {[isop $n $ch] || [isvoice $n $ch] || [validuser [nick2hand $n]]} continue
		scan [getchanhost $n $ch] {%[^@]@%s} user host
		if {[regexp {\d+} $user y]} {		
			if {[string equal $x $y]} {
				pushmode $ch +b "*!$user@*"
			}
		}
	}
}
Or even better can add another regexp that will first check if the user part in the ban matches the sid/uid pattern and set a ban on whatever is there, basically triggering on *!*uid306017@id-306017.charlton.irccloud.com or *!uid306017@1.2.3.4 and setting a ban on *!*uid306017@* or *!uid306017@* respectively instead. So, the code becomes:

Code: Select all

if {[regexp {[su]id\d+} $u]} {
	pushmode $ch +b "*!$u@*"
} elseif {[regexp {id-(\d+).(.*?).irccloud.com} $h - x]} {
   foreach n [chanlist $ch] {
      if {[isbotnick $n]} continue
      if {[isop $n $ch] || [isvoice $n $ch] || [validuser [nick2hand $n]]} continue
      scan [getchanhost $n $ch] {%[^@]@%s} user host
      if {[regexp {\d+} $user y]} {      
         if {[string equal $x $y]} {
            pushmode $ch +b "*!$user@*"
         }
      }
   }
}
Haven't tested anything so let me know the results.
Once the game is over, the king and the pawn go back in the same box.
s
simo
Revered One
Posts: 1072
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

tested it seems to work as intented

tnx caesar much apreciated
g
gamble27
Halfop
Posts: 71
Joined: Tue Aug 05, 2008 7:51 am

Final version

Post by gamble27 »

Hey simo, can I have the final version of this tcl? Much appreciated. Anyone using final version of this please share. Thank you.
s
simo
Revered One
Posts: 1072
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

Code: Select all

## ircCloudBan v.1.0 ##


bind mode - "#% +b" ircCloudBan
bind kick - * ircCloudKick


proc ircCloudBan {nk uh hn ch md banmask} {
      if {![botisop $ch]} return

      if {[string match -nocase "*@*irccloud*" $banmask] && ![regexp {[su]id\d+} $banmask] && ![regexp {id-(\d+).(.*?).irccloud.com} $banmask] && ![string match -nocase "*@*-*-*-*-*irccloud.com" $banmask]} {
                   set ::irccloudban $banmask
                   after [expr {1*1000*60}] [list unset ::irccloudban]
     }

          if {[regexp {[su]id\d+} $banmask] || [regexp {id-(\d+).(.*?).irccloud.com} $banmask] || [string match -nocase "*@*-*-*-*-*irccloud.com" $banmask]} {
   foreach n [chanlist $ch] {
         if {![matchaddr $banmask $n![getchanhost $n $ch]]} { continue }
         if {[isop $n $ch] || [ishalfop $n $ch]} { continue }
         if {[matchattr [nick2hand $n] "fnmo|fnmo" $ch]} { continue }
                 set chost [getchanhost $n $ch]
                   regsub -all -- ~ $chost "" chost
                   set ident  [lindex [split $chost @] 0]
                   set xbmaskx [string map {sid id uid id} $ident]
                   set bmask  *!*[string tolower $xbmaskx ]@*
                   pushmode $ch +b $bmask
                   pushmode  $ch -b $banmask
                   set ::irccloudban2 $banmask
    }
  }
}

 
 

proc ircCloudKick {nk uh hn ch target why} {
 if {[info exists ::irccloudban] || [info exists ::irccloudban2]} {
     if {![botisop $ch]} return
         set chost [getchanhost $target $ch]
        if {[string match -nocase "*@*irccloud*" $chost]} {
        regsub -all -- ~ $chost "" chost
        set ident  [lindex [split $chost @] 0]
        set xbmaskx [string map {sid id uid id} $ident]
        set bmask  *!*[string tolower $xbmaskx ]@*
        pushmode $ch +b $bmask
       if {[info exists ::irccloudban]} { pushmode $ch -b  $::irccloudban }
       after cancel unset ::irccloudban
       if {[info exists ::irccloudban]} { unset ::irccloudban }
    }
  }
}
s
simo
Revered One
Posts: 1072
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

I have been using the above posted code wich works well except for banmasks like

Code: Select all

Nick!*@*.langley.irccloud.com

Or

Nick!*@*.irccloud.com

Wich could be utilized to unset ban and set the proper one without having to wait for the kick as the banmask contains the nick
s
simo
Revered One
Posts: 1072
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

anyway we can use this kind of banmask? as i failed to find a way to add it to be detected when set
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

the script so far

Post by SpiKe^^ »

simo,

Here is a cleaned up copy of your script, with proper indentation so it can be read by others.
I see multiple issues with the code as it stands so far...

Code: Select all

## ircCloudBan v.1.0 ##


bind mode - "#% +b" ircCloudBan
bind kick - * ircCloudKick


proc ircCloudBan {nk uh hn ch md banmask} {
  if {![botisop $ch]} {  return 0  }

  if {[string match -nocase "*@*irccloud*" $banmask] && ![regexp {[su]id\d+} $banmask] && ![regexp {id-(\d+).(.*?).irccloud.com} $banmask] && ![string match -nocase "*@*-*-*-*-*irccloud.com" $banmask]} {
    set ::irccloudban $banmask
    after [expr {1*1000*60}] [list unset ::irccloudban]
  }


  if {[regexp {[su]id\d+} $banmask] || [regexp {id-(\d+).(.*?).irccloud.com} $banmask] || [string match -nocase "*@*-*-*-*-*irccloud.com" $banmask]} {

    foreach n [chanlist $ch] {
      if {![matchaddr $banmask $n![getchanhost $n $ch]]} { continue }
      if {[isop $n $ch] || [ishalfop $n $ch]} { continue }
      if {[matchattr [nick2hand $n] "fnmo|fnmo" $ch]} { continue }

      set chost [getchanhost $n $ch]
      regsub -all -- ~ $chost "" chost
      set ident  [lindex [split $chost @] 0]
      set xbmaskx [string map {sid id uid id} $ident]
      set bmask  *!*[string tolower $xbmaskx ]@*
      pushmode $ch +b $bmask
      pushmode $ch -b $banmask
      set ::irccloudban2 $banmask
    }

  }
}


proc ircCloudKick {nk uh hn ch target why} {
  if {[info exists ::irccloudban] || [info exists ::irccloudban2]} {
    if {![botisop $ch]} {  return 0  }

    set chost [getchanhost $target $ch]
    if {[string match -nocase "*@*irccloud*" $chost]} {

      regsub -all -- ~ $chost "" chost
      set ident  [lindex [split $chost @] 0]
      set xbmaskx [string map {sid id uid id} $ident]
      set bmask  *!*[string tolower $xbmaskx ]@*
      pushmode $ch +b $bmask

      if {[info exists ::irccloudban]} { pushmode $ch -b  $::irccloudban }
      after cancel unset ::irccloudban
      if {[info exists ::irccloudban]} { unset ::irccloudban }

    }
  }
}

SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
s
simo
Revered One
Posts: 1072
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

Ah ok Thanks SpiKe^^
s
simo
Revered One
Posts: 1072
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

edited and tested

Code: Select all


## ircCloudBan v.1.0 ##

bind mode - "#% +b" ircCloudBan
bind kick - * ircCloudKick

proc ircCloudBan {nk uh hn ch md banmask} {
  if {![botisop $ch]} return

  if {[string match -nocase "*@*irccloud*" $banmask] && ![regexp {[\`\^\-\_\\\|\}\{\[\]a-zA-Z0-9]{1,}!(\*)@.*irccloud\.com} $banmask] && ![regexp {[su]id\d+} $banmask] && ![regexp {id-(\d+).(.*?).irccloud.com} $banmask] && || ![regexp {(\*)!(\*)@.*[a-zA-Z0-9\-]+\.[a-zA-Z]+\.irccloud\.com} $banmask]} { 

    set ::irccloudban $banmask
    after [expr {1*1000*60}] [list unset ::irccloudban]
  }

  if {[regexp {[\`\^\-\_\\\|\}\{\[\]a-zA-Z0-9]{1,}!(\*)@.*irccloud\.com} $banmask] || [regexp {[su]id\d+} $banmask] || [regexp {id-(\d+).(.*?).irccloud.com} $banmask] || [regexp {(\*)!(\*)@.*[a-zA-Z0-9\-]+\.[a-zA-Z]+\.irccloud\.com} $banmask]} {

    set userList [chanlist $ch]

    foreach n $userList {

      if {![matchaddr $banmask $n![getchanhost $n $ch]]} { continue }
      if {[isop $n $ch] || [ishalfop $n $ch] || [matchattr [nick2hand $n] "fnmo|fnmo" $ch]} { continue }

      set chost [getchanhost $n $ch]
      regsub -all -- ~ $chost "" chost
      set ident  [lindex [split $chost @] 0]
      set xbmaskx [string map {sid id uid id} $ident]
      set bmask  *!*[string tolower $xbmaskx ]@*
      pushmode $ch +b $bmask
      pushmode $ch -b $banmask
    }
  }
}

proc ircCloudKick {nk uh hn ch target why} {
  set chost [getchanhost $target $ch]

  if {[info exists ::irccloudban] && [matchaddr $::irccloudban $target!$chost]} {
    if {![botisop $ch]} return

    regsub -all -- ~ $chost "" chost
    set ident  [lindex [split $chost @] 0]
    set xbmaskx [string map {sid id uid id} $ident]
    set bmask  *!*[string tolower $xbmaskx ]@*
    pushmode $ch +b $bmask
    pushmode $ch -b  $::irccloudban
    after cancel unset ::irccloudban
    unset ::irccloudban
  }
}

putlog "irccloud.tcl Loaded."

Post Reply