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 Exception

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


Joined: 07 Jul 2020
Posts: 15

PostPosted: Sun Nov 13, 2022 4:27 pm    Post subject: IRCCloud Exception Reply with quote

Hello All!

Recently, I have been getting a lot of spam from IRCCloud as they have static IPs and it is impossible to detect it as a proxy or VPN connection.

That's why I am looking for a TCL that adds specific nicknames or hostnames to the IRCCloud exception list so the rest of the IRCCloud users can be kicked or banned until they are added to the IRCCloud exception list.

For this filter, I would choose hostnames as they are more static than nicknames. Something in this format;
uid*****@uid*****.irccloud.com


If someone could help, I would be grateful.
_________________
Nepal chat
India chat
Pakistan chat
Indian chat
Back to top
View user's profile Send private message Visit poster's website
SpiKe^^
Owner


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

PostPosted: Tue Nov 15, 2022 7:00 pm    Post subject: cloudGuard version 0.1 Reply with quote

TimeRider,

Try this untested code, inspired by: GuardChan by JamesOff

List your trusted hostmasks in cg(goodlist) like this:
set cg(goodlist) { *!uid569209@* *!~uid321317@* *!uid587206@* *!uid682486@* }

!! Add +cloudguard to channel(s) you want to protect: .chanset #channel +cloudguard

Code:

##########  cloudGuard version 0.1 by SpiKe^^  (15Nov2022)  ##########

##  !! Add +cloudguard to channel(s) you want to protect:  .chanset #channel +cloudguard  ##

namespace eval clouded {   variable cg


##### begin settings #####

#
set cg(badlist) { *!uid*@* *!~uid*@* }

#
set cg(goodlist) {  }



# Set to 1 to ban users from the channel.  (0 = no ban)
set cg(doban) 0

# Set to 1 to kick users from the channel.  (0 = no kick)
set cg(dokick) 1

# Set the nick to get progress messages.  ("" = don't send messages)
set cg(owner) ""


###### end settings ######


bind join - * [namespace current]::cloudguard_join

setudef flag cloudguard


set cg(badlist)  [split [string trim $cg(badlist)]]
set cg(goodlist) [split [string trim $cg(goodlist)]]
if {$cg(doban)  != 0} {  set cg(doban)  1  }
if {$cg(dokick) != 0} {  set cg(dokick) 1  }
set cg(owner) [string trim $cg(owner)]


proc cloudguard_join {nk uh hn ch} {   variable cg
  if {[isbotnick $nk] || ![channel get $ch cloudguard]} {  return 0  }
  if {$hn ne "*"} {  return 0  }   ;# exempt everyone with a handle #

  if {![botisop $ch]} {
    if {$cg(owner) ne ""} {
      puthelp "PRIVMSG $cg(owner) :HELP! I do not have ops in $ch  ($nk has joined)."
    }
    return 0
  }
  if {![llength $cg(badlist)]} {
    if {$cg(owner) ne ""} {
      puthelp "PRIVMSG $cg(owner) :The cg(badlist) setting is empty! cloudGuard script disabled."
    }
    return 0
  }

  set isbad 0  ;  set nkuh "$nk!$uh"
  foreach m $cg(badlist) {
    if {[matchaddr $m $nkuh]} {  set isbad 1  ;  break  }
  }
  if {$isbad == 0} {  return 0  }

  foreach m $cg(goodlist) {
    if {[matchaddr $m $nkuh]} {  return 0  }
  }


  if {$cg(doban) > 0} {
    set usr [split $uh "@"]
    pushmode $ch +b "*!${usr}@*"
    if {$cg(owner) ne ""} {
      puthelp "PRIVMSG $cg(owner) :Kicked $nk from $ch"
    }
  }

  if {$cg(dokick) > 0} {
    putkick $ch $nk
    if {$cg(owner) ne ""} {
      puthelp "PRIVMSG $cg(owner) :Banned $nk from $ch"
    }
  }

  return 0
}

putlog "Loaded cloudGuard version 0.1"

}  ;## end of:  namespace eval ##


_________________
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
TimeRider
Voice


Joined: 07 Jul 2020
Posts: 15

PostPosted: Thu Nov 17, 2022 2:55 pm    Post subject: Reply with quote

SpiKe^^, Thank you for the script. The tcl script works great!

But is it possible to make
1. # Set the nick to get progress messages. ("" = don't send messages)

That it also sends the ident and hostname of the kicked/banned user?

2. ##### begin settings #####

#
set cg(badlist) { *!uid*@* *!~uid*@* }

#
set cg(goodlist) { }

Instead of this, if it is possible to make .txt list file?

Thanks again! Smile
_________________
Nepal chat
India chat
Pakistan chat
Indian chat
Back to top
View user's profile Send private message Visit poster's website
SpiKe^^
Owner


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

PostPosted: Thu Nov 24, 2022 1:30 pm    Post subject: cloudGuard v. 0.2 - 25Nov2022 Reply with quote

TimeRider

All of the public commands now function fine, but all still need work.

See if this addresses your two option requests...

Note: This code edited once on 25Nov2022

Code:

##########  cloudGuard version 0.2 by SpiKe^^  (cg.tcl)  25Nov2022  ##########


######  cloudGuard Public Commands (eggdrop userfile flags ofn|ofn):  ######
##
##  !cg on               :Enable cloudGuard in this channel
##  !cg off              :Disable cloudGuard in this channel
##
##  !cg +bad <mask(s)>   :Add badMasks to the badList
##  !cg +good <mask(s)>  :Add goodMasks to the goodList
##  !cg -bad <mask(s)>   :Remove badMasks from the badList
##  !cg -good <mask(s)>  :Remove goodMasks from the goodList
##
##  !cg lbad             :List the badMasks in the badList
##  !cg lgood            :List the goodMasks in the goodList


## Note:  Add <mask(s)> can be full irc nk!usr@host masks or any part of that.
##        Masks without a ! or @ will be treated as a nick mask  (nick!*@*).
##        All other masks are referenced by the location(s) of the ! and/or @.
##  Examples:
##  !cguard addbad bart      :adds the badMask:     bart!*@*
##  !cg +bad tom jerry       :adds the badMasks:    tom!*@*  &  jerry!*@*
##  !cg +b @*.irccloud.com   :adds the badMask:     *!*@*.irccloud.com
##  !cg +b !uid* ~uid*@*     :adds the badMasks:    *!uid*@* *!~uid*@*
##  !cg +good !~george       :adds the goodMask:    *!~george@*
##  !cg +g uid487201@        :adds the goodMask:    *!uid487201@*


namespace eval cloudguard {   variable cg



########### begin settings ###########


# Set to 1 to ban users from the channel.  (0 = no ban)
set cg(doban) 0

# Set to 1 to kick users from the channel.  (0 = no kick)
set cg(dokick) 1

# Set one nick to get progress messages.  ("" = don't send messages)
set cg(owner) ""


############ end settings ############ end settings ############


setudef flag [string trim [namespace current] :]

###################################
###### Public admin commands ######

bind pubm ofn|ofn "#% !cg*" [namespace current]::cg_onpub
bind pubm ofn|ofn "#% !cloud*" [namespace current]::cg_onpub

proc cg_onpub {nk uh hn ch tx} {   variable cg
  set tx [regsub -all -- {\s{2,}} [string trim $tx] { }]
  set argls [lassign [split $tx] cmd opt]
  if {[string tolower $cmd] ni {!cg !cguard !cloud !cloudg !cloudguard}} { return 0 }
  set o [string tolower $opt]
  set uflag [string trim [namespace current] :]
#putlog "proc cg_onpub:: uflag=($uflag)"

  if       {$o in {+bad +b addbad addb}}   {   set y "+"  ;  set x "b"
  } elseif {$o in {+good +g addgood addg}} {   set y "+"  ;  set x "g"
  } elseif {$o in {-bad -b delbad delb}}   {   set y "-"  ;  set x "b"
  } elseif {$o in {-good -g delgood delg}} {   set y "-"  ;  set x "g"
  } elseif {$o in {lbad lb listbad listb}} {   set y "l"  ;  set x "b"
  } elseif {$o in {lgood lg listgood listg}} { set y "l"  ;  set x "g"

  } elseif {$o in {on}} {
    if {[channel get $ch $uflag]} {
      puthelp "PRIVMSG $ch :The cloudGuard script is already enabled on $ch"
    } else {   channel set $ch +$uflag
      puthelp "PRIVMSG $ch :The cloudGuard script is now enabled on $ch"
    }
    return 0
  } elseif {$o in {off}} {
    if {![channel get $ch $uflag]} {
      puthelp "PRIVMSG $ch :The cloudGuard script is already disabled on $ch"
    } else {   channel set $ch -$uflag
      puthelp "PRIVMSG $ch :The cloudGuard script is now disabled on $ch"
    }
    return 0
  }

  if {[info exists x]} {
    if {![channel get $ch $uflag]} {  return 0  }

    if {$x eq "b"} {  set z "bad"  } else {  set z "good"  }
    if {$y eq "+" || $y eq "-"} {
      if {![llength $argls]} {
        puthelp "PRIVMSG $ch :Command syntax:  \002!cg $o <mask(s)>\002"
        return 0
      }
      ###### ADD Masks ######
      if {$y eq "+"} {   set addls {}  ;   set err {}  ;   set e2 {}
        foreach m $argls {   set m [regsub -all -- {\*{2,}} $m "*"]
          if {[matchstr *!*!* $m] || [matchstr *@*@* $m] || $m eq "*"} {  lappend err $m

          } else {   set m2 $m    ;# fix/complete partial addMasks #
            if {![string match {*[!@]*} $m]} {  append m2 "!"  }

            set nuhls [split $m2 "!@"]
            if {![matchstr *!* $m2]} {   set n ""  ;   lassign $nuhls u h
            } else {   lassign $nuhls n u h   }

            foreach p {n u h} {   if {[set $p] eq ""} { set $p "*" }   }
            set m2 ${n}!${u}@$h

            if {$m2 eq "*!*@*"} {   lappend err $m
            } else {
              if {[lsearch -nocase -exact $cg(_${x}list) $m2] >= 0} {  lappend e2 $m2
              } else {   lappend addls $m2  ;   lappend cg(_${x}list) $m2  }
            }
          }
        }  ;# end of foreach #

        if {[set len [llength $addls]] > 0} {   cg_savefile $x   ;# update the file #
          if {$len > 1} {  set tm "${z}Masks"  } else {  set tm "${z}Mask"  }
          puthelp "PRIVMSG $ch :<cloudGuard> Added $len new ${tm}: [join $addls]"
        }
        if {[set len [llength $err]] > 0} {
          if {$len > 1} {  set tm "${z}Masks"  } else {  set tm "${z}Mask"  }
          puthelp "PRIVMSG $ch :<cloudGuard Error> Found $len invalid ${tm}: [join $err]"
        }
        if {[set len [llength $e2]] > 0} {
          if {$len > 1} {  set tm "$len ${z}Masks"  } else {  set tm "one ${z}Mask"  }
          puthelp "PRIVMSG $ch :<cloudGuard Error> Found ${tm} already listed: [join $e2]"
        }
        return 0
      }  ;# end if is + #
      ######

      ###### DEL Masks ######
      if {$y eq "-"} {   set dells {}  ;   set err {}
        if {![llength $cg(_${x}list)]} {
          puthelp "PRIVMSG $ch :<cloudGuard> The ${z}List is empty."
          return 0
        }

        foreach m $argls {
          if {[set id [lsearch -nocase -exact $cg(_${x}list) $m]] < 0} {  lappend err $m
          } else {   lappend dells $m
            set cg(_${x}list) [lreplace $cg(_${x}list) $id $id]
          }
        }

        if {[set len [llength $dells]] > 0} {   cg_savefile $x   ;# update the file #
          if {$len > 1} {  set tm "$len ${z}Masks"  } else {  set tm "one ${z}Mask"  }
          puthelp "PRIVMSG $ch :<cloudGuard> Removed ${tm}: [join $dells]"
        }
        if {[set len [llength $err]] > 0} {
          if {$len==1} { set tm "One ${z}Mask doesn't" } { set tm "$len ${z}Masks don't" }
          puthelp "PRIVMSG $ch :<cloudGuard Error> ${tm} exist: [join $err]"
        }
        return 0
      }  ;# end if is - #
      ######

    }  ;# end if  $y eq "+" || $y eq "-" #

    ###### LIST Masks ######
    if {$y eq "l"} {   set cls $cg(_${x}list)
      if {[set len [llength $cls]] == 0} {
        puthelp "PRIVMSG $ch :<cloudGuard> The ${z}List is empty."
        return 0
      }

      if {$len > 1} {  set tm "$len ${z}Masks"  } else {  set tm "One ${z}Mask"  }
      puthelp "PRIVMSG $ch :<cloudGuard> ${tm} in the list: [join $cls]"


      return 0
    }  ;# end if is l #
    ######

  }  ;# end if info exists x #
  return 0
}


##################################
###### Onjoin user checking ######

bind join - * [namespace current]::cg_onjoin

proc cg_onjoin {nk uh hn ch} {   variable cg
  if {[isbotnick $nk] || ![channel get $ch [string trim [namespace current] :]]} { return 0 }
  if {$hn ne "*"} {  return 0  }   ;# exempt everyone with a handle #

  if {![botisop $ch]} {
    if {$cg(owner) ne ""} {
      puthelp "PRIVMSG $cg(owner) :HELP! $nk ($uh) has joined $ch & I don't have ops there."
    }
    return 0
  }
  if {![llength $cg(_blist)]} {
    if {$cg(owner) ne ""} {
      puthelp "PRIVMSG $cg(owner) :The badMask list is empty! cloudGuard script is disabled."
      puthelp "PRIVMSG $cg(owner) :To add a badMask now, use:  \002!cg +bad <mask(s)>\002"
    }
    return 0
  }

  set isbad 0  ;   set nkuh "$nk!$uh"
  foreach m $cg(_blist) {
    if {[matchaddr $m $nkuh]} {  set isbad 1  ;  break  }
  }
  if {$isbad == 0} {  return 0  }

  foreach m $cg(_glist) {
    if {[matchaddr $m $nkuh]} {  return 0  }
  }

  if {$cg(doban) > 0} {   set usr [lindex [split $uh "@"] 0]
    pushmode $ch +b "*!${usr}@*"
    if {$cg(owner) ne "" && $cg(dokick) == 0} {
      puthelp "PRIVMSG $cg(owner) :Banned $nk ($uh) from $ch"
    }
  }
  if {$cg(dokick) > 0} {
    putkick $ch $nk
    if {$cg(owner) ne "" && $cg(doban) == 0} {
      puthelp "PRIVMSG $cg(owner) :Kicked $nk ($uh) from $ch"
    }
  }
  if {$cg(doban) > 0 && $cg(dokick) > 0 && $cg(owner) ne ""} {
    puthelp "PRIVMSG $cg(owner) :Kick/banned $nk ($uh) from $ch"
  }
  return 0
}


#########################
# cleanup some settings #
if {$cg(doban)  != 0} {  set cg(doban)  1  }
if {$cg(dokick) != 0} {  set cg(dokick) 1  }
set cg(owner) [string trim $cg(owner)]

########################
###### file stuff ######

#Name of badList file.
set cg(bfile) "scripts/cg_[string trim [namespace current] :]_badlist.txt"

#Name of goodList file.
set cg(gfile) "scripts/cg_[string trim [namespace current] :]_goodlist.txt"


proc cg_onload {} {   variable cg
  foreach x {b g} {
    set cg(${x}file) [string trim $cg(${x}file)]

    if {![file exists $cg(${x}file)]} {
      set openfile [open $cg(${x}file) a]   ;## cg(bfile) || cg(gfile) ##
      close $openfile
      set cg(_${x}list) {}      ;## sets var: cg(_blist) || cg(_glist) ##
    }
    if {![info exists cg(_${x}list)]} {
      set openfile [open $cg(${x}file) r]
      set cg(_${x}list) [split [read -nonewline $openfile] "\n"]
      close $openfile
    }
  }
}
cg_onload

proc cg_savefile { {x g} } {   variable cg   ;## $x can be: (b || g) ##
  set openfile [open $cg(${x}file) w]
  puts $openfile [join $cg(_${x}list) "\n"]
  close $openfile
}


putlog "Loaded cloudGuard version 0.2  25Nov2022"

}  ;## end of:  namespace eval ##


_________________
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
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