Hello There.
I need a script to, per exemple, i say on channel:
!ban NICK REASON %1h30m
That ban will expire after 1 hour 30 minutes.
*This must work in akick from bot.
Thx
what you mean?McMilan wrote: *This must work in akick from bot.
sure, try:McMilan wrote:can you give your script for me see?
Code: Select all
# Author: tomekk
# e-mail: tomekk/@/oswiecim/./eu/./org
# home page: http://tomekk.oswiecim.eu.org/
#
# Version 0.1
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html
# !aban <nick> <interval_in_minutes>
# script is using [maskhost] for mask host
# from tcl-commands.txt
# maskhost <nick!user@host>
# Returns: masked hostmask for the string given ("n!u@1.2.3.4" -> "*!u@1.2.3.*",
# "n!u@lame.com" -> "*!u@lame.com", "n!u@a.b.edu" -> "*!u@*.b.edu")
# !aban channels
set aban_channels {#channel #channel2}
# file with banned hosts
set banned_hosts_file "bans.db"
########################################################
bind pub o|o !aban aban_proc
bind join -|- "*" aban_join_proc
if {![file exists $banned_hosts_file]} {
set touch_file [open $banned_hosts_file w]
close $touch_file
}
proc get_banned_hosts { } {
global banned_hosts_file
set banned_hosts ""
set open_hosts [open $banned_hosts_file r]
set banned_hosts [split [read $open_hosts] "\n"]
close $open_hosts
return $banned_hosts
}
proc add_banned_host { uhost utime uint uchan } {
global banned_hosts_file
set new_db_ban [open $banned_hosts_file a]
puts $new_db_ban "$uhost%$utime%$uint%$uchan"
close $new_db_ban
}
proc del_banned_host { uhost } {
global banned_hosts_file
set bnd_hosts [get_banned_hosts]
if {$bnd_hosts != ""} {
set bnd_hosts_u [open $banned_hosts_file w]
foreach bnd_host $bnd_hosts {
if {$bnd_host != ""} {
set clear_host [lindex [split $bnd_host "%"] 0]
if {$clear_host != $uhost} {
puts $bnd_hosts_u $bnd_host
}
}
}
close $bnd_hosts_u
}
}
proc check_for_ban { uhost } {
set ban_exists 0
set bnd_hosts [get_banned_hosts]
if {$bnd_hosts != ""} {
foreach bnd_host $bnd_hosts {
if {$bnd_host != ""} {
set clear_host [lindex [split $bnd_host "%"] 0]
if {$clear_host == $uhost} {
set ban_exists 1
break
}
}
}
}
return $ban_exists
}
proc aban_timer { } {
check_ban_intervals
if {[string match *aban_timer* [utimers]] != 1} {
utimer 10 aban_timer
}
}
proc aban_join_proc { nick uhost hand chan } {
global aban_channels botnick
if {[lsearch $aban_channels $chan] == -1} {
return
}
if {$botnick != $nick} {
set victim_host [maskhost [getchanhost $nick $chan]]
if {[check_for_ban $victim_host] == 1} {
putquick "MODE $chan +b $victim_host"
putkick $chan $nick "old ban..."
}
}
}
proc aban_proc { nick uhost hand chan arg } {
global aban_channels
set proc_args [split $arg]
set proc_nick [lindex $proc_args 0]
set proc_interval [lindex $proc_args 1]
if {[lsearch $aban_channels $chan] == -1} {
return
}
if {$proc_interval != ""} {
set proc_interval [expr int($proc_interval)]
if {[regexp {^[0-9]+$} $proc_interval]} {
if {$proc_interval > 0} {
if {[onchan $proc_nick $chan]} {
set victim_host [maskhost [getchanhost $proc_nick $chan]]
if {[check_for_ban $victim_host] == 0} {
add_banned_host $victim_host [clock seconds] $proc_interval $chan
putquick "MODE $chan +b $victim_host"
putkick $chan $proc_nick "banned for $proc_interval minute/s"
} {
putquick "NOTICE $nick :$victim_host is already on the list"
}
} {
putquick "NOTICE $nick :user $proc_nick is not on $chan"
}
} {
putquick "NOTICE $nick :interval must be greater than 0"
}
}
} {
putquick "NOTICE $nick :use: !aban <nick> <interval_in_minutes>"
}
}
proc check_ban_intervals { } {
set bnd_hosts [get_banned_hosts]
if {$bnd_hosts != ""} {
set time_now [clock seconds]
foreach bnd_host $bnd_hosts {
if {$bnd_host != ""} {
set bnd_rows [split $bnd_host "%"]
set ban_user_host [lindex $bnd_rows 0]
set ban_user_time [lindex $bnd_rows 1]
set ban_user_int [lindex $bnd_rows 2]
set ban_user_chan [lindex $bnd_rows 3]
if {[expr $time_now - $ban_user_time] > [expr $ban_user_int * 60]} {
if {[botonchan $ban_user_chan]} {
putquick "MODE $ban_user_chan -b $ban_user_host"
}
del_banned_host $ban_user_host
}
}
}
}
}
if {[string match *aban_timer* [utimers]] != 1} {
utimer 10 aban_timer
}
putlog "tb2.tcl ver 0.1 by tomekk loaded"