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 

irccloud banmask
Goto page Previous  1, 2, 3, 4
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
simo
Owner


Joined: 22 Mar 2015
Posts: 969

PostPosted: Tue Jul 24, 2018 3:33 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3743
Location: Mint Factory

PostPosted: Tue Jul 24, 2018 3:42 am    Post subject: Reply with quote

Nothing happens on:
Code:

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:

[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:

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

with:
Code:

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:

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.
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 969

PostPosted: Tue Jul 24, 2018 7:34 am    Post subject: Reply with quote

tested it seems to work as intented

tnx caesar much apreciated
Back to top
View user's profile Send private message
gamble27
Halfop


Joined: 05 Aug 2008
Posts: 71

PostPosted: Wed Jun 03, 2020 1:48 pm    Post subject: Final version Reply with quote

Hey simo, can I have the final version of this tcl? Much appreciated. Anyone using final version of this please share. Thank you.
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 969

PostPosted: Sat Oct 22, 2022 1:17 pm    Post subject: Reply with quote

Code:

## 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 }
    }
  }
}
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 969

PostPosted: Sun Oct 23, 2022 2:54 am    Post subject: Reply with quote

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

Code:

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
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 969

PostPosted: Sun Oct 23, 2022 10:56 am    Post subject: Reply with quote

anyway we can use this kind of banmask? as i failed to find a way to add it to be detected when set
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 809
Location: Tennessee, USA

PostPosted: Mon Oct 24, 2022 9:13 am    Post subject: the script so far Reply with quote

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:

## 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
.
Back to top
View user's profile Send private message Visit poster's website
simo
Owner


Joined: 22 Mar 2015
Posts: 969

PostPosted: Mon Oct 24, 2022 11:33 am    Post subject: Reply with quote

Ah ok Thanks SpiKe^^
Back to top
View user's profile Send private message
simo
Owner


Joined: 22 Mar 2015
Posts: 969

PostPosted: Mon Nov 07, 2022 10:27 am    Post subject: Reply with quote

edited and tested

Code:


## 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."

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
Goto page Previous  1, 2, 3, 4
Page 4 of 4

 
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