This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

DCC Chat

Old posts that have not been replied to for several years.
f
faisal
Voice
Posts: 13
Joined: Tue Nov 04, 2003 5:56 am
Location: Singapore

DCC Chat

Post by faisal »

Hello

Erm... how do i make a bot DCC Chat a user? I wanna execute the channel rules to the users via DCC Chat so that the bot will not disconnect due to excess flood.

Eg: When i type !rules, the bot will DCC chat me with the list of rules.


Yours Regards
Faisal
Oper @ Supra.Sg.ChatGalaxy.Org - ChatGalaxy IRC Network
User avatar
Rusher2K
Halfop
Posts: 88
Joined: Fri Apr 18, 2003 10:45 am
Location: Germany
Contact:

Post by Rusher2K »

Eggheads had written an example script i hope this can help you :

Code: Select all

http://members.fortunecity.com/eggheadtcl/chatme.tcl.txt
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

I think this is what you want...or at least it should point you in the right direction.

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
	}
}
Don't sue me if it doesn't work, but feel free to ask questions about the code :)
Have you ever read "The Manual"?
f
faisal
Voice
Posts: 13
Joined: Tue Nov 04, 2003 5:56 am
Location: Singapore

Post by faisal »

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.

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"
}
I understood that $n = the user, but what is $fn? is the rules file?
Online
User avatar
CrazyCat
Revered One
Posts: 1286
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

faisal wrote:

Code: Select all

set f [open $fn]
I understood that $n = the user, but what is $fn? is the rules file?
If you see set aaa [open $bbb], you are sure that bbb is a filename.
But I think something is missing:

Code: Select all

set f [open $fn FLAG]
with FLAG like r (read) or w (write) or a (append)
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

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.
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)
You don't need to care about the code inside the namespace...all you need to change (if anything) is the bind and that last proc.
CrazyCat wrote:But I think something is missing:

Code: Select all

set f [open $fn FLAG]
with FLAG like r (read) or w (write) or a (append)
r is the default mode and doesn't need to be specified.
Have you ever read "The Manual"?
Online
User avatar
CrazyCat
Revered One
Posts: 1286
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

user wrote:r is the default mode and doesn't need to be specified.
ok :)
but if I prefer to specify, let me specify :))
more seriously, I always specify, 'cuz I never comment my scripts when developping, so it's easiest to understand :)
But I'll remember this :)
Online
User avatar
CrazyCat
Revered One
Posts: 1286
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

lot of smileys in my former post, isn't it?
no one in this, average is good...
Sorry
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

Heh, since my name is mentioned here ... :) Like user said, the two scripts do completely different things. If you want to use eggdrops internal "listen" mechanism, you could base the script on e.g.
http://members.fortunecity.com/eggheadtcl/menu.tcl.txt

Below you will find the basic structure which serves a file from the text directory (as defined by the text-path variable in eggdrops config file). Of course this script should be further fancied up.

A nice plus is that by using the dccdumpfile mechanism, you can use text substitutions as described in doc/text-substitutions.doc.

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
}
f
faisal
Voice
Posts: 13
Joined: Tue Nov 04, 2003 5:56 am
Location: Singapore

Post by faisal »

Okay... i'll give it a try then...

Thanks! :D
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

egghead wrote:If you want to use eggdrops internal "listen" mechanism ...
Keep in mind that your protect-telnet setting could cause people to be refused when connecting.
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.
Have you ever read "The Manual"?
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

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.
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.
f
faisal
Voice
Posts: 13
Joined: Tue Nov 04, 2003 5:56 am
Location: Singapore

Post by faisal »

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?
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Post by egghead »

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?
Like user suggested, you have probably "protect-telnet" set to 1 which will disallow connections from unknown hosts.
f
faisal
Voice
Posts: 13
Joined: Tue Nov 04, 2003 5:56 am
Location: Singapore

Post by faisal »

I see... so is there any other alternative?
Locked