Code: Select all
cmd ex: !BotNick Nick hello
Code: Select all
# Author: tomekk
# e-mail: tomekk/@/tomekk/./org
# home page: http://tomekk.org/
#
# Version 0.1
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html
set private_channel "#private"
##############################################################
bind pub - !forward forward_proc
bind msgm - "*" private_proc
proc private_proc { nick uhost hand arg } {
global private_channel
if {[botonchan $private_channel]} {
putquick "PRIVMSG $private_channel :$nick -> $arg"
}
}
proc forward_proc { nick uhost hand chan arg } {
global private_channel
set forward_arg [split $arg]
set forward_to [lindex $forward_arg 0]
set forward_msg [join [lrange $forward_arg 1 end]]
if {$chan == $private_channel} {
if {$forward_msg != ""} {
putquick "PRIVMSG $forward_to :$forward_msg"
} {
putquick "PRIVMSG $chan :use: !forward <nick> <msg>"
}
}
}
putlog "eggforward.tcl ver 0.1 by tomekk loaded"
That should already be working in the script:)i want it one more feature tht whn i type
!forward #egghelp hey
it shall msg that in #egghelp hey
Code: Select all
# Author: tomekk
# e-mail: tomekk/@/tomekk/./org
# home page: http://tomekk.org/
#
# Version 0.1
#
# This file is Copyrighted under the GNU Public License.
# http://www.gnu.org/copyleft/gpl.html
set private_channel "#private"
# List things not to forward to the channel, one item per line:
# List commands like this: op *
# list badwords like this: * badword * :or: *badword*
set dont_forward {
auth *
ident *
op *
} ;## end of dont_forward setting ##
##############################################################
bind pub - !forward forward_proc
bind msgm - "*" private_proc
set dont_forward [split [string trim $dont_forward] \n]
proc private_proc { nick uhost hand arg } {
global private_channel dont_forward
foreach item $dont_forward {
set item [string trim $item]
if {[string match -nocase $item $arg]} { return }
}
if {[botonchan $private_channel]} {
puthelp "PRIVMSG $private_channel :$nick -> $arg"
}
return
}
proc forward_proc { nick uhost hand chan arg } {
global private_channel
set forward_arg [split $arg]
set forward_to [lindex $forward_arg 0]
set forward_msg [join [lrange $forward_arg 1 end]]
if {$chan == $private_channel} {
if {$forward_msg != ""} {
puthelp "PRIVMSG $forward_to :$forward_msg"
} {
puthelp "PRIVMSG $chan :use: !forward <nick> <msg>"
}
}
return
}
putlog "eggforward.tcl ver 0.1 by tomekk loaded"
Besides, you should check only the first argument (word) from user input against the $dont_forward variable, make $dont_forward a list and use lsearch (with -nocase to make it case insensitive) to see if that argument (command, word or whatever you want to call it) is in there or not.if {[string match -nocase $item $arg]} { return }
dose anyone know what's that exclusive-binds setting refers to?If the exclusive-binds setting is enabled, MSG binds will not be triggered by text that a MSGM bind has already handled.
O.K., I'll buy that:) Removed the check from the above script.You don't need to count the lines (length $dont_forward) cos if there aren't any the foreach loop won't execute anything.
Actually, I did mean return. If the typed text matches any of the string patterns in the dont_forward setting, I want the process to return out, and not say anything to the private_channel.Also, I think you meant break not return in:
Quote:
if {[string match -nocase $item $arg]} { return }
Actually, I did mean to do it the way I did, I just didn't explain the reasons why at all.Besides, you should check only the first argument (word) from user input against the $dont_forward variable, make $dont_forward a list and use lsearch (with -nocase to make it case insensitive) to see if that argument (command, word or whatever you want to call it) is in there or not.
O.K., I'll buy that:) I did not write that part of the script, but have fixed the above script to reflect a more correct puthelp.Leave putquick to important stuff and use puthelp instead.
My understanding of that is:Edit: While we are at the MSGM subject, in the tcl-commands.doc I've noticed this:
Quote:
If the exclusive-binds setting is enabled, MSG binds will not be triggered by text that a MSGM bind has already handled.
dose anyone know what's that exclusive-binds setting refers to?
Code: Select all
# eggforward.tcl ver 0.2 by SpiKe^^ (3 Jan 2013) #
# author: SpiKe^^ #
# e-mail: spike<at>mytclscripts<dot>com #
# webpage: http://mytclscripts.com/ #
# This file is Copyrighted under the GNU Public License. #
# http://www.gnu.org/copyleft/gpl.html #
##### Based Almost Entirely on This Script by tomekk #####
# eggforward.tcl ver 0.1 by tomekk #
# Author: tomekk #
# #
# e-mail: tomekk/@/tomekk/./org #
# home page: http://tomekk.org/ #
# #
# Version 0.1 #
# #
# This file is Copyrighted under the GNU Public License. #
# http://www.gnu.org/copyleft/gpl.html #
##########################################################
# Set the private channel (all msgs sent to the bot, will be sent here)
set private_channel "#private"
# Enable multi bot support??? ( 0 = NO | 1 = YES )
# 0 = The reply command is: !forward <target> <text>
# 1 = The reply command is: !<botnick> <target> <text>
set is_multi_bot "0"
# List things not to forward to the channel, one item per line:
# List commands like this: op *
# List badwords like this: * badword * :or: *badword*
set dont_forward {
auth *
ident *
op *
} ;## end of dont_forward setting ##
##############################################################
bind msgm - "*" private_proc
set dont_forward [split [string trim $dont_forward] \n]
proc lets_do_unbind {} {
foreach bnd [binds forward_proc] {
foreach {ty fl na hi pr} $bnd { break }
unbind $ty $fl $na $pr
}
}
lets_do_unbind
if {$is_multi_bot=="1"} { bind pubm - "*" forward_proc
} else { bind pub - !forward forward_proc }
proc private_proc { nick uhost hand arg } {
global private_channel dont_forward
foreach item $dont_forward {
set item [string trim $item]
if {[string match -nocase $item $arg]} { return }
}
if {[botonchan $private_channel]} {
puthelp "PRIVMSG $private_channel :$nick -> $arg"
}
return
}
proc forward_proc { nick uhost hand chan arg } {
global private_channel is_multi_bot botnick
set forward_arg [split $arg]
if {$is_multi_bot=="1"} { set trig [lindex $forward_arg 0]
if {![string match -nocase $trig !$botnick]} { return }
set forward_arg [lrange $forward_arg 1 end]
} else { set trig !forward }
set forward_to [lindex $forward_arg 0]
set forward_msg [join [lrange $forward_arg 1 end]]
if {[string match -nocase $chan $private_channel]} {
if {$forward_msg ne ""} {
puthelp "PRIVMSG $forward_to :$forward_msg"
} else {
puthelp "PRIVMSG $chan :use: $trig <nick> <msg>"
}
}
return
}
putlog "eggforward.tcl ver 0.2 by SpiKe^^ loaded"
Code: Select all
# eggforward.tcl ver 0.3 by SpiKe^^ (4 Jan 2013) #
# author: SpiKe^^ #
# e-mail: spike<at>mytclscripts<dot>com #
# webpage: http://mytclscripts.com/ #
# This file is Copyrighted under the GNU Public License. #
# http://www.gnu.org/copyleft/gpl.html #
##### Based Almost Entirely on This Script by tomekk #####
# eggforward.tcl ver 0.1 by tomekk #
# Author: tomekk #
# #
# e-mail: tomekk/@/tomekk/./org #
# home page: http://tomekk.org/ #
# #
# Version 0.1 #
# #
# This file is Copyrighted under the GNU Public License. #
# http://www.gnu.org/copyleft/gpl.html #
##########################################################
# Set the private channel (all msgs sent to the bot, will be sent here)
set private_channel "#private"
# Enable multi bot support??? ( 0 = NO | 1 = YES )
# 0 = The reply command is: !forward <target> <text>
# 1 = The reply command is: !<botnick> <target> <text>
set is_multi_bot "0"
# Set the command prefix for the !forward and !<botnick> triggers
set forward_cmd "!"
# List things not to forward to the channel, one item per line:
# list commands first, then any badwords not to forward.
# List commands like this: op *
# List badwords like this: * badword * :or: *badword*
# Note: use * badword * for only the whole word 'badword'
# use *badword* for anywhere in words (match. 'isabadword')
set dont_forward {
auth *
ident *
op *
} ;## end of dont_forward setting ##
# If a msg to the bot contains a *badword*,
# would like a line sent to private_channel stating that??
# Leave this empty to just ignore message with badwords.
# or set this the the text to use (will be prefixed by: nick -> )
set say_badword "Message Contains badword"
##############################################################
bind msgm - "*" private_proc
set dont_forward [split [string trim $dont_forward] \n]
set say_badword [string trim $say_badword]
proc lets_do_unbind {} {
foreach bnd [binds forward_proc] {
foreach {ty fl na hi pr} $bnd { break }
unbind $ty $fl $na $pr
}
}
lets_do_unbind
if {$is_multi_bot=="1"} { bind pubm - "*" forward_proc
} else { bind pub - ${forward_cmd}forward forward_proc }
proc private_proc { nick uhost hand arg } {
global private_channel dont_forward say_badword
foreach item $dont_forward {
set item [string trim $item]
if {[string index $item 0] eq "*"} {
if {[string match -nocase $item " $arg "]} {
if {$say_badword eq ""} { return }
set arg $say_badword ; break
}
} elseif {[string match -nocase $item $arg]} { return }
}
if {[botonchan $private_channel]} {
puthelp "PRIVMSG $private_channel :$nick -> $arg"
}
return
}
proc forward_proc { nick uhost hand chan arg } {
global private_channel is_multi_bot botnick forward_cmd
set forward_arg [split $arg]
if {$is_multi_bot=="1"} { set trig [lindex $forward_arg 0]
if {![string match -nocase $trig $forward_cmd$botnick]} { return }
set forward_arg [lrange $forward_arg 1 end]
} else { set trig ${forward_cmd}forward }
set forward_to [lindex $forward_arg 0]
set forward_msg [join [lrange $forward_arg 1 end]]
if {[string match -nocase $chan $private_channel]} {
if {$forward_msg ne ""} {
puthelp "PRIVMSG $forward_to :$forward_msg"
} else {
puthelp "PRIVMSG $chan :use: $trig <nick> <msg>"
}
}
return
}
putlog "eggforward.tcl ver 0.3 by SpiKe^^ loaded"