Code: Select all
http://members.fortunecity.com/eggheadtcl/chatme.tcl.txt
Code: Select all
namespace eval dccdump {
variable v
set v(timeout) 25000;# milliseconds
proc putlog what {::putlog "#dccdump# $what"}
proc chatfile {n fn} {
variable v
set f [open $fn]
set t [after $v(timeout) [list [namespace current]::timeout $f]]
set s [socket -server [list [namespace current]::start $f $t] -myaddr [myip] 0]
set p [lindex [fconfigure $s -sockname] 2]
set v($f) [list $s $n $fn]
putserv "PRIVMSG $n :\001DCC CHAT chat [myip] $p\001"
#putlog "Sending $fn to $n"
}
proc timeout {f} {
variable v
close $f
close [lindex $v($f) 0]
putlog "Timeout waiting for [lindex $v($f) 1] to connect."
unset v($f)
}
proc start {f t s a p} {
variable v
after cancel $t
close [lindex $v($f) 0]
#putlog "[lindex $v($f) 1] connected..."
fcopy $f $s -command [list [namespace current]::done $f $s]
}
proc done {f s b {e ""}} {
variable v
if {[string len $e]} {
putlog "Error transfering [lindex $v($f) 2] to [lindex $v($f) 1]: $e"
} {
putlog "Done transfering [lindex $v($f) 2] to [lindex $v($f) 1]."
}
close $f
close $s
unset v($f)
}
}
bind pub - !rules dccRules
proc dccRules {n u h c a} {
if {[catch {dccdump::chatfile $n rules.txt} err]} {
# initiating the send failed (failed to open file or socket)
putlog $err
return 0
}
}
I understood that $n = the user, but what is $fn? is the rules file?proc chatfile {n fn} {
variable v
set f [open $fn]
set t [after $v(timeout) [list [namespace current]::timeout $f]]
set s [socket -server [list [namespace current]::start $f $t] -myaddr [myip] 0]
set p [lindex [fconfigure $s -sockname] 2]
set v($f) [list $s $n $fn]
putserv "PRIVMSG $n :\001DCC CHAT chat [myip] $p\001"
#putlog "Sending $fn to $n"
}
If you see set aaa [open $bbb], you are sure that bbb is a filename.faisal wrote:I understood that $n = the user, but what is $fn? is the rules file?Code: Select all
set f [open $fn]
Code: Select all
set f [open $fn FLAG]
The two scripts do entirely different things. Egghead's code "fakes" a '/ctcp <bot> CHAT' making the bot initiate a telnet session with the user via dcc chat. (the user must be added in the bot)faisal wrote:Wow! The code is much more complicated than Egghead's TCL example script introduced by Rusher (thanks by the way).
As for the code, I dont know which line to replace so that the directory of the rules file can be found and executed by the bot.
r is the default mode and doesn't need to be specified.CrazyCat wrote:But I think something is missing:with FLAG like r (read) or w (write) or a (append)Code: Select all
set f [open $fn FLAG]
Code: Select all
#---------------------------------------------------------------------
# open listen port
#---------------------------------------------------------------------
set dccrulesport 37000
listen $dccrulesport script presentrules
#---------------------------------------------------------------------
# upon a public !rules tell the user the ip/port combination
#---------------------------------------------------------------------
bind pub - !rules pub:rules
proc pub:rules { nick uhost hand chan text } {
global dccrulesport
putlog "Request for rules by $nick (aka $hand)"
set line "\001DCC CHAT chat [myip] $dccrulesport\001"
putserv "PRIVMSG $nick :$line"
}
#---------------------------------------------------------------------
# dump rules through DCC
#---------------------------------------------------------------------
proc presentrules { idx } {
# upon a successfull connection:
# present the rules from the text directory
# check the setting of the variable "text-path"
dccdumpfile $idx rules.txt
# ... and terminate the connection
killdcc $idx
return 1
}
Keep in mind that your protect-telnet setting could cause people to be refused when connecting.egghead wrote:If you want to use eggdrops internal "listen" mechanism ...
I've tried to "dos" my bot by making numerous connections without reading the data. What happens is that the bot gets an incoming telnet connection and nothing happens any further. If there is a lot of connections the only thing I see is: "[01:17] Ident failed for hostname: No Free DCC's". And finally, when doing many connections from the same host, the bot places that host on ignore.user wrote: And also, since dccdumpfile is not async, people could use this port to dos your bot by connecting and just keeping the connection without reading any data.
Like user suggested, you have probably "protect-telnet" set to 1 which will disallow connections from unknown hosts.faisal wrote:I've tried but it doesnt work. The bot is able to trigger the !rules, but somehow it does not create a DCC Chat or execute the rules file. i've checked the "text-path" as mention and its path directory is "text/". So i uploaded the rules.txt into that folder. But still, the bot wont execute the rules file. Any idea what's causing the problem? or is there anyting else that i've forgotten to edit?