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 

Universal channel script
Goto page 1, 2, 3 ... 13, 14, 15  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Thu Sep 01, 2005 4:53 am    Post subject: Universal channel script Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Thu Sep 01, 2005 7:06 am    Post subject: Reply with quote

There already is such a script Razz but it's always nice to see a new one if you ask me.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Thu Sep 01, 2005 12:23 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Thu Sep 01, 2005 12:28 pm    Post subject: Reply with quote

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 Smile
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
caesar
Mint Rubber


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

PostPosted: Thu Sep 01, 2005 12:41 pm    Post subject: Reply with quote

:Thumbs up!: Very Happy Go for it, sounds great. I think a lot of people would like to use ALL in one script with the stuff they want. Smile
_________________
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
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Fri Sep 02, 2005 2:50 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
Dizzle
Op


Joined: 28 Apr 2005
Posts: 109

PostPosted: Fri Sep 02, 2005 4:10 am    Post subject: Reply with quote

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 ???
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Fri Sep 02, 2005 5:04 am    Post subject: Reply with quote

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


Joined: 24 Sep 2001
Posts: 733
Location: Norway

PostPosted: Fri Sep 02, 2005 11:43 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Send e-mail
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Mon Sep 05, 2005 12:43 am    Post subject: Reply with quote

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

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"

}
Back to top
View user's profile Send private message Visit poster's website
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Mon Sep 05, 2005 1:02 am    Post subject: Reply with quote

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:

    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:

    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:

    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:

<(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
Back to top
View user's profile Send private message Visit poster's website
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Mon Sep 05, 2005 6:40 am    Post subject: Reply with quote

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.
_________________
Follow me on GitHub

- Opposing

Public Tcl scripts
Back to top
View user's profile Send private message Visit poster's website
mm
Halfop


Joined: 01 Jul 2004
Posts: 78

PostPosted: Mon Sep 05, 2005 10:09 pm    Post subject: Reply with quote

Works like a champ. great great great work demond.
_________________
MM
Back to top
View user's profile Send private message
demond
Revered One


Joined: 12 Jun 2004
Posts: 3073
Location: San Francisco, CA

PostPosted: Tue Sep 06, 2005 11:38 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
KrzychuG
Master


Joined: 16 Aug 2003
Posts: 306
Location: Torun, Poland

PostPosted: Wed Sep 07, 2005 2:21 am    Post subject: Reply with quote

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?
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 Support & Releases All times are GMT - 4 Hours
Goto page 1, 2, 3 ... 13, 14, 15  Next
Page 1 of 15

 
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