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.

Kill 1st Gline 2nd

Help for those learning Tcl or writing their own scripts.
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Kill 1st Gline 2nd

Post by ComputerTech »

So just made this rough code on my mobile, it's meant to kill a user if they flood on 1st, and if they flood when they reconnect it will gline, is this code close to correct?

Code: Select all

bind flud - pub flud:ban

proc flud:ban { n u h t c } {
	global badguy
	if {(![info exists badguy])} { set badguy "0" }
	if {($badguy != "1")} {
		putnow "gline $n 30m Network_Flood"
		set badguy "0"
	} else {
		putnow "KILL $n Spamming is not allowed on TechNet"
		set badguy "1"
	}
}

i want to make this for each user, and not set a global variable
Cheers in advanced guys 8)
ComputerTech
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

Heh, figured it out by myself

Code: Select all

bind flud - pub flud:ban

proc flud:ban { n u h t c } {
	global badguy
	if {(![info exists badguy])} { set badguy "0" }
	if {($badguy == "1")} {
		putnow "gline $n 30m Network_Flood"
		set badguy "0"
	} else {
		putnow "KILL $n Spamming is not allowed on TechNet"
		set badguy "1"
	}
}
And of course, all is welcome to edit and give ideas to improve :D
ComputerTech
User avatar
CrazyCat
Revered One
Posts: 1216
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Well, your script will gline a lot of flooders:
If UserA floods, the proc is called and badguy is set to 1.
If anyone else floods, the proc is called again and then, he's glined, even if he's not UserA.

Here is a way to make it gline the user already advertised, by using his host as key for $badguy

Code: Select all

bind flud - pub flud:ban

proc flud:ban { n u h t c } {
   if {(![info exists ::badguy($u)])} { set ::badguy($u) 0 }
   if {($::badguy($u) == "1")} {
      putnow "gline $n 30m Network_Flood"
      set ::badguy($u) 0
   } else {
      putnow "KILL $n Spamming is not allowed on TechNet"
      set ::badguy($u) 1
   }
}
I didn't correct your gline command which won't work, the gline syntax is gline host duration :reason
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

Cheers CrazyCat, what about ip? if i wanted to gzline them, what would i change?

Thanks in advanced for effort :D
ComputerTech
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

Um, your version didn't work until I added a namespace, now it works Perfect :D

Code: Select all

namespace eval ::badguy {

bind flud - pub flud:ban

proc flud:ban { n u h t c } {
   if {(![info exists ::badguy($u)])} { set ::badguy($u) 0 }
   if {($::badguy($u) == "3")} {
      putnow "gline $n 30m Network_Flood"
      set ::badguy($u) 0
   } else {
      putnow "KILL $n Spamming is not allowed on TechNet"
      set ::badguy($u) 1
   }
   if {($::badguy($u) == "2")} {
   putnow "privmsg $n :You Are Flooding/Spamming, Please Stop Or You Will Be Network Banned"
  
  } else {
      return

     }
  }
}
Cheers CrazyCat 8)
ComputerTech
User avatar
CrazyCat
Revered One
Posts: 1216
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Do you know you're really lucky ?
I did a small script a few week ago to gline potential bad bots...

Here is the source: https://gitlab.com/tcl-scripts/chan-acc ... hecker.tcl

If I adapt for your usage:

Code: Select all

namespace eval badguy {

	variable bad
	
	bind flud - pub flud:ban
	
	proc flud:ban { n u h t c } {
		if {(![info exists ::badguy::bad($u)])} { set ::badguy::bad($u) 0 }
		incr ::badguy::bad($u)
		switch $::badguy::bad($u) {
			1 {
				putquick "privmsg $n :You Are Flooding/Spamming, Please Stop Or You Will Be Network Banned"
			}
			2 {
				putquick "KILL $n Spamming is not allowed on TechNet"
			}
			3 {
				putnow "WHOIS $n"
				unset ::badguy::bad($u)
			}
		}
		return 1
	}
	
	bind raw - 378 flud:gline
	proc flud:gline {from kw text} {
		set host [lindex [split $text " "] end]
		putnow "gzline *@$host +30m :Network flood"
	}
}
Note that there is no security: if eggdrop receive a response to a /whois, it will gzline the user.

Small other notes:
- you decide to use a namespace but your variable was in the global namespace, so I rename it and put it in your namespace
- I changed your if / else to a switch, allowing to add more options
- the flood counter is now using incr, you don't have to set it to the next level each time
- I reserved putnow for actions needing high priority (/whois and gline), others can simply use putquick. Don't use putnow everywhere.
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Don't know why you need to issue the whois since you already got the host in the flud proc, but why not move the unset in the flud:gline proc and with a if you can also make sure you don't punish innocent people.
Once the game is over, the king and the pawn go back in the same box.
User avatar
CrazyCat
Revered One
Posts: 1216
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Sorry, but the flud proc only have the cloacked IP, you have to do a whois to get the real IP and then be able to gline/gzline.
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

Thanks CrazyCat! i'll go test it to be sure, and report back

*salute*
Last edited by ComputerTech on Mon May 17, 2021 8:24 pm, edited 1 time in total.
ComputerTech
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

So just to be sure, if i want to add more options do i do it like this?

Code: Select all

 proc flud:ban { n u h t c } {
      if {(![info exists ::badguy::bad($u)])} { set ::badguy::bad($u) 0 }
      incr ::badguy::bad($u)
      switch $::badguy::bad($u) {
         1 {
            putquick "privmsg $n :You Are Flooding/Spamming, Please Stop Or You Will Be Network Banned"
         }
         2 {
            putquick "KILL $n Spamming is not allowed on TechNet"
         }
         3 { 
             putquick "privmsg $chan :your a sucker, you know that?"
          }

         4 {
            putnow "WHOIS $n"
            unset ::badguy::bad($u)
         }
      }
      return 1
   } 
If so, that is super duper awesome :D
ComputerTech
User avatar
CrazyCat
Revered One
Posts: 1216
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

Yes, it's exactly the way to add new levels.
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

Sweeeettt :D

Thanks a lot CrazyCat :D :D :D
ComputerTech
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

Is it possible if the bot has snomask +f, and a user exceed's recvq limit, that the bot joins the channel the user exceeded the recvq limit?

Cheers in advanced

Unrealircd 5.0.5.1

Anope 2.0.7
ComputerTech
s
simo
Revered One
Posts: 1072
Joined: Sun Mar 22, 2015 2:41 pm

Post by simo »

no not possible cause it cannot determine the channel
User avatar
ComputerTech
Master
Posts: 399
Joined: Sat Feb 22, 2020 10:29 am
Contact:

Post by ComputerTech »

Hmm, i guessed that, what of the notice or excessive flood, can it be noticed to a particular channel?
for example

Excessive Flood by guest123

on #test

Guest123 did Excessive Flood

that possible?

to catch the notice, and project to a specified channel
ComputerTech
Post Reply