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 

Help fixing cmd trigger into botnick blacklist add ip global

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
mrleaW
Voice


Joined: 14 Feb 2018
Posts: 2

PostPosted: Wed Feb 14, 2018 10:05 am    Post subject: Help fixing cmd trigger into botnick blacklist add ip global Reply with quote

Code:
#
# blacklist.tcl
#   blacklist script
#
# RCS: @(#) $Id: blacklist.tcl,v 1.1 2006/10/19 13:28:21 wanne Exp $
#
#
# Copyright (C) 2006 Patrick G�nther (Wanne) <0wn3d-all@arcor.de> #Wanne @QuakeNet
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#

# '''> blacklist script

#  namespace eval ::blacklist {

# ''> setting variables

# '> don't change the copyright

variable version  "1.1"
variable author   "Patrick G�nther (Wanne)"

# '> script settings

variable trigger  ".bl"

# '<
# '> mysql settings

variable host     "localhost"
variable user     "username"
variable password "password"
variable database "database"
variable table    "blacklist"

# '<

# ''<
# ''> set user defined channel ..

# '> flags

setudef flag blacklist

# '<

# ''<
# ''> bindings

# '> public messages

bind PUB nm|nm $trigger ::blacklist::public

# '<
# '> user join

bind JOIN -|- *        ::blacklist::user:join

# '<

# ''<
# ''> procedures

# '> trigger

proc public { nickname hostname handle channel arguments } {

   switch -exact -- [string tolower [lindex [split $arguments] 0]] {

      on - enable {

         if {![matchattr $handle mn|mn $channel]} {
            return
         } elseif {[channel get $channel blacklist]} {
            putquick "NOTICE $nickname :BlacklistScript is already enabled \{$channel\}."
         } else {
            channel set $channel +blacklist
            putquick "NOTICE $nickname :BlacklistScript enabled successfully \{$channel\}."
         }

      }

      off - disable {

         if {![matchattr $handle mn|mn $channel]} {
            return
         } elseif {![channel get $channel blacklist]} {
            putquick "NOTICE $nickname :BlacklistScript is already disabled \{$channel\}."
         } else {
            channel set $channel -blacklist
            putquick "NOTICE $nickname :BlacklistScript disabled successfully \{$channel\}."
         }

      }

      add {

         if {![matchattr $handle mn|mn $channel]} {
            return
         } elseif {![channel get $channel blacklist]} {
            putquick "NOTICE $nickname :BlacklistScript is currently disabled on $channel, try: \"$::lastbind on\"."
         } elseif {[llength [split $arguments]] < 2} {
            putquick "NOTICE $nickname :Wrong parameters, try: \"$::lastbind add <hostmask> \[reason\] \[-global\]\"."
         } elseif {![string match *!*@* [lindex [split $arguments] 1]]} {
            putquick "NOTICE $nickname :Wrong hostmask, nickname\002!\002ident\002@\002host \[wildcards allowed\]."
         } elseif {[string map {{*} {} {?} {} {.} {}} [lindex [split $arguments] 1]] == "!@"} {
            putquick "NOTICE $nickname :Hostmask matches to many users."
         } elseif {[string match -nocase [lindex [split $arguments] 1] $::botname]} {
            putquick "NOTICE $nickname :Hostmask matches me."
         } elseif {![string equal -nocase [lindex [split $arguments] end] -global] && [llength [set hostmask [mysql "SELECT hostmask FROM `$::blacklist::table` WHERE channel='$channel' && hostmask like '[string map "* % ? _" [lindex [split $arguments] 1]]'"]]]} {
            putquick "NOTICE $nickname :[lindex [split $arguments] 1] is already blacklisted on $channel (hostmask: $hostmask)."
         } elseif {[string equal -nocase [lindex [split $arguments] end] -global] && [llength [set hostmask [mysql "SELECT hostmask FROM `$::blacklist::table` WHERE channel='global' && hostmask like '[string map "* % ? _" [lindex [split $arguments] 1]]'"]]]} {
            putquick "NOTICE $nickname :[lindex [split $arguments] 1] is already global blacklisted (hostmask: $hostmask)."
         } else {

            set kick {}

            if {[string equal -nocase [lindex [split $arguments] end] -global]} {

               set reason [lrange [split $arguments] 2 end-1]

               foreach chan [channels] {

                  if {![botisop $chan]} {
                     continue
                  } elseif {![channel get $chan blacklist]} {
                     continue
                  } else {

                     foreach user [chanlist $chan] {

                        if {[matchattr [nick2hand $user] mnov|mnov $chan]} {
                           continue
                        } elseif {[string match -nocase [lindex [split $arguments] 1] $user![getchanhost $user $chan]]} {
                           putquick "MODE $chan -ov+b $user $user [expr {[string match *.users.quakenet.org [getchanhost $user $chan]] ? "*!*@[lindex [split [lindex [split [getchanhost $user $chan] @] 1] .] 0].users.quakenet.org" : "[maskhost [getchanhost $user $chan]]"}]"
                           putquick "KICK $chan $user :[expr {![llength $reason] ? "You are BANNED from this Channel." : "$reason"}]"
                           lappend kick $user:$chan
                        }

                     }

                  }

               }

            } else {

               set reason [lrange [split $arguments] 2 end]

               if {[botisop $channel]} {

                  foreach user [chanlist $channel] {

                     if {[matchattr [nick2hand $user] mnov|mnov $channel]} {
                        continue
                     } elseif {[string match -nocase [lindex [split $arguments] 1] $user![getchanhost $user $channel]]} {
                        putquick "MODE $channel -ov+b $user $user [expr {[string match *.users.quakenet.org [getchanhost $user $channel]] ? "*!*@[lindex [split [lindex [split [getchanhost $user $channel] @] 1] .] 0].users.quakenet.org" : "[maskhost [getchanhost $user $channel]]"}]"
                        putquick "KICK $channel $user :[expr {![llength $reason] ? "You are BANNED from this Channel." : "$reason"}]"
                        lappend kick $user:$channel
                     }

                  }

               }

            }

            if {![llength $reason]} {
               set reason "You are BANNED from this Channel."
            }

            mysql "INSERT INTO `$::blacklist::table` VALUES ('$handle','[lindex [split $arguments] 1]','[expr {[string equal -nocase [lindex [split $arguments] end] -global] ? "global" : "$channel"}]','$reason','[llength $kick]')"
            putquick "NOTICE $nickname :Hostmask \{[lindex [split $arguments] 1]\} has been added to the [expr {[string equal -nocase [lindex [split $arguments] end] -global] ? "Global" : "$channel"}].Blacklist (reason: $reason) \[[llength $kick] [expr {[llength $kick] != "1" ? "Users" : "User"}] kicked[expr {[llength $kick] ? " ([join [join $kick " "] ", "])" : ""}]\]."

         }

      }

      del - delete - remove {

         if {![matchattr $handle mn|mn $channel]} {
            return
         } elseif {![channel get $channel blacklist]} {
            putquick "NOTICE $nickname :BlacklistScript is currently disabled on $channel, try: \"$::lastbind on\"."
         } elseif {[llength [split $arguments]] < 2} {
            putquick "NOTICE $nickname :Wrong parameters, try: \"$::lastbind delete <hostmask> \[-global\] \[-matches\]\" \[\"-matches\" removed all matches hostmasks\]."
         } elseif {![string match *!*@* [lindex [split $arguments] 1]]} {
            putquick "NOTICE $nickname :Wrong hostmask, nickname\002!\002ident\002@\002host \[wildcards allowed\]."
         } elseif {![string match -nocase [lindex [split $arguments] end] -global] && ![string match -nocase [lindex [split $arguments] end-1] -global] && ![llength [set hostmask [mysql "SELECT hostmask FROM `$::blacklist::table` WHERE channel='$channel' && [expr {[string equal -nocase [lindex [split $arguments] end] -matches] || [string equal -nocase [lindex [split $arguments] end-1] -matches] ? "hostmask like '[string map "* % ? _" [lindex [split $arguments] 1]]'" : "hostmask='[lindex [split $arguments] 1]'"}]"]]]} {
            putquick "NOTICE $nickname :[expr {[string equal -nocase [lindex [split $arguments] end] -matches] || [string equal -nocase [lindex [split $arguments] end-1] -matches] ? "No hostmasks found matches [lindex [split $arguments] 1]." : "Hostmask [lindex [split $arguments] 1] not found."}]"
         } elseif {[string match -nocase [lindex [split $arguments] end] -global] || [string match -nocase [lindex [split $arguments] end-1] -global] && ![llength [set hostmask [mysql "SELECT hostmask FROM `$::blacklist::table` WHERE channel='global' && [expr {[string equal -nocase [lindex [split $arguments] end] -matches] || [string equal -nocase [lindex [split $argumetns] end-1] -matches] ? "hostmask like '[string map "* % ? _" [lindex [split $arguments] 1]]'" : "hostmask='[lindex [split $arguments] 1]'"}]"]]]} {
            putquick "NOTICE $nickname :[expr {[string equal -nocase [lindex [split $arguments] end] -matches] || [string equal -nocase [lindex [split $arguments] end-1] -matches] ? "No hostmasks found matches [lindex [split $arguments] 1]." : "Hostmask [lindex [split $arguments] 1] not found."}]"
         } else {

            set remove {}

            if {[string equal -nocase [lindex [split $arguments] end] -global] || [string match -nocase [lindex [split $arguments] end-1] -global]} {

               if {[string match -nocase [lindex [split $arguments] end] -matches] || [string match -nocase [lindex [split $arguments] end-1] -matches]} {
                  mysql "DELETE FROM `$::blacklist::table` WHERE channel='global' && hostmask like '[string map "* % ? _" [lindex [split $arguments] 1]]'"
               } else {
                  mysql "DELETE FROM `$::blacklist::table` WHERE channel='global' && hostmask='[lindex [split $arguments] 1]'"
               }

               foreach chan [channels] {

                  if {![botisop $chan]} {
                     continue
                  } elseif {![channel get $channel blacklist]} {
                     continue
                  } else {

                     foreach host $hostmask {

                        if {[ischanban $host $chan]} {
                           pushmode $chan -b $host
                           lappend remove $host:$chan
                        }

                     }

                  }

               }

            } else {

               if {[string match -nocase [lindex [split $arguments] end] -matches] || [string match -nocase [lindex [split $arguments] end-1] -matches]} {
                  mysql "DELETE FROM `$::blacklist::table` WHERE channel='$channel' && hostmask like '[string map "* % ? _" [lindex [split $arguments] 1]]'"
               } else {
                  mysql "DELETE FROM `$::blacklist::table` WHERE channel='$channel' && hostmask='[lindex [split $arguments] 1]'"
               }

               foreach host $hostmask {

                  if {[ischanban $host $channel]} {
                     pushmode $channel -b $host
                     lappend remove $host:$channel
                  }

               }

            }

            putquick "NOTICE $nickname :Hostmask(s) \{[join $hostmask ", "]\} has been removed from the [expr {[string equal -nocase [lindex [split $arguments] end] -global] || [string equal -nocase [lindex [split $arguments] end-1] -global] ? "Global" : "$channel"}].Blacklist. \[[llength $remove] [expr {[llength $remove] != "1" ? "Bans" : "Ban"}] removed[expr {[llength $remove] ? " ([join [join $remove " "] ", "])" : ""}]\]."

         }

      }

      info - infos {

         if {![matchattr $handle mn|mn $channel]} {
            return
         } elseif {[llength [split $arguments]] < 2} {
            putquick "NOTICE $nickname :Wrong parameters, try: \"$::lastbind info <hostmask> \[-matches\]\" \[\"-matches\" show info from all matches hostmasks\]."
         } elseif {![string match *!*@* [lindex [split $arguments] 1]]} {
            putquick "NOTICE $nickname :Wrong hostmask, nickname\002!\002ident\002@\002host \[wildcards allowed\]."
         } elseif {![llength [set infos [mysql "SELECT * FROM `$::blacklist::table` WHERE [expr {[string equal -nocase [lindex [split $arguments] end] -matches] || [string equal -nocase [lindex [split $arguments] end-1] -matches] ? "hostmask like '[string map "* % ? _" [lindex [split $arguments] 1]]'" : "hostmask='[lindex [split $arguments] 1]'"}]"]]]} {
            putquick "NOTICE $nickname :[expr {[string equal -nocase [lindex [split $arguments] end] -matches] || [string equal -nocase [lindex [split $arguments] end-1] -matches] ? "No hostmasks found matches [lindex [split $arguments] 1]." : "Hostmask [lindex [split $arguments] 1] not found."}]"
         } else {

            foreach info $infos {
               putquick "NOTICE $nickname :Hostmask: [lindex [split $info \t] 1] is currently [expr {[string equal -nocase [lindex [split $info \t] 2] global] ? "Global Blacklisted" : "Blacklisted on $channel"}] - Added by: [lindex [split $info \t] 0] (reason: [lindex [split $info \t] 3]) - Kicked [lindex [split $info \t] 4] times."
            }

         }

      }

      list - liste {

         if {![matchattr $handle mn|mn $channel]} {
            return
         } elseif {[string equal -nocase [lindex [split $arguments] 1] -global]} {

            if {![llength [set infos [mysql "SELECT * FROM `$::blacklist::table` WHERE channel='global'"]]]} {
               putquick "NOTICE $nickname :No Global.Blacklist entrys found."
            } else {

               puthelp "NOTICE $nickname :Show Global.Banlist \[[llength [join [split $infos \t]]] entrys found\] ..."
               puthelp "NOTICE $nickname :#ID: HOSTMASK - OWNER - REASON - KICKTIMES"
               set id 0

               foreach info $infos {
                  puthelp "NOTICE $nickname :#[incr id 1]: [lindex [split $info \t] 1] - [lindex [split $info \t] 0] - [lindex [split $info \t] 3] - [lindex [split $info \t] 4]"
               }

               puthelp "NOTICE $nickname :End of list."

            }

         } elseif {[string equal -nocase [lindex [split $arguments] 1] -all]} {

            if {![llength [set infos [mysql "SELECT * FROM `$::blacklist::table` WHERE 1"]]]} {
               putquick "NOTICE $nickname :No Blacklist entrys found."
            } else {

               puthelp "NOTICE $nickname :Show All Blacklist entrys \[[llength [join [split $infos \t]]] entrys found\] ..."
               puthelp "NOTICE $nickname :#ID: CHANNEL - HOSTMASK - OWNER - REASON - KICKTIMES"
               set id 0

               foreach info $infos {
                  puthelp "NOTICE $nickname :#[incr id 1]: [lindex [split $info \t] 2] - [lindex [split $info \t] 1] - [lindex [split $info \t] 0] - [lindex [split $info \t] 3] - [lindex [split $info \t] 4]"
               }

               puthelp "NOTICE $nickname :End of list."

            }

         } elseif {![llength [set infos [mysql "SELECT * FROM `$::blacklist::table` WHERE channel='$channel'"]]]} {
            putquick "NOTICE $nickname :No $channel.Blacklist entrys found."
         } else {

            puthelp "NOTICE $nickname :Show $channel.Blacklist \[[llength [join [split $infos \t]]] entrys found\] ..."
            puthelp "NOTICE $nickname :#ID: HOSTMASK - OWNER - REASON - KICKTIMES"
            set id 0

            foreach info $infos {
               puthelp "NOTICE $nickname :#[incr id 1]: [lindex [split $info \t] 1] - [lindex [split $info \t] 0] - [lindex [split $info \t] 3] - [lindex [split $info \t] 4]"
            }

            puthelp "NOTICE $nickname :End of list."

         }

      }

      v - ver - vers - version - author - script - scripter {

         if {![matchattr $handle mn|mn $channel] && [info exists ::blacklist::lv] && [expr [unixtime] - $::blacklist::lv] < 20} {
            return
         }

         set ::blacklist::lv [unixtime]
         putquick "PRIVMSG $channel :Blacklist.tcl v$::blacklist::version - Copyright (c) 2006 $::blacklist::author <0wn3d-all@arcor.de> #Wanne @Quakenet"

      }

      default {

         if {![matchattr $handle mn|mn $channel]} {
            return
         } else {
            putquick "NOTICE $nickname :Wrong parameters, try: \"$::lastbind <on/off/add/delete/info/list/version> \[xtra parameters\]\"."
         }

      }

   }

}

# '<
# '> user join

proc user:join { nickname hostname handle channel } {

   if {![channel get $channel blacklist]} {
      return
   } elseif {![botisop $channel]} {
      return
   } else {

      foreach info [mysql "SELECT hostmask, reason, id FROM `$::blacklist::table` WHERE channel='$channel'"] {

         if {[string match -nocase [lindex [split $info \t] 0] $nickname!$hostname]} {
            putquick "MODE $channel -ov+b $nickname $nickname [lindex [split $info \t] 0]"
            putquick "KICK $channel $nickname :[lindex [split $info \t] 1]"
            mysql "UPDATE `$::blacklist::table` SET id='[expr [lindex [split $info \t] 2]+1]' WHERE channel='$channel' && hostmask='[lindex [split $info \t] 0]'"
            return
         }

      }

      foreach info [mysql "SELECT hostmask, reason, id FROM `$::blacklist::table` WHERE channel='global'"] {

         if {[string match -nocase [lindex [split $info \t] 0] $nickname!$hostname]} {
            putquick "MODE $channel -ov+b $nickname $nickname [lindex [split $info \t] 0]"
            putquick "KICK $channel $nickname :[lindex [split $info \t] 1]"
            mysql "UPDATE `$::blacklist::table` SET id='[expr [lindex [split $info \t] 2]+2]' WHERE channel='global' && hostmask='[lindex [split $info \t] 0]'"
            return
         }

      }

   }

}

# '<
# '> mysql

proc mysql { args } {
   return [lrange [split [exec echo [join $args] | mysql --host=$::blacklist::host --user=$::blacklist::user --password=$::blacklist::password --database=$::blacklist::database] \n] 1 end]
}

# '<
# '> tablecheck

if {[catch {mysql "SELECT * FROM `$::blacklist::table` WHERE 1"} tableerror] && [string match -nocase "*ERROR*1146*at*line*1*:*Table*'*'*doesn't*exist*" $tableerror]} {

   putlog "MySQLtable doesn't exist - creating..."

   mysql "CREATE TABLE `$::blacklist::table` (\n\
      `handle` varchar(250) NOT NULL default '',\n\
      `hostmask` varchar(250) NOT NULL default '',\n\
      `channel` varchar(250) NOT NULL default '',\n\
      `reason` varchar(250) NOT NULL default '',\n\
      `id` int(11) NOT NULL default '0'\n\
      ) ENGINE=MyISAM;"

   putlog "MySQLtable created."

}

# '<


# ''<
# ''> copyright informations

putlog "blacklist.tcl v.$version loaded successfully - Copyright (c) 2006 $author <0wn3d-all@arcor.de> #Wanne @QuakeNet"

# ''<

}

# '''<
Back to top
View user's profile Send private message
mrleaW
Voice


Joined: 14 Feb 2018
Posts: 2

PostPosted: Wed Feb 14, 2018 12:09 pm    Post subject: Re: Help fixing cmd trigger into botnick blacklist add ip gl Reply with quote

All i want is to make this tcl work with the command botnick blacklist add ip global instead of .bl add ip global (i have tried to contact the author and didn't find it anywhere)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
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