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.

on join check

Old posts that have not been replied to for several years.
Locked
User avatar
ReaLz
Op
Posts: 121
Joined: Sat Oct 19, 2002 5:33 am
Location: Athens, Greece

on join check

Post by ReaLz »

could u tell me how to make a simple script that reads a file with socks and when the eggdrop sees a sock joining the channel to ban it?
«A fantastic spaghetti is a spaghetti that does not exist»
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Code: Select all

set socksfile "socks.txt"
set socksreason "Don't use socks!"
set socksbantime 1440

bind join * * sock:check

proc sock:check {nick uhost handle channel} {
  set file [open "$::socksfile" r]

  if {![file exists $::socksfile]} {
    putlog "\002Error\002: $::socksfile dose not exist!"
    return 0
  }

  while {![eof $file]} {
    set text [split [read $file] "\n"]
    if {![string match "[lindex [split $uhost @] 1]" [split $text]]} { return }
    set mask "*!*@[lindex [split $uhost @] 1]"
    newchanban $channel $mask Socks "$::socksreason" $::socksbantime
  }
}
Once the game is over, the king and the pawn go back in the same box.
User avatar
ReaLz
Op
Posts: 121
Joined: Sat Oct 19, 2002 5:33 am
Location: Athens, Greece

Post by ReaLz »

thank you :)
«A fantastic spaghetti is a spaghetti that does not exist»
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

I've had a feeling that something is wrong there and decided to run a test. I've noticed that he only tests the first line, so here is the code that will read and test all lines from the file:

Code: Select all

set socksfile "socks.txt"
set socksreason "Don't use socks!"
set socksbantime 1440

bind join * * sock:check

proc sock:check {nick uhost handle channel} {
  if {![botisop $channel]} { return }
  if {![file exists $::socksfile]} {
    putlog "\002Error\002: $::socksfile dose not exist!"
    return 0
  }

  set file [open "$::socksfile" r]
  while {![eof $file]} {
    set lines [split [read $file] "\n"]
    foreach line $lines {
      if {$line == "" || ![string match "[lindex [split $uhost @] 1]" $line]} { continue }
      set mask "*!*@[lindex [split $uhost @] 1]"
      newchanban $channel $mask Socks "$::socksreason" $::socksbantime
      break
    }
  }
}
My appologies..
Last edited by caesar on Sat Apr 05, 2003 3:03 am, edited 1 time in total.
Once the game is over, the king and the pawn go back in the same box.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Due the fact that I was borring made something nice for you:

Code: Select all

bind msg m socks msg:socks

proc msg:socks {nick host hand text} {
  if {![file exists $::socksfile]} {
    putserv "PRIVMSG $nick :\002Error\002: $::socksfile dose not exist!"
    return 0
  }

  if {[llength $text] <1} {
    putserv "PRIVMSG $nick :\002Usage\002: socks <add|del|check> <socks>"
    return 0
  }


  switch -- [string tolower [lindex $text 0]] {

    "add" {
      if {[lindex $text 1] == ""} {
        putserv "PRIVMSG $nick :\002Usage\002: socks <add> <socks>"
        return 0
      }

      set sock "[lindex $text 1]"
      set file [open "$::socksfile" r]
      while {![eof $file]} {
        set line [gets $file]
        if {[string match [lindex $text 1] $line]} {
          putserv "PRIVMSG $nick :'$sock' socks is already in the list."
          return 0
        }
      }
      catch {close $file}
      set file [open "$::socksfile" a]
      puts $file $sock
      putserv "PRIVMSG $nick :Socks '$sock' was added to the list."
      catch {close $file}
    }

    "del" {
      if {[lindex $text 1] == ""} {
        putserv "PRIVMSG $nick :\002Usage\002: socks <del> <socks>"
        return 0
      }

      set found 0
      set index ""
      set sock "[lindex $text 1]"
      set file [open $::socksfile r] 
      while {![eof $file]} {
        set lines [split [read $file] "\n"]
        foreach line $lines { 
          if {$line == ""} { continue }
          if {$line == $sock} {
            set found 1
          } else { lappend index $line }
        }
        if {$found == 0} {
          putserv "PRIVMSG $nick :'$sock' was not found in the list."
        return }
      }
      catch {close $file}
      set file [open $::socksfile w] 
      foreach line $index {
        puts $file $line
      }
      catch {close $file}
      putserv "PRIVMSG $nick :Socks '$sock' was removed."
    }

    "check" {
      if {[lindex $text 1] == ""} {
        putserv "PRIVMSG $nick :\002Usage\002: socks <check> <socks>"
        return 0
      }
      set sock "[lindex $text 1]"
      set file [open "$::socksfile" r]
      while {![eof $file]} {
        set line [gets $file]
        if {[string match [lindex $text 1] $line]} {
          putserv "PRIVMSG $nick :Socks '$sock' was found in the list."
          return 0
        }
      }
      catch {close $file}
      putserv "PRIVMSG $nick :Socks '$sock' was not found in the list."
    }
  }
}
With 'socks add' you add a socks in to the list, with 'socks del' you delete one and finaly but not the last, with 'socks check' you can check if the specified socks is in the list. Enjoy.. :)

PS: Please tell me if you spot an error or something..
Once the game is over, the king and the pawn go back in the same box.
User avatar
ReaLz
Op
Posts: 121
Joined: Sat Oct 19, 2002 5:33 am
Location: Athens, Greece

Post by ReaLz »

sorry for asking you again but..
is it possible to make it scan 2 seconds after the join if the sock is banned in the channel and if not then ban it?
«A fantastic spaghetti is a spaghetti that does not exist»
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Here is the stuff you've requested.

Code: Select all

bind join * * sock:check

proc sock:check {nick uhost handle channel} {
  utimer 2 "sock:ban $nick $uhost $channel"
}

proc sock:ban {nick uhost channel} {
  if {![botisop $channel]} { return }
  if {![file exists $::socksfile]} {
    putlog "\002Error\002: $::socksfile dose not exist!"
    return 0
  }

  set file [open "$::socksfile" r]
  while {![eof $file]} {
    set lines [split [read $file] "\n"]
    foreach line $lines {
      if {$line == "" || ![string match "[lindex [split $uhost @] 1]" $line]} { continue }
      set mask "*!*@[lindex [split $uhost @] 1]"
      if {[ischanban $mask $channel]} { return }
      newchanban $channel $mask Socks "$::socksreason" $::socksbantime
      break
    }
  }
}
Enjoy.. :)
Once the game is over, the king and the pawn go back in the same box.
Locked