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.

Banning Scripts

Old posts that have not been replied to for several years.
V
Viper359
Voice
Posts: 10
Joined: Fri Feb 14, 2003 9:44 am
Location: Toronto,Ontario, Canada
Contact:

Banning Scripts

Post by Viper359 »

Okay, I was wondering, if such a tcl script exsists were the bot remembers every ban set by an op, records the reason, inculding color and bolds if used, and time, if there is one. If one does not exsist, how hard would it be to write that tcl for a brand new user like myself?

Thanks

Bill
S
StormLord

Post by StormLord »

Huh. I dunno is there any such tcl script, but if you are novice in tcl it will be a little harder unless you can manage with arrays.
:D
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

well... if he wants every ban to be recorded and logged he will have to work with files.. and that's really not hard ;)
Elen sila lúmenn' omentielvo
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

hmmm

Post by De Kus »

i dunno what he exactly wants, but sounds similar to that i would really like to make. but i am laking knowledge about using tables.

i thought i would bind mode +b and -b. on +b it will be checked by handle if this one is half-op, op or higher. then newchanban will be called adding the ban with handle as creator.
the -b binding shall check via banlist if the user of -b is same or more privileged than the creator. and here is my problem. id need a way finding the ban in the bots banlist, if not found returning doing nothing, and if found returning creator handle. in case creator handle is invalid it suggest it is created by script, means by the bot equilant to ban is made by a master.

bonus would be a kick bind which changes the ban reason if the kicked matchs a ban created by him or more privilleged :D.

because im scripting is not my job only a small hobby i would prefer a german howto or a simple script which i can copy&paste and change for this job ;).
S
StormLord

Post by StormLord »

Papillon wrote:well... if he wants every ban to be recorded and logged he will have to work with files.. and that's really not hard ;)
well :roll: it depens how often does he want to 'use' the ban data.
if it's occasionaly then he can simple use bot's log file to dig into...
but, anything more than that I'd advice to keep bans into some kind of cache :wink:
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

the problem with caches is that it dissapears if the bot goes down ;)... of course you can store it all in cache but then I would make sure the complete cache is written to a file before rehash, restart, sighterm, kill ..... etc
Elen sila lúmenn' omentielvo
S
StormLord

Re: hmmm

Post by StormLord »

De Kus wrote:i dunno what he exactly wants, but sounds similar to that i would really like to make. but i am laking knowledge about using tables.
not even quite :lol:
De Kus wrote:---snip---
and here is my problem. id need a way finding the ban in the bots banlist, if not found returning doing nothing, and if found returning creator handle. in case creator handle is invalid it suggest it is created by script, means
by the bot equilant to ban is made by a master.
---snip---
well, you can use (for the good start) something next code for searching banlist *$newban is new ban string from `bind mode'*:

Code: Select all

foreach list_of_bans [banlist] {
  foreach {ban comment expire created lastact owner} $list_of_bans {
     if {[string match $ban $newban]} {
         return ($owner)
     }
  }
}
at this moment i don't have time to write down all script, but you can ask for more help if you get lost in scripting :D
Last edited by StormLord on Fri Feb 14, 2003 5:48 pm, edited 2 times in total.
S
StormLord

Post by StormLord »

Papillon wrote:the problem with caches is that it dissapears if the bot goes down ;)... of course you can store it all in cache but then I would make sure the complete cache is written to a file before rehash, restart, sighterm, kill ..... etc
:lol:
but... when the bot starts again, script is runover which reads bot's log file and searches for last bans :wink:
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

hehe yes.. but that would probably just be more work than creating a new file and put all bans in it :) .. and he wanted EVERY ban logged ... that means that if he was supposed to pull it from the logs he would have to have one BIG log .. or look through ALOT of files... ;)
Elen sila lúmenn' omentielvo
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Re: StormLord

Post by De Kus »

thank you, i think ill create the script within the next days based on your code.

if my suggestion sounds interessting for someone else ill post it after it has passed by own beta test and fit requirements :D.
V
Viper359
Voice
Posts: 10
Joined: Fri Feb 14, 2003 9:44 am
Location: Toronto,Ontario, Canada
Contact:

Post by Viper359 »

Thanks guys. I dont think I will attempt a script at it yet, as I am too new, I will start with some simplier scripts, and some tutorials and work my way up. I already like the ease of getting information and help on here. Much appreciated.
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

Code: Select all

#Script for adding and removing bans to and from the bots intern banlist by privileged persons.
#v1.0.4: 26.02.03 fixed logical error in the if expression for -userbans - still unknown why no -b comes tried to fix with ""
#v1.0.3: 22.02.03 fixed problems somehow only occuring on unix eggdrops with variables and newchanban return
#v1.0.2: 19.02.03 changed texts to be configurable
#v1.0.1: 16.02.03 changed priority of other bots bans
#v1.0  : 15.02.03 first release

set banmanagerbanreason "bis zu ${ban-time}min - requested by"
#up to
set banmanagerillegal "Sorry, diesen Ban kann ich nicht annehmen!"
#Sorry, I can't accept this ban!
set banmanagernorights "Sorry, ich kenn dich nicht mit irgendwelchen Rechten, die dir das Hinzufügen von Bans gestatten würden."
#Sorry, I don't know you having any rights to add a ban.
set banmanagernoperm "Sorry, du hast nicht die Rechte den Ban zu entfernen"
#Sorry, your don't have the rights to remove this ban

#only configuration you'd like to make could be to change german feedback ^-^
#no more configuration needed, tried to hold script flexible using global variables

#
# begin of Code - change on your own risk :)
#

bind mode - "*+b" banmanager:add
bind mode - "*-b" banmanager:rem

proc banmanager:add {nick uhost hand chan mode newban} {
  global botnick banmanagerbanreason banmanagerillegal banmanagernorights
  if { [matchban $newban $chan] || $nick == "" || $nick == $botnick } { return 0 }
#ban is already registered? fine, what else would we want?
#till now server bans will be ignored until i figure out how to add them as flagged op, not master
  if { [matchattr $hand m|m $chan] || [matchattr $hand o|o $chan] || [matchattr $hand l|l $chan] } {
    newchanban $chan $newban $hand "$banmanagerbanreason $hand"
    if { [isban $newban $chan] } {
      putcmdlog "<$nick@$chan> !$hand! added Channelban $newban"
    } else {
      pushmode $chan -b $newban
      puthelp "NOTICE $nick :$banmanagerillegal"
    }
#creates the ban with the handle as creator and with standard banlifetime
    return 1
  } elseif { [lsearch -exact [channel info $chan] -userbans] > -1} {
#removing ban if no userbans are allowed on channel and telling the user this
    pushmode $chan -b "$newban"
    puthelp "NOTICE $nick :$banmanagernorights"
  } else { return 2 }
}

proc banmanager:rem {nick uhost hand chan mode oldban} {
  global botnick banmanagernoperm
  if { $nick == $botnick && [lsearch -exact [channel info $chan] +dynamicbans] > -1} { return 0 }
#do nothing if ban gets removed by a bot on channels with dynamic bans
  set banowner [getbanowner $oldban $chan]
  if { $banowner == "*" } {
    return 0
#ban not registered? who cares... now its away
  } elseif { ![validuser $banowner] } { set banowner [finduser -telnet!*@*] }
#owner doenst exist? must be from a script. and i hope everyone has the autocreated account with host this host
  if { [matchattr $banowner m|m $chan] && ![matchattr $banowner b] } {
#i mean... any owner is master, isnt it?
    set ownerrank 3
  } elseif { [matchattr $banowner o|o $chan] } {
    set ownerrank 2
  } elseif { [matchattr $banowner l|l $chan] } {
    set ownerrank 1
  } else { set ownerrank 0 }
  if { [matchattr $hand m|m $chan] && ![matchattr $banowner b] } {
    set handrank 3
  } elseif { [matchattr $hand o|o $chan] || $nick == "" } {
#nick can only be empty on server mode changes, so lets say server is op
    set handrank 2
  } elseif { [matchattr $hand l|l $chan] } {
    set handrank 1
  } else { set handrank 0 }
  if { $handrank >= $ownerrank } {
    if { ![killchanban $chan $oldban] } {
      if {(([matchattr $hand o] || [matchattr $hand n|n $chan]) && ![isbansticky $oldban]) || [matchattr $hand m]} {
#only global ops and channel owner may remove a global ban and non sticky bans
        killban $oldban
        putcmdlog "<$nick@$chan> !$hand! removed global ban $oldban"
        return 1
      }
    } else {
      putcmdlog "<$nick@$chan> !$hand! removed Channelban $oldban"
      return 1
    }
  }
  pushmode $chan +b $oldban
  if { !($nick == "") } { puthelp "NOTICE $nick :$banmanagernoperm" }
  return 1
}

#this code is sponsered by StormLord @ egghelp.org
proc getbanowner {oldban chan} {
  foreach list_of_bans [banlist] {
    foreach {ban comment expire created lastact owner} $list_of_bans {
      if { $ban == $oldban } {
        return $owner
      }
    }
  }
  foreach list_of_bans [banlist $chan] {
    foreach {ban comment expire created lastact owner} $list_of_bans {
      if { $ban == $oldban } {
        return $owner
      }
    }
  }
  return *
}
suggestions and bug reports are welcome of course :).
Last edited by De Kus on Tue Feb 25, 2003 7:25 pm, edited 4 times in total.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

An english translation? ;]
Once the game is over, the king and the pawn go back in the same box.
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Translation

Post by De Kus »

caesar wrote:An english translation? ;]
na gut :)
eh... i meant: ok ;)
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Danke :)
Once the game is over, the king and the pawn go back in the same box.
Locked