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.

add BAN with MSG

Old posts that have not been replied to for several years.
Locked
P
Prab

add BAN with MSG

Post by Prab »

I could really need some script help, please help. :roll:

I have made my own irssi (http://irssi.org) perl script, that detects spam.
When someone triggers it, i want to be able to send a

/msg Botnick ADDBAN *!*@.evil.spammer.com (reason:) SPAM

to my bot, to make it add the ban...and if possible, "password protection" too:

/msg Botnick PASSWORD eViLpAsSw0Rd ADDBAN *!*@evil.spammer.com reason:) SPAM

Anyone can help with with this?, please! :oops:
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

A simple solution to this, is to create a client side script to interface with DCC chat, rather than code it into eggdrop.
M
Mapherick

Post by Mapherick »

ppslim is very right, but since i had nothing to do besides waiting for a slow ora8 install to finish, i wrote it for you. I will finish this script by making 3 more functions for listing/searching/unbanning and a user friendly interface (This is more for automatic processes like yours)

After i finished the script i will ofcourse distribute it.

Code: Select all

# FILENAME: MSGBAN.TCL
# VERSION:  1.0 
# DATE:     8/17/2002
# ----------------------------------------------------------------
# REQUIREMENTS:
#    channels.mod, core.mod
# ----------------------------------------------------------------
# AUTHOR:
#    Mapherick^ApL <mapherick at apl-productions.org>
#
# ----------------------------------------------------------------
# USAGE:
#    /MSG <bot> ADDBAN [parameters]
#    Parameters:
#       --help       show commandline help, overrides other 
#                    parameters
#       --mask       hostmask to ban confirming *!*@*       
#       --nick       nick to ban if no hostmask given
#       --reason     reason of ban, optional
#       --chan       restrict ban to a single channel
#       --sticky     stick a ban (overrides +dynamicbans)
#       --pass       optional extra password protection
#                    specified in the config section
#    Examples:
#       /MSG Bot --mask guy!needs@ban.com --chan #MyChan --sticky
#       /MSG Bot --nick Guy --pass 1337P455 --reason you lahmah!
# ----------------------------------------------------------------
# PURPOSE:
#    To enable bans through the MSG command, mainly for automated
#    IRC programs, like the spamdetector as described by Prab on
#    http://forum.egghelp.org/viewtopic.php?t=2372
# ----------------------------------------------------------------
# LICENSING:
#    This script is free to use and modify for personal use. If
#    you wish to distribute your modified version, please contact 
#    the author.
# ----------------------------------------------------------------
# Configuration Of Script Follows:

# --
# $mb_flag_needed & $mb_global_flag_needed
#    Set the flags that are needed to place bans
#--
set mb_flag_needed "o|o"
set mb_global_flag_needed "o"

# --
# $mb_ban_time
#    Time that a ban stays active in minutes
#    0 = permanent
# --
set mb_ban_time 0

# --
# $mb_default_banmsg
#    Default message that shows up when a user
#    is kick_banned and no custom reason was given
# --
set mb_default_banmsg "Ewww!"

# --
# $mb_password
#    OPTIONAL!
#    Adds extra security by requesting a second 
#    password on ban
# --
set mb_password "blah"

bind msg $mb_flag_needed addban mb_addban

proc mb_addban {nick uhost hand args} {
  global botnick mb_password mb_flag_needed mb_ban_time mb_default_banmsg mb_global_flag_needed

  if {[lindex $args 0] == ""} {puthelp "NOTICE $nick :[mb_errmsg HELPME]" ; return 0}

  foreach param [split [lindex $args 0] "--"] {
    switch -- [string tolower [lindex $param 0]] {
      mask      {set mb_banmask [strlwr [lindex $param 1]]}
      nick      {set mb_bannick [string tolower [lindex $param 1]]}
      pass      {set mb_pass [lindex $param 1]}
      reason    {set mb_reason [string range $param 6 end]}
      chan      {set mb_chan [string tolower [lindex $param 1]]}
      sticky    {set mb_sticky sticky}
      help      {puthelp "NOTICE $nick :[mb_errmsg HELPME]" ; return 0}
    } 
  }
  
  if ![info exists mb_pass] {set mb_pass ""}

  if {![info exists mb_banmask]  && ![info exists mb_bannick]} {
    puthelp "NOTICE $nick :[mb_errmsg NOTODO]" ; return 0
  } elseif {[info exists mb_banmask]  && ![string match "*!*@*" $mb_banmask]} {
    puthelp "NOTICE $nick :[mb_errmsg BADMSK]" ; return 0
  } elseif {[info exists mb_chan]     && ![onchan $botnick $mb_chan]} {
    puthelp "NOTICE $nick :[mb_errmsg NOCHAN]" ; return 0
  } elseif {[info exists mb_bannick]  && $mb_bannick == $botnick} {
    puthelp "NOTICE $nick :[mb_errmsg BANSLF]" ; return 0
  } elseif {![info exists mb_chan]    && ![matchattr $hand $mb_global_flag_needed]} {
    putlog [mb_errmsg NOAUTH $nick] ; return 0
  } elseif {[info exists mb_chan]     && ![matchattr $hand $mb_flag_needed $mb_chan]} {
    putlog [mb_errmsg NOAUTH $nick] ; return 0
  } elseif {[info exists mb_password] && $mb_password != $mb_pass} {
    putlog [mb_errmsg BADPAS $nick] ; return 0
  }

  if {![info exists mb_banmask] && [info exists mb_bannick]} {set mb_banmask "$mb_bannick!*@*"}
  if ![info exists mb_sticky] {set mb_sticky none}
  if ![info exists mb_reason] {set mb_reason $mb_default_banmsg}


  if ![info exists mb_chan] {
    newban $mb_banmask $hand $mb_reason $mb_ban_time $mb_sticky
  } else {
    newchanban $mb_chan $mb_banmask $hand $mb_reason $mb_ban_time $mb_sticky
  }
}



proc mb_errmsg {args} {
  global botnick
  set errno [lindex $args 0]
  switch $errno {
    HELPME {
      set msg "\002USAGE:\002 /MSG $botnick ADDBAN <--nick Nick/--mask nick!ident@host.net> \[--password password\]"
      set msg "$msg \[--reason reason for ban\] \[--chan \#channel\] \[--sticky\] \[--help\]"
      return $msg
    }
    NOCHAN {
      set msg "\002ERROR:\002 I am not on that channel."
      return $msg
    }
    BANSLF {
      set msg "\002ERROR:\002 Unable to ban myself."
      return $msg
    }
    NOAUTH {
      set msg "MSGBAN.TCL: ERROR: User [lindex $args 1] has"
      set msg "$msg insufficient rights to use this function"
      return $msg
    }
    BADMSK {
      set msg "\002ERROR:\002 Bad hostmask supplied, use format"
      set msg "$msg nick!ident@address. Wildcards (*\/?) allowed."
      return $msg
    }
    NOTODO {
      set msg "\002ERROR:\002 Nothing to do!"
      return $msg
    }
    BADPAS {
      set msg "MSGBAN.TCL: ERROR: User [lindex $args 1] supplied"
      set msg "$msg a bad password"
      return $msg
    }
    default {
      set msg "ERROR: Missing entry"
      return $msg
    }
  }
}


putlog "MSGBAN.TCL v1.0 by Mapherick^ApL loaded..."
Enjoy!
P
Prab

ohhh i love u guys :)

Post by Prab »

Thank you very much :D *hugs*

I tought about DCC to, but i tought MSG would be faster? and more simpel (for me)...

Thank you very much (again)...
Locked