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.

Universal channel script

Support & discussion of released scripts, and announcements of new releases.
Post Reply
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Universal channel script

Post by demond »

I realized my channel script sucks and I'm thinking of writing a channel protection script that will handle all channel offenses (flood, repeat, caps, colors, spam, bad words, etc. lame behaviour) in uniform way, counting offenses and punishing in different fashion by their number (e.g. 1-st by warning, 2-nd by kick, 3-rd by ban) - all configurable all the way, in real time, via chan settings; it will also have automatic +mi closing on flood and dynamic +l limiter

let me know what you think
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

There already is such a script :P but it's always nice to see a new one if you ask me.
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

functionally similar, but not quite; also, the implementation will be radically different from most, if not all such scripts - I mean, the keyword here is uniformity, which implies reuse of code; also, I intend to make the configuration part entirely based on chan settings, i.e. you won't need to edit the script at all
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Yeah that might be better for some users, I was intending to add some dynamic settings in allfloodprotection (not to all settings though) only to some most commonly exposed to change settings. Anyway, I'm for such a script especially from you :)
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

:Thumbs up!: :D Go for it, sounds great. I think a lot of people would like to use ALL in one script with the stuff they want. :)
Once the game is over, the king and the pawn go back in the same box.
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

well, it probably won't have all of the conceivable offenses punishment out there, but I'll try to optimize it for performance and make it relatively modular, so new features could be added easily, even by others
D
Dizzle
Op
Posts: 109
Joined: Thu Apr 28, 2005 11:21 am
Contact:

Post by Dizzle »

it sounds okay demond, butt doenst it look just the same as the script of Sir_Fz ?
What's this real life ppl keep talking about ??? And where can I download it ???
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

as I said, it will be functionally similar, to some extent, to all such scripts (including Sir_Fz's), i.e. it will be punishing for flood/lameness; however, similarity ends here - it will have completely different configuration, all done with chan settings (you don't edit the script, you don't write config file - that allows you to change script's behaviour on-the-fly, without logging to shell, editing files, rehashing), and its internal organization and implementation will also be quite different from all the others I have seen so far - much more streamlined and modular (I hope hehe)
g
greenbear
Owner
Posts: 733
Joined: Mon Sep 24, 2001 8:00 pm
Location: Norway

Post by greenbear »

Modular sounds good. That have always been my objection against the all-in-one type scripts. I really dont want 10 types of flood protection when maybe only 2-3 of them apply to my channel/situation.
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

for those interested, here's the basic framework of this thing, with one handler implemented (repeat):

Code: Select all

package require Tcl 8.3
package require eggdrop 1.6

namespace eval xchannel {

variable version "xchannel-1.0"

variable names {punish bantype bantime reason}
variable udefs {str int int str}

set conf1g(repeat) {w:k:b 1 10 "repeating is lame"}
set custom(repeat) {rate:str:2:10}

variable arrays {offenses:10:720 repeats:2:5}

bind time - * [namespace current]::timer

proc maskhost {nuhost {type 0}} {
	scan $nuhost {%[^!]!%[^@]@%s} nick user host
	scan [set mask [::maskhost $nuhost]] {%*[^@]@%s} mhost
	switch $type {
	0 - 1 {return $mask}       ;# *!*foo@*.bar.com
	2 {return *!*@$host}       ;# *!*@moo.bar.com
	3 {return *!*@$mhost}      ;# *!*@*.bar.com
	4 {return *!*$user@$host}  ;# *!*foo@moo.bar.com
	5 {return *!*$user@*}      ;# *!*foo@*
	6 {return $nuhost}
	}
}

proc init {chan} {
	variable names; variable udefs
	variable conf1g; variable custom
	foreach {type data} [array get conf1g] {
		bind pubm - * [namespace current]::$type
		setudef flag x:$type
		foreach val $data name $names udef $udefs {
			setudef $udef x:$type:$name
			if {$udef == "int"} {set void 0} {set void ""}
			if {[channel get $chan x:$type:$name] == $void} {
				channel set $chan x:$type:$name $val
			}
		}
	}
	foreach {type data} [array get custom] {
		foreach elem $data {
			scan $elem {%[^:]:%[^:]:%s} name udef val
			setudef $udef x:$type:$name
			if {$udef == "int"} {set void 0} {set void ""}
			if {[channel get $chan x:$type:$name] == $void} {
				channel set $chan x:$type:$name $val
			}
		}		
	}
}

proc timer {min hour day month year} {
	variable arrays
	foreach elem $arrays {
		scan $elem {%[^:]:%[^:]:%s} name freq val
		upvar #1 [namespace current]::$name arr
		if {([unixtime]/60) % $freq == 0} {
			if {[info exists arr]} {
			foreach {hash data} [array get arr] {
				set ts [lindex $data 0]
				if {[unixtime] - $ts > $val*60} {
					unset arr($hash)
				}
			}}
		} 
	}
}

proc punish {nick uhost hand chan type} {
	variable offenses
	if {[isop $nick $chan] || 
	    [matchattr $hand of|of $chan]} {return}
	set hash [md5 $chan:$type:[maskhost $nick!$uhost]]
	if {![info exists offenses($hash)]} {set n 1} {
		set n [lindex $offenses($hash) 1]; incr n
	}
	set offenses($hash) [list [unixtime] $n]
	set reason "[channel get $chan x:$type:reason] ($n)"
	set punish [split [channel get $chan x:$type:punish] :]
	set len [llength $punish]; if {$n > $len} {set n $len}
	switch [lindex $punish [incr n -1]] {
	"w" {putserv "privmsg $nick :$reason"}
	"k" {if {[botisop $chan]} {putkick $chan $nick $reason}}
	"b" {
		set time [channel get $chan x:$type:bantime]
		set type [channel get $chan x:$type:bantype]
		newchanban $chan [maskhost $nick!$uhost $type] $::nick $reason $time
		if {[botisop $chan]} {putkick $chan $nick $reason}
	}}
}

proc repeat {nick uhost hand chan text} {
	variable repeats
	if {![channel get $chan x:repeat]} {return}
	scan [channel get $chan x:repeat:rate] {%[^:]:%s} maxr maxt
	set hash [md5 $chan:$text:[maskhost $nick!$uhost]]
	if {![info exists repeats($hash)]} {
		set n 1; set ts [unixtime]
	} {
		set n [lindex $repeats($hash) 1]; incr n
		set ts [lindex $repeats($hash) 0]
		if {[unixtime] - $ts > $maxt} {
			set n 1; set ts [unixtime]
		} {
			if {$n > $maxr} {
				punish $nick $uhost $hand $chan repeat
				unset repeats($hash); return
			}
		} 
	}
	set repeats($hash) [list $ts $n]
}

foreach chan [channels] {init $chan}
putlog "$version by demond loaded"

}
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

so, what do I have here?
  • standard [punish] command, to be used uniformly in all offense handlers; it takes care of all checks and offense counting
  • common configuration routine, setting automatically channel settings needed; operating on 2 config arrays:

    Code: Select all

    set conf1g(repeat) {w:k:b 1 10 "repeating is lame"}
    
    this means: standard configuration for the repeat handler - "w:k:b" is punishment order (1st - warning, 2nd - kick, 3rd - ban and so on); 1 is bantype (see [maskhost] proc); 10 is bantime in minutes; "repeating is lame" is default kick/ban reason
    these config types are standard for all offense handlers

    Code: Select all

    set custom(repeat) {rate:str:2:10}
    
    meaning: custom configuration for the repeat handler - name of config parameter, udef type, value - at most 2 repeats in 10 seconds allowed
    these config types are specific for each offense handler
  • common cleanup routine, triggered by timer; it operates on config array specifying which arrays need to be periodically purged of old records:

    Code: Select all

    variable arrays {offenses:10:720 repeats:2:5}
    
    the meaning is: purge the offenses array every 10 mins from records older than 720 mins (12 hours), and purge the repeat array every 2 mins from records older than 5 mins
so basically, all I need to do when adding new handlers is to set up corresponding config arrays records (and cleanup array, if needed); then write the [bind pubm] handler, simply using [punish] as needed

and here are config chansets, as the bot sees it:

Code: Select all

<(Bot> User defined channel flags:
<(Bot>      -noseendata +quietseens +quietaiseens -nopubseens
<(Bot>      +x:repeat
<(Bot> User defined channel settings:
<(Bot> x:repeat:bantype: 1   x:repeat:bantime: 10
<(Bot> User defined channel strings:
<(Bot> x:repeat:reason: {repeating is lame}
<(Bot> x:repeat:rate: 2:10
<(Bot> x:repeat:punish: w:k:b
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Looks awsome mate, very well done. And working with [unixtime] instead of timers is also a great idea (also I liked the punishment mechanism, you had a good though about it). IMO, the script is very proffesional. Keep it up.
m
mm
Halfop
Posts: 78
Joined: Thu Jul 01, 2004 10:24 pm

Post by mm »

Works like a champ. great great great work demond.
MM
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

again, for those interested, you can monitor the progress of developing this thing by downloading the current version from my website, xchannel.txt

I need to write a vhost cloner to test it since I don't have dronenet hehe
User avatar
KrzychuG
Master
Posts: 306
Joined: Sat Aug 16, 2003 2:51 pm
Location: Torun, Poland
Contact:

Post by KrzychuG »

demond wrote:I need to write a vhost cloner to test it since I don't have dronenet hehe
Why write them again, there are plenty of these on polish websites, for example hyrda, xmen2, cloner ...
They're mostly optimized for IRCnet but should also work (mass join channels - basically that's what you need, right?) on other networks too.
Que?
Post Reply