 |
|
 |
|
MeBoy Comandant

Joined: 15 Aug 2007 Posts: 13
|
|
 |
|
 |
|
Posted: 15/08/2007 16:09 Post subject: BadNick.tcl |
|
|
| Code: | ######################################################################
# #
# Badnick.tcl ---> version 0,1 ( beta ) #
# Tested on: #
# Windrop v1.6.17 CYGWIN_NT with Tcl 8.4 #
# Basic usage guide: #
# .chanset #channel +badnick #
# .badnick -add <word> #
# .badnick -del <word> #
# .badnick -check <word> #
# .badnick -list <word> #
# .badnick <-add|-del|-check|-list> word #
# #
# ++ Requests a%a_light or LendingScript ++ #
# #
# #
# LICENSE: #
# This code comes with ABSOLUTELY NO WARRANTY. #
# #
# 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, or (at your option) any #
# later version. #
# #
# 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. (http://www.gnu.org/copyleft/library.txt) #
# #
# Copyright (C) 2007, ReaL|DoG #
# #Lending @ Undernet. Support http://forum.ircproject.info #
# Badnick at http://script.ircproject.info #
# #
######################################################################
################## How to Install this script ########################
######################################################################
# #
# Create folder /badnick/ in /eggdrop/ #
# Edit: local_n.tcl, aux.tcl #
# #
# #
# +++++++++++++++++++++++++++++++++++ #
# Edit Local_n.tcl #
# +++++++++++++++++++++++++++++++++++ #
# #
# Now, put this lines in local_n.tcl: #
a:command -add badnick pub:badnick 0000 000 |n
set bad(file) "badnick/$chan.db" ;# Here, you can set the folder where the files are going to be saved
proc pub:badnick {hand chan args x mix} {
global settings bad
set where $chan
set opt [lindex $args 0] ;# Option
set word [lindex $args 1] ;# BadNick word
switch -- $opt {
-add {
if {![matchattr $hand -|n $chan]} {puthelp "privmsg $chan :If you want to use this command ( \002!badnick -add\002 ) then you must be a $chan owner. (+n flag)"; return}
if {![file exists $bad(file)]} {
set fh [open $bad(file) w]
puts -nonewline $fh ""
close $fh
}
set fdz [open $bad(file) r]
set conte [read $fdz]
close $fdz
if {[string match -nocase "*$word*" $conte]} {puthelp "privmsg $chan :This word (\002$word\002) already exists in the $chan bad nick database."; return }
set fd [open $bad(file) a+]
puts $fd "$word"
close $fd
puthelp "PRIVMSG $chan :Added bad nick \002$word\002 to the $chan database."
}
-del {
if {![matchattr $hand -|n $chan]} {puthelp "privmsg $chan :If you want to use this command ( \002!badnick -del\002 ) then you must be a $chan owner. (+n flag)"; return}
set fd [open $bad(file) r]
set reads [read $fd]
close $fd
set data ""
if {![string match -nocase "*$word*" $reads]} {puthelp "privmsg $chan :This word (\002$word\002) doesn't exist in the $chan bad nick database."; return }
if {[llength $reads]} {
set fd [open $bad(file) w]
foreach line [split $reads \n] {
if {![string match -nocase *$word* $line]} {
if {[llength $line]} {puts $fd "$line\n"}
}
}
close $fd
puthelp "PRIVMSG $chan :I removed the bad nick word \002$word\002 from the $chan database."
}
}
-check {
if {![matchattr $hand -|- $chan]} {puthelp "privmsg $chan :If you want to use this command ( \002!badnick -check\002 ) then you must be a $chan owner. (+n flag)"; return}
set fd [open $bad(file) r]
set cont [read $fd]
close $fd
if {![string match -nocase "*$word*" $cont]} {puthelp "privmsg $chan :This word (\002$word\002) doesn't exist in the $chan bad nick database."; return }
foreach abuse [split $cont \n] {if {[string match -nocase "*$word*" $abuse]} {
set a1 [lindex $abuse 0]
puthelp "PRIVMSG $chan :The word \002$a1\002 exists in the $chan bad nick database."}
}
}
-list {
if {![matchattr $hand -|N $chan]} {puthelp "privmsg $chan :If you want to use this command ( \002!badnick -list\002 ) then you must be a $chan manager (+N flag)"; return}
set fd [open $bad(file) r]
set cont [read $fd]
close $fd
set listabuse ""
foreach abuse [split $cont \n] {lappend listabuse "\002[lindex $abuse 0]\002"}
puthelp "PRIVMSG $chan :I retrieved the following list from the $chan bad nick database: [join $listabuse]"
}
default {puthelp "privmsg $chan :Usage: !badnick <-add|-del|-check|-list> word"}
}
}
############################################################
# Now, go to chanset process, and put there badnick, like here:
# ie:
# [regexp {^[+-](badnick|silent|auto(op|voice)|.....}
# Now save this file and close it.
############################################################
#
# ++++++++++++++++++++++++++++++++++++ #
# Edit aux.tcl #
# ++++++++++++++++++++++++++++++++++++ #
# Here put this lines: #
bind join - * check:badnick
proc check:badnick {nick uhost hand chan} {
global settings bad username
if {![channel get $chan badnick] || ![botisop $chan] || [matchattr $hand +v]} { return 0 }
set fd [open $bad(file) r]
set wordlist [read $fd]
close $fd
foreach badnick [string tolower $wordlist] {
set bbanmask "*$badnick*!*@*"
if {[botisop $chan] && ![matchattr $hand -|+v $chan] && [channel get $chan badnick] && [string match *$badnick* [string tolower $nick]]} {
newchanban $chan $bbanmask $username "Before you can join this channel please change your nick because it contains the '\00304$badnick\003' word. Thanks." [channel get $chan ban-time]
}
}
}
################################################################
# Now save this file, aux.tcl and edit settings.conf. Here you #
# must to add, setudef flag badnick. After that.. save and type#
# on IRC !rehash or !restart :) #
################################################################ |
|
|